﻿var qsParm = new Array();

    //Functions Created by Virender Asija
    //Dated 02/05/2011

	function getDateFmt(firstDate)
	{
		var dates=firstDate.split('/');
		var day = dates[1];
		var month = dates[0]-1;
		var year = dates[2];
		firstDate = new Date(year, month, day);
		return firstDate;
	}

	//Difference between 2 dates
	function days_between(date1, date2) {

    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime()
    var date2_ms = date2.getTime()

    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms)
    
    // Convert back to days and return
    return difference_ms/ONE_DAY;

	}

function qs() {
    
    var query = window.location.search.substring(1);
    
    var parms = query.split('&');
    
    for (var i=0; i<parms.length; i++) {
    
        var pos = parms[i].indexOf('=');
    
        if (pos > 0) {
    
            var key = parms[i].substring(0,pos);
    
            var val = parms[i].substring(pos+1);
    
            qsParm[key] = val;
        }
    }
} 

function getCityPairText()
{
    var val = "";
    
    alert(val);
    
    val += $("#_ctl0_FROMA").val() + " - " + $("#_ctl0_TOB").val() + "<br>";
    
    alert(val);
    
    val += $("#_ctl0_DEPARTDATE").val() + " - " + $("#_ctl0_RETURNDATE").val() + "<br>";
    
    alert(val);
    
    return val;
}


///Function used to display Text for each Itinerary
function  getFareDescription() {

    var fare_Description = "total price including taxes fees and discounts for ";
    
    if(Number($("#_ctl0_Adults").val())> 0)
    {
        fare_Description += $("#_ctl0_Adults").val() + " Adult";
        
        if(Number($("#_ctl0_Adults").val())> 1)
        {
            fare_Description += "s,";
        }
    }
    
    if(Number($("#_ctl0_Children").val())> 0)
    {
        fare_Description += $("#_ctl0_Children").val() + " Child";
        
        if(Number($("#_ctl0_Children").val())> 1)
        {
            fare_Description += "ren, ";
        }
    }
    
    if(Number($("#_ctl0_Infants").val())> 0)
    {
        fare_Description += $("#_ctl0_Infants").val() + " Infant";
        
        if(Number($("#_ctl0_Infants").val())> 1)
        {
            fare_Description += "s";
        }
    }
    
    return fare_Description;
}

function taxes_Fees_PopUP() { 
       
        window.open('/content/Taxes_Fees.html', 'Total_Price', 'width=600, height=600,scrollbars=yes');
       
        return false;
    }

function templateURL(urlStr, param)
{
    qs();
    
    var url  = urlStr
    
    if(qsParm[param] != null)
    {
        url += "&"+ param +"=" + qsParm[param];
    }
    
    document.location.href = url;
}


function redirectWL()
{
    var str = window.location.hostname;

	if(str.indexOf("hariworld.com") < 0 && window.location.search.indexOf("WLID") < 0 && str.indexOf("192.168.") < 0 && str.indexOf("208.82.") < 0 && str.indexOf("localhost") < 0 )
	{
	    
		var str = str.substring(0,str.indexOf("."));

		str = window.location.hostname.replace(str, "www")

		window.location.href = "http://"+str
	}
}

function redirectIframeWL()
{
    var str = parent.window.location.hostname;

	if(str.indexOf("hariworld.com") < 0 && parent.window.location.search.indexOf("WLID") < 0 && str.indexOf("192.168.") < 0 && str.indexOf("208.82.") < 0 &&  str.indexOf("localhost") < 0 )
	{
		var str = str.substring(0,str.indexOf("."));

		str = parent.window.location.hostname.replace(str, "www")

		parent.window.location.href = "http://"+str
	}
}

function populateRightRailFrame(frame_URL)
{
    if(document.getElementById('WhiteLabel1_rightRail') != null)
    {
        document.getElementById('WhiteLabel1_rightRail').src = frame_URL;
    }
}

function populateRightRail()
{
    //alert($("#"+child_ID).val());
    
    var child_Count = Number($("#"+child_ID).val());
     
    child_Count += Number($("#"+Inf_ID).val());
    
    var roundOneVal = "oneway";
    
    if(RadioRound.checked)
    {
        roundOneVal = "round";
    }
    
    var url = "/BackOffice/RightRail.aspx?WINstartcity="+ $("#"+FROMA.id).val().substring($("#"+FROMA.id).val().length - 3, $("#"+FROMA.id).val().length) +"&WINendcity="+ $("#"+TOB.id).val().substring($("#"+TOB.id).val().length - 3, $("#"+TOB.id).val().length) +"&WINstartdate="+ $("#"+depart_Date_ID).val() +"&WINenddate="+ $("#"+return_Date_ID).val() +"&WINflightclass="+ $("#"+class_Of_Service_ID + ' input:checked').val() +"&WINadults="+ $("#"+adt_ID).val() +"&WINchildren="+ child_Count +"&WINtripstatus="+ roundOneVal;
    
    //alert(url);
    
    populateRightRailFrame(url);
}

function getAiportCode(str_Value)
{
    var airport_Code = "";
    
    if(str_Value.length > 3)
    {
        airport_Code = str_Value.substring(str_Value.length - 3, str_Value.length);
    }
    else
    {
        airport_Code = str_Value;
    }
    
    return airport_Code; 
}

function adjustDates(isoutbound)
{
    //debugger;
    var e1 = document.getElementById(isoutbound ? 'DEPARTDATE' : 'RETURNDATE');

    var e2 = document.getElementById(isoutbound ? 'RETURNDATE' : 'DEPARTDATE');

    ModifyDates(e1,e2);

    var RadioRound = document.getElementById("RadioRound");

    if (e1.id=='DEPARTDATE') if (RadioRound.checked) e2.select();
}

var ClickedOnPriceButton=false;				


function getClearFunc()
{
    if(window.location.toString().indexOf('WLID=') != -1)
    {
        document.getElementById("ClearButton").style.display = "none";
    }
}

function showClientError(message)
{
    $("#client_Check").show();
    
    if(message != '')
    {
        message = "<img src =\"/images/error_Info.gif\" alt=\"Error_Info\" /> &nbsp;&nbsp;" + message;
    }
    
    window.scroll(0,0);

    $("#client_Check").html(message);
}

function verify_Fields(id, message)
{
    if($.trim($("#"+id).val()) =='') {
        
        showClientError(message);
        
        window.scroll(0,0);
        
        return false;
    }
    
    return true;
}

function setTitle()
{
    if(!$.trim($("#"+FROMA.id).val()) == '')
    {   
        var title_Text = "Available flights for ";
        
        title_Text += getAiportCode($.trim($("#"+FROMA.id).val()).toUpperCase())+  '-' + getAiportCode($.trim($("#"+TOB.id).val()).toUpperCase());
        
        document.title = title_Text;
    }
}

function PriceButtonClick(wl_User)
{
    //Empty message, so it is not visible from transparent background
    showClientError('');
    
    if(!verify_Fields(FROMA.id, "Please verify origin city"))
    {
        return false;
    }
    
    if(!verify_Fields(TOB.id, "Please verify desination city"))
    {
        return false;
    }
    
    if(!verify_Fields(adt_ID, "Please verify adult count"))
    {
        return false;
    }
    
    if(!verify_Fields(child_ID, "Please verify child count"))
    {
        return false;
    }
    
    if(!verify_Fields(Inf_ID, "Please verify infant count"))
    {
        return false;
    }
    
    if(!verify_Fields(depart_Date_ID, "Please verify departing date"))
    {
        return false;
    }
    
    //alert(new Date());
    //alert((days_between(getDateFmt($("#"+depart_Date_ID).val()),  new Date()) <= 1));
    if((days_between(getDateFmt($("#"+depart_Date_ID).val()),  new Date()) <= 1))
	{
	    showClientError('Sorry you cannot purchase a flight departing within 1 day.');
	    
		return false;
	}
    
    if((!rad.checked) && !verify_Fields(return_Date_ID, "Please verify return date"))
    {
        return false;
    }
    
//    alert($("#"+depart_Date_ID).val());
//    alert($("#"+return_Date_ID).val());
//    
//    if($("#"+depart_Date_ID).val() > $("#"+return_Date_ID).val())
//    {
//        alert("Depart Date should be before Return Date");
//        
//        return false;
//    }
//    
    var today_Date = new Date();
     
    if((new Date($("#"+depart_Date_ID).val()) < today_Date))
    {
        showClientError("Please select departure date after today");
        
        return false;
    }
      
    if(isNaN($("#"+child_ID).val()))
    {
        showClientError("Children count is not a valid number");
        
        return false;
    }
    
    if(isNaN($("#"+adt_ID).val()))
    {
        showClientError("Adult count is not a valid number");
        
        return false;
    }
    
    if($("#"+adt_ID).val() < 1)
    {
        showClientError("Adult count should be greater than 0");
        
        return false;
    }
    
    if(isNaN($("#"+Inf_ID).val()))
    {
        showClientError("Infant count is not a valid number");
        
        return false;
    }
        
    var child_Count = Number($("#"+child_ID).val());
    
    if(child_Count + Number($("#"+adt_ID).val()) < 1)
    {
        showClientError("Please verify number of adults and number of children");
    }
     
    child_Count += Number($("#"+Inf_ID).val());
    
    ClickedOnPriceButton=true;    
    
    resettingPageIndex();
    
    //alert('test1');
    
    if(document.getElementById('FromPage') != null)
    {
        document.getElementById('FromPage').checked = true;
    }
    
    showjqmTimeout();
   
    if(wl_User == 'True')
    {
        //wayFares();
        
        win2 = window.open('/Advertisement.htm', 'Advertisement', 'width=165,height=600');
        
        win2.blur()
        
        window.focus()

    }
    
    pageTracker._trackPageview('/BackOffice/SearchFlights/SearchButton');    
}				
	
var ClickedOnTab=false;

function TabClick()
{
    ClickedOnTab=true;

    resettingPageIndex(); 
}	

function wayFares()
{    
    ConvertSearchFields('checkbox','','','airfare');
}

function resettingPageIndex()
{
    if(document.getElementById('PAGEINDEX') != null)
    {
        document.getElementById('PAGEINDEX').value = 0;
    }
}
				
function rulespop(id_zonefare) {showpopup('showrules.aspx?id_zonefare='+id_zonefare,'Rules',700,700);return false;}
function rulesInterlinepop(id_zonefare) {showpopup('showinterlinerules.aspx?id_zonefare='+id_zonefare,'Rules',700,700);return false;}
function showpopup_new(mypage,myname,w,h,features)
{
    if(screen.width)
    {
        var winl=(screen.width-w)/2;
        var wint=(screen.height-h)/2;
    }
    else
    {
        winl=0;wint=0;
    }
    if (winl < 0) 
        winl=0;
    if (wint < 0) 
        wint=0;
    var settings='height='+h+',';
    settings+='width='+w+',';
    settings+='top='+wint+',';
    settings+='left='+winl+',';
    settings+=features;
    win=window.open(mypage,myname,settings);
    win.window.focus();
    return false;
}

function showpopup(url, name, width, height){showpopup_new (url,name,width,height,'status=no,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes');return false;}

/*
    Populating Airline
*/
function airlineselect(mode, textbox_id, drop_id)
{
	var C = document.getElementById(textbox_id);
	
	var D = document.getElementById(drop_id);
	
	if (mode=='drop')
	{
	    C.value=D.value;
	}
	else
	{
		C.value=C.value.toUpperCase();

		D.value=C.value;
	}
	
}

function AirportLookup(textbox)
{
	var FROMC = document.getElementById("FROMC");

	if (FROMC.disabled && (textbox=='FROMC' || textbox=='TOD')) return;
	
	return showpopup('AirportLookup.aspx?textbox='+textbox,'AIRPORTS',400,500);
	
}

function TypingAircodes(textbox)
{
    if (FROMC.disabled)
	{
		FROMC.value=TOB.value;

		TOD.value=FROMA.value;
	}
	
}

function HideRow()
{	
	FROMC.disabled = RadioRound.checked;
	
	TOD.disabled = RadioRound.checked;
	
	FROMC.className = RadioRound.checked ? 'TEXTBOXDisabled' : 'TEXTBOXEnabled';
	
	TOD.className = RadioRound.checked ? 'TEXTBOXDisabled' : 'TEXTBOXEnabled';
	
	var value = "none";
	
	if(RadioRound.checked)
	{
	    row.style.display= "block";
	    
	    TR1.style.display = "none";

	    TR2.style.display = "none";
	} 
	else if(RadioOpenJaw.checked)
	{
	    value = "block";
	    
	    row.style.display= value;
	    
	    TR1.style.display = "block";

	    TR2.style.display = "block";
	}
	else
	{
	    row.style.display= value;
	}
	
	thirdRow.style.display = value;
	
	forthRow.style.display = value;
    
    fifthRow.style.display = value;
	
	sixthRow.style.display = value;
	
	if (FROMC.disabled)
	{
		FROMC.value=TOB.value;

		TOD.value=FROMA.value;
	}
	
}

function get_Date(number_Of_Days)
{
    var Mydate = new Date();

    Mydate.setDate(Mydate.getDate() + number_Of_Days);

    return formatDate(Mydate,'MM/dd/yyyy');
}


var timer;

function Onload()
{
	HideRow();
}

function off() {
   document.getElementById("hidethis").style.display = 'none';
}
function on() {
   document.getElementById("hidethis").style.display = '';
}
function OnewayOff()
{
    row.style.display = 'none';
}

var sg = "";

function DisplayDetails(ai,fm)
{
    sg = fm;    
    document.getElementById('PopupDiv').style.display = "none";
    poptext = ai;
    var tdRef = document.getElementById('tdUser');
    tdRef.innerHTML = poptext;
    window.setTimeout("ShowAct()", 300);   
}

function showjqmTimeout()
{
	showjqmOnSearch();
	
	window.setTimeout('addAnimatedImg()',300);
}

function addAnimatedImg()
{
    $("#animate_Img").html("");
	
	$("#animate_Img").append('<img src="/images/interstitial/moving_image.gif"/>');
}

function showjqmOnSearch()
{
    $('#searchProgressDialog').jqmShow();
}
 
function bookRedirect(id,str,buyNow)
{
    //Getting Query string
   qs();
   
	showjqmTimeout();

   var book_Flights_Location = "/BackOffice/BookFlights.aspx?ID="+ id+"&ind="+buyNow;
   
   //alert(qsParm['search']);
   
   //Checking Query string parameter
   if(qsParm['search'] != undefined)
   {
        book_Flights_Location += "&search="  + qsParm['search'];
   } 
   
   window.location = book_Flights_Location;        
}

function ShowAct()
{
        var ctl = sg;
        var leftpos=0;
        var toppos=0;
        myDiv = document.getElementById('PopupDiv');
        var aTag = ctl;
        try
        {
        do
        {
            aTag = aTag.offsetParent;
            leftpos += aTag.offsetLeft;
            toppos += aTag.offsetTop;              
        }
        while(aTag.tagName!="BODY");
            myDiv.style.left = ctl.offsetLeft + leftpos + 50+ 'px';
            myDiv.style.top = ctl.offsetTop + toppos - 50 + 'px';
            myDiv.style.display = 'block';
        }
        catch(e)
        {
            //alert("Oops! Something bad just happened. Calling 911...");
        }
}

function UnPop()
{
    document.getElementById('PopupDiv').style.display = "none";
}  
function switchMenu(obj) 
{
   var el = document.getElementById(obj);
   if ( el.style.display != "none" )
   {
      el.style.display = 'none';
   }
   else 
   {
      el.style.display = '';
   }
}


var booking_Completed = false;

function ajaxBooking(id, record_ID, wlUser, openJaw_Local, ticketingTimeLimitID)
{
    if(record_ID >= 0)
    {
        //alert('test');
        //showing processing to agents user only
        if(wlUser != 'True')
        {
            $('#Ajax_Loader_Large').show("slow");
        }
        
        var jqxhr = $.get("/AjaxBookFlights.aspx?mode=ticket&Booking_ID="+id+"&record_ID="+record_ID+"&openJaw="+openJaw_Local, function(response) {
                
        //alert(response.toString().length);
        
        if(response.toString().length == 6)
        {
            //$('#Ajax_Confirmation').show("slow");
            
            //setting PNR Value in P div showing PNR
            $('#pnr_Status_Value').html(response);
            
            if(wlUser != 'True')
            {
                $('#'+ticketingTimeLimitID).show("slow");
            }
            
            booking_Completed = true;
            
        }
        else
        {
            $('#Ajax_Confirmation').show("slow");
            
            $('#Ajax_Confirmation').html("Sorry we are unable to confirm your selection. Please Search Again.<br><a href=\"/Backoffice/SearchFlights.aspx?mode=searchflights\" >Search Flights</a>");
            
            window.scroll(0,0);
        }
        
        $('#Ajax_Loader_Large').hide("slow");
        
        //alert(response);
    });
    }
}

var rege = /^([a-zA-Z ]+)$/;
    
var phone_rege = /^\d{3}\-\d{3}\-\d{4}$/;

function button_Continue_Validators(place)
{
    var inner_HTML = "<h1 class=\"client_Error_H1\">We are unable to continue booking as we need you to provide more information:</h1><ul class=\"client_Error_UL\">";
        
    var error = "";
    
    var today_Date = new Date();
    
    if(!($("#CheckBoxDISCLAIMER").is(':checked')))
    {
        error += '<li  class="client_Error_LI">Please accept our Terms and Rules</li>';
    }
    
    if($.trim($("#PHONE_NUMBER").val()).length == 0)
    { 
        error += '<li  class="client_Error_LI">Please provide Contact Phone Number.</li>';
    }
    
    if($.trim($("#PHONE_NUMBER").val()).length > 0 && !phone_rege.test($("#PHONE_NUMBER").val()))
    {
        error += '<li  class="client_Error_LI">Please check the Contact Phone Number format.</li>';
    }
    
    if($.trim($("#" + txt_b_Email).val()).length == 0 && !validate_email($("#" + txt_b_Email).val()))
    {
        error += '<li  class="client_Error_LI">Please provide a valid Email Address</li>';
    }
    
    if($.trim($("#" + txt_Retype_Email).val()).length == 0 && !validate_email($("#" + txt_Retype_Email).val()))
    {
        error += '<li  class="client_Error_LI">Please provide Email again for confirmation</li>';
    }
    
    if($.trim($("#" + txt_b_Email).val()) != $.trim($("#" + txt_Retype_Email).val()))
    {
        error += '<li  class="client_Error_LI">Email Addresses you provided do not match</li>';
    }
    
    for (key in passangar_First_name)
    {
        if($.trim($("#"+key).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide passenger First Name</li>';
            break;
        }
        
        if($.trim($("#"+key).val()).length > 0 && !rege.test($("#"+key).val()))
        {
            error += '<li class="client_Error_LI">Only characters(a-z) and spaces are allowed in First Name</li>';
            break;
        }
    }
    for (key in passangar_Middle_name)
    {
        if($.trim($("#"+key).val()).length > 0 && !rege.test($("#"+key).val()))
        {
            error += '<li class="client_Error_LI">Only characters(a-z) and spaces are allowed in Middle Name</li>';
            break;
        }
    }
    
    for (key in passangar_Last_name)
    {
        if($.trim($("#"+key).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide passenger Last Name</li>';
            break;
        }
        
        if($.trim($("#"+key).val()).length > 0 && !rege.test($("#"+key).val()))
        {
            error += '<li class="client_Error_LI">Only characters(a-z) and spaces are allowed in Last Name</li>';
            break;
        }
    }
    for (key in passangar_Date_Of_Birth)
    {
        var value = $.trim($("#"+key).val());
        
        if(value.length == 0)
        {
            error += '<li class="client_Error_LI">Please provide passenger Date of Birth</li>';
            break;
        }   
        /*alert(isDate(value, "mm/dd/yyyy"));*/
        if (value.length > 0 && !isDate(value, "MM/dd/yyyy"))
        {
            error += '<li class="client_Error_LI">Please verify your Date of Birth format</li>';
            break;
        }
        
        var array_Val = passangar_Date_Of_Birth[key];
        
        var element_Val = $.trim($("#"+array_Val).html());
        
        //alert(element_Val);
        
        if(element_Val == 'Child')
        {
            var checkInDt = new Date();
            
            var aFromDate = value.split("/");
    
            /*Start 'Date to String' conversion block, this block is required because javascript do not provide any direct function to convert 'String to Date' */
            var fdd = aFromDate[1]; //get the day part
            var fmm = aFromDate[0]; //get the month part
            var fyyyy = aFromDate[2]; //get the year part
            
            checkInDt.setUTCDate(fdd);
            checkInDt.setUTCMonth(parseInt(fmm) -1);
            checkInDt.setUTCFullYear(parseInt(fyyyy) + 12);
    
            if(checkInDt < today_Date)
            {
                error += '<li class="client_Error_LI">Please verify Child Age. Child Fare Applies less than 12 years</li>';
                break;
            }
        }
        
        //alert(element_Val);
        
        if(element_Val == 'Infant')
        {
            var checkInDt = new Date();
            
            var aFromDate = value.split("/");
    
            /*Start 'Date to String' conversion block, this block is required because javascript do not provide any direct function to convert 'String to Date' */
            var fdd = aFromDate[1]; //get the day part
            //alert(fdd);
            var fmm = aFromDate[0]; //get the month part
            //alert(fmm - 1);
            var fyyyy = aFromDate[2]; //get the year part
            //alert(fyyyy);
            
            checkInDt.setUTCDate(fdd);
            checkInDt.setUTCMonth(parseInt(fmm)-1);
            checkInDt.setUTCFullYear(parseInt(fyyyy) + 2);
            
            if(checkInDt < today_Date)
            {
                error += '<li class="client_Error_LI">Please verify Infant Age. Infant Fare Applies less than 2 years</li>';
                
                break;
            }
        }
        
    }
    
//    for (key in infant_Associations)
//    {
//        if($("select[id$='" + key+ "']")!= null && $("select[id$='" + key+ "']")!== undefined)
//        {
//            for (key1 in infant_Associations)
//            {
//                if(key != key1)
//                {
//                    if($("select[id$='" + key1+ "']")!= null && $("select[id$='" + key1+ "']")!== undefined)
//                    {
//                        if($.trim($("select[id$='" + key+ "']  :selected").text()) != $.trim($("select[id$='" + key1+ "']  :selected").text()))
//                        {
//                                error += '<li  class="client_Error_LI">Infants has to be associated to different Adults</li>';
//                        }
//                    }
//                }
//            }
//        }
//    }
//    
    for (key in passangar_Gender)
    {
        if($.trim($("select[id$='" + key+ "']  :selected").text()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide passenger Gender</li>';
            break;
        }
    }
    
    if(error.length >0)
    {
        $('#client_Check').html(inner_HTML + error + "</ul>");
        
        if(!$('#client_Check').is(':visible'))
        {
            $('#client_Check').show("slow");
        }
            
        window.scrollTo(0,0);
             
        return false;
    }
    
    var id = '#dialog';
    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //Set heigth and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});
	
    //transition effect		
    $('#mask').show();	
    //$('#mask').fadeTo("fast",0.8);	
    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();
    
    //Set the popup window to center
    $(id).css('top',  (winH/2-$(id).height()/2)+$(window).scrollTop());
    $(id).css('left', (winW/2-$(id).width()/2)+$(window).scrollLeft());

    //transition effect
    $(id).show(); 
    
    window.setTimeout('addAnimatedImg()',300);
    
    pageTracker._trackPageview('/bookflights/Book_Flight_'+place);
    
    return true;
}

function button_Issue_Ticket_Validators()
{
    var inner_HTML = "<h1 class=\"client_Error_H1\">We are unable to continue booking as we need you to provide more information:</h1><ul class=\"client_Error_UL\">";
        
    var error = "";
    
    if(!booking_Completed && record_ID > -1)
    {
        error = '<li  class="client_Error_LI">Sorry we cannot confirm following itinerary with airline, Please seach again and select some other itinerary.</li>';
    }
    
    if(!($("#"+checkbox_Disclaimer_Validator_ID).is(':checked')))
    {
        error += '<li  class="client_Error_LI">Please accept our Terms and Rules</li>';
    }
    
    //Checking Credit Card Details on client side
    if(document.getElementById(is_CC_Payment) === null || document.getElementById(is_CC_Payment).checked)
    {
        if($.trim($("#"+cc_Name_Validator_ID).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card Holder Name</li>';
        }
        if($.trim($("#"+address_Validator_ID).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card Address</li>';
        }
        if ($('#'+state_Validator_ID +' option:selected').length == 0)
        {
          error += '<li  class="client_Error_LI">Please provide Billing State</li>';
        }
        if($.trim($("#"+zip_Validator_ID).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card Holder Zip</li>';
        }
        if($.trim($("#"+cc_Type_ID).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card Type</li>';
        }
        if($.trim($("#"+cc_Number).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card Number</li>';
        }
        if($.trim($("#"+cc_Month+' option:selected')).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card Expiration Month</li>';
        }
        if($.trim($("#"+cc_Year+' option:selected')).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card Expiration Year</li>';
        }
        if($.trim($("#"+cc_CCCvv).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card CVV Number</li>';
        }
        if($.trim($("#"+billing_Phone_Number_Validator_ID).val()).length == 0)
        {
            error += '<li class="client_Error_LI">Please provide your Credit Card Billing Phone Number</li>';
        }
    }
    
    if($.trim($("#"+contact_Phone_Number).val()).length == 0)
    {
        error += '<li  class="client_Error_LI">Please provide your Preferred Contact Phone Number</li>';
    }
      
    if(!($("#"+chk_Contact_Info).is(':checked')) && (document.getElementById(is_CC_Payment).checked))
    {
        if($.trim($("#"+txt_contact_Address).val()).length == 0)
        {
            error += '<li  class="client_Error_LI">Please provide your Preferred Contact Address</li>';
        }
        
        if($.trim($("#"+txt_contact_City).val()).length == 0)
        {
            error += '<li  class="client_Error_LI">Please provide your Preferred Contact City</li>';
        }
        
        if($.trim($("#"+state_Contact_City+' option:selected')).length == 0)
        {
            error += '<li  class="client_Error_LI">Please provide your Preferred Contact State</li>';
        }
        
        if($.trim($("#"+txt_contact_Zip).val()).length == 0)
        {
            error += '<li  class="client_Error_LI">Please provide a valid Preferred Contact Zip Code</li>';
        }
     }

    if(error.length >0)
    {
        $('#client_Check').html(inner_HTML + error + "</ul>");
        
        if(!$('#client_Check').is(':visible'))
        {
            $('#client_Check').show("slow");
        }
            
        window.scrollTo(0,0);
             
        return false;
    }
        
        var id = '#dialog';
        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
	
        //Set heigth and width to mask to fill up the whole screen
        $('#mask').css({'width':maskWidth,'height':maskHeight});
		
        //transition effect		
        $('#mask').show();	
        //$('#mask').fadeTo("fast",0.8);	
        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();
        
        //Set the popup window to center
        $(id).css('top',  (winH/2-$(id).height()/2)+$(window).scrollTop());
        $(id).css('left', (winW/2-$(id).width()/2)+$(window).scrollLeft());
	
        //transition effect
        $(id).show(); 	
        
        window.setTimeout('addAnimatedImg()',300);
        
        pageTracker._trackPageview('/ticket/purchace_Ticket');
    
    return true;
}


  function validate_email(address) {
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
            if(reg.test(address) == false) {
            return false;
        }
        return true;
    }
    
    function validate_Feedback_Form()
    {
       alert("In validate_Feedback_Form()");
        
        if($.trim($("#emailAddress").val()).length == 0)
        {
            showFeedbackPageError("Please provide email address.");
            
            return false;
        }
        
        if(!validate_email($("#emailAddress").val()))
        {
            showFeedbackPageError("Please provide valid email address.");
                       
            return false;
        }
        
        if($.trim($("#textFeedBack").val()).length == 0)
        {
            showFeedbackPageError("Please provide feedback.");
            
            return false;
        }
        
        return true;    
    }
    
    function showFeedbackPageError(message)
    {
         $("#messageDiv").show();
            
         $("#messageDiv").html(message);
         
    }
    
    //Function used to validate MyBooking Form
    function validateMyBookingForm()
    {
        //If reference id is blank
        if($.trim($('#RefID').val()).length == 0)
        {
            alert('Please verify Reference ID.');
            return false;
        }
        
        //If email id is blank
        if($.trim($('#EmailID').val()).length == 0)
        {
           alert('Please verify Email ID.');
           return false; 
        }
        
        //If email ID provided is not valid
        if(!validate_email($("#EmailID").val()))
        {
            alert('Please provide a valid email ID.');
            return false;
        }
    }





