function PopUpModalDialog(strURL, winName, winWidth, winHeight, winTop, winLeft, winResizable, winScroll, winStatus, winHelp, winLocation, winMenu, winToolbar){
	if(window.showModalDialog){
		var features =
			'dialogWidth:'		+ winWidth + 'px' +
			';dialogHeight:'	+ winHeight + 'px' +
			';dialogTop='		+ winTop + 'px' +
			';dialogLeft='		+ winLeft + 'px' +
			';resizable:'		+ winResizable +
			';scrollbars:'		+ winScroll +
			';status:'			+ winStatus +
			';help:'			+ winHelp ;
		window.showModalDialog(strURL, winName, features);
	}else{
		var features =
			'width='			+ winWidth +
			',height='			+ winHeight +
			',top='				+ winTop +
			',left='			+ winLeft +
			',resizable='		+ winResizable +
			',scrollbars='		+ winScroll +
			',status='			+ winStatus +
			',location='		+ winLocation +
			',menubar='			+ winMenu +
			',toolbar='			+ winToolbar;
			',dependant=yes'
		window.open (strURL, winName, features);
	}
}
function PopUpModalWindowPG(){
	window.showModalDialog("RequestPastGuestNumber.aspx" , "" , "dialogHeight:400px;dialogWidth:650px;resizable:1;scrollbars:0;status:0;help:0;dialogTop=px;dialogLeft:px")
}
function PopUpModalWindowFromShip(){
	window.showModalDialog("EmailToFriend.aspx?From=FromShip" , "Email To a Friend" , "dialogHeight:400px;dialogWidth:500px;resizable:0;scrollbars:0;status:0;help:0;dialogTop=px;dialogLeft:px")
		
}
function PopUpModalWindowFromDestination(){
	window.showModalDialog("EmailToFriend.aspx?From=FromDestination" , "Email To a Friend" , "dialogHeight:400px;dialogWidth:500px;resizable:0;scrollbars:0;status:0;help:0;dialogTop=px;dialogLeft:px")			
}
function PopUpModalWindowFromItinerary(){
	window.showModalDialog("EmailToFriend.aspx?From=FromItinerary" , "Email To a Friend" , "dialogHeight:400px;dialogWidth:500px;resizable:0;scrollbars:0;status:0;help:0;dialogTop=px;dialogLeft:px")			
}
function PopUpModalWindowFromShoreTour(){
	window.showModalDialog("EmailToFriend.aspx?From=FromShoreTour" , "Email To a Friend" , "dialogHeight:400px;dialogWidth:500px;resizable:0;scrollbars:0;status:0;help:0;dialogTop=px;dialogLeft:px")			
}
function PopUpModalWindowFromConfirmation(){
	window.showModalDialog("EmailToFriend.aspx?From=FromConfirmation" , "Email To a Friend" , "dialogHeight:400px;dialogWidth:500px;resizable:0;scrollbars:0;status:0;help:0;dialogTop=px;dialogLeft:px")			
}
function PopUpModalWindowFromSpecials(){
	window.showModalDialog("EmailToFriend.aspx?From=FromSpecials" , "Email To a Friend" , "dialogHeight:400px;dialogWidth:500px;resizable:0;scrollbars:0;status:0;help:0;dialogTop=px;dialogLeft:px")			
}
function PopUpModalWindowAddPastGuest(){
	var PastGuestNumber	= 0;
	var ReturnVal = new Object();
	window.showModalDialog("AddPastGuestNumber.aspx?From=FromUpdateprofile.aspx" , ReturnVal , "dialogHeight:400px;dialogWidth:600px;resizable:0;scrollbars:0;status:0;help:0")			
	PastGuestNumber = ReturnVal.PastGuestNumber;
	if((PastGuestNumber != 0) && (PastGuestNumber != null)){
		document.frmTestPage.action = "TestPage.aspx?PastGuest=" + PastGuestNumber;
		document.frmTestPage.submit();
	}else if( PastGuestNumber = -1 ){
		document.location.href = "UpdateProfile.aspx"			
	}else if  (PastGuestNumber = -2 ){
		document.location.href = "MyProfile.aspx"
	}
}
function SetError(){
    alert('seterror');
 	var Error = document.getElementById("lblError");
 	if(Error != null){
		Error.innerText = "";
	}
}
function CheckLength300Chars(oSrc, args){
	var TextMessage;
	TextMessage = args.Value;			
	args.IsValid = (TextMessage.length < 300);			
}
function PopUpWindow(PageName){
	window.open(PageName);
}

function PopUpWindow(PageName){
	var wind = window.open(PageName);
	wind.target = "_blank";
}
function RedirectTo(PageName){
	document.forms[0].action = PageName;
	document.forms[0].submit();			
}
/*
function ReloadTo(PageName){
	if ( (PageName == null) || (PageName == "") ) {
	}else{
		window.location.href = PageName;
	}		
}
*/
function RegularExpressionValidator(val, validationexpression) {	
    var value = val;    
    var rx = new RegExp(validationexpression);
    var matches = rx.exec(value);
    return (matches != null && value == matches[0]);
}
function ValidateZipCodeForUSAndCA (ZipCode, CountryCode){
	var IsValid = true;				
	var RegExpUS = "\\d{9}(-\\d{4})?|\\d{5}\\s\\d{4}|\\d{5}\\-\\d{4}|\\d{5}";
	var RegExpCA = "^[A-Za-z]\\d[A-Za-z]\\d[A-Za-z]\\d|^[A-Za-z]\\d[A-Za-z]-\\d[A-Za-z]\\d|^[A-Za-z]\\d[A-Za-z]\\s\\d[A-Za-z]\\d";			
	var ExpUS = new RegExp(RegExpUS);
	var ExpCA = new RegExp(RegExpCA);				
	
	if ( CountryCode == "US"){	
		IsValid = RegularExpressionValidator(ZipCode, RegExpUS);
	}else {
		if(ExpCA.exec(ZipCode) == null){
			IsValid = false;
		}
	}
	return (IsValid);
}

function std_OnChangeControl(srvCtl, rfvCtl, rfvCtl2)
{
    var lsrvCtl = document.getElementById(srvCtl);
    var lrfvCtl = document.getElementById(rfvCtl);
    var lrfvCtl2 = document.getElementById(rfvCtl2);
    
    if ((lsrvCtl.value != null) && (lsrvCtl.value != ""))
    {
        lsrvCtl.className = "LV_valid_field";
    }
            
    if (lrfvCtl != null)
    {
        lrfvCtl.style.display = "none";
    }
    
    if (lrfvCtl2 != null)
    {
        lrfvCtl2.style.display = "none";
    }
    
    std_OnDeactivateControl(srvCtl, rfvCtl, rfvCtl2);    
}

function std_OnActivateControl(srvCtl, rfvCtl, rfvCtl2)
{    
    var srvCtl = document.getElementById(srvCtl);
    var rfvCtl = document.getElementById(rfvCtl);
    var rfvCtl2 = document.getElementById(rfvCtl2);
    
    srvCtl.className = "";
    
    if (rfvCtl != null)
    {
        rfvCtl.style.display = "none";
    }
    
    if (rfvCtl2 != null)
    {
        rfvCtl2.style.display = "none";
    }
}

function std_OnDeactivateControl(srvCtl, rfvCtl, rfvCtl2)
{
    var lrfvCtl = document.getElementById(rfvCtl);
    var lrfvCtl2 = document.getElementById(rfvCtl2);
    var srvCtl = document.getElementById(srvCtl);

    if ((srvCtl.value != null) && (srvCtl.value != ""))
    {
        srvCtl.className = "LV_valid_field";
    }
    else
    {
        srvCtl.className = "";
    }

    if (lrfvCtl != null)
    {	        
        ValidatorValidate(lrfvCtl);
                
        lrfvCtl = document.getElementById(rfvCtl);
        
        if (lrfvCtl.style.display == "inline")
        {
            srvCtl.className = "LV_invalid_field";        
        }
        else
        {
            if (lrfvCtl2 != null)
            {
                ValidatorValidate(lrfvCtl2);
                lrfvCtl2 = document.getElementById(rfvCtl2);
                if (lrfvCtl2.style.display == "inline")
                {
                    srvCtl.className = "LV_invalid_field";
                }
            }
        }
    }
}


function verifyCardNumber(ccNumb, cType)
    {  
//    alert('from js '+ ccNumb + ' ' + cType);
        //Capitalize cardtype for consistency
        var cardType = cType.toUpperCase();             
        
        // Strip any non-digits (useful for credit card numbers with spaces and hyphens)
        var number = ccNumb.replace(/\D/g, '');        
        
        //Verify Card Number as per : 
                //1) Type of card
                //2) Mod10 validation
        if(verifyCardType(cardType,number))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

function verifyCardType(cardType, cardNumber)
    {
        if(cardType == "AMEX")
        {
             // AMEX -- 34 or 37 -- 15 length
            var regExp = new RegExp('^(34|37)');          
            if((cardNumber.match(regExp)) && cardNumber.length == 15) {
                if(Mod10Validation(cardType, cardNumber)) {
                    return true; }
                else {
                    return false; }
            }
            else {
                return false; }
        }
        else if(cardType == "VISA")
        {
            // VISA -- 4 -- 13 and 16 length
            var regExp = new RegExp('^(4)');
            if((cardNumber.match(regExp)) && (cardNumber.length == 13 || cardNumber.length == 16)) {
                if(Mod10Validation(cardType, cardNumber)) {
                    return true; }
                else {
                    return false; }
            }
            else {
                return false; }
        }
        else if(cardType == "MASTERCARD")
        {
            // MasterCard -- 51 through 55 -- 16 length 
            var regExp = new RegExp('^(51|52|53|54|55)');            
            if((cardNumber.match(regExp)) && cardNumber.length == 16) {
                    if(Mod10Validation(cardType, cardNumber)) {
                    return true; }
                else {
                    return false; }
            }
            else {
                return false; }
        }
        else if(cardType == "DINNERSCLUB" || cardType == "CARTE BLANCHE")
        {
            // Diners Club -- 300-305, 36 or 38 -- 14 length
             var regExp = new RegExp('^(300|301|302|303|304|305|36|38)');
            if((cardNumber.match(regExp)) && cardNumber.length == 14) {
                    if(Mod10Validation(cardType, cardNumber)) {
                    return true; }
                else {
                    return false; }
            }
            else {
                return false; }
        }
        else if(cardType == "ENROUTE")
        {
            // enRoute -- 2014,2149 -- 15 length
            var regExp = new RegExp('^(2014|2149)');
            if((cardNumber.match(regExp)) && cardNumber.length == 15) {                    
                    if(Mod10Validation(cardType, cardNumber)) {
                    return true; }
                else {
                    return false; }
            }
            else {
                return false; }
        }
        else if(cardType == "DISCOVER")
        {
            // Discover -- 6011 -- 16 length
            var regExp = new RegExp('^(6011)');
            if((cardNumber.match(regExp)) && cardNumber.length == 16) {
                    if(Mod10Validation(cardType, cardNumber)) {
                    return true; }
                else {
                    return false; }
            }
            else {
                return false; }
        }
        else if(cardType == "JCB")
        {
            //JCB -- 3 -- 16 length
            //-------2131, 1800 -- 15 length
            var regExp1 = new RegExp('^(3)');
            var regExp2 = new RegExp('^(2131|1800)');
            if(((cardNumber.match(regExp1)) && cardNumber.length == 16) ||
                ((cardNumber.match(regExp2)) && cardNumber.length == 15)) {
                    if(Mod10Validation(cardType, cardNumber)) {
                    return true; }
                else {
                    return false; }
            }
            else {
                return false; }
        }
        else
        {
            return false;
        }
    }

function Mod10Validation(cardType, number)
    {
      // Set the string length and parity
      var number_length=number.length;
      var parity=number_length % 2;

      // Loop through each digit and do the maths
      var total=0;
      for (i=0; i < number_length; i++) {
            //Fetch current digit
            var digit=number.charAt(i);   
            // Multiply alternate digits by two
            if (i % 2 == parity) {
                digit=digit * 2;
                // If the sum is two digits, add them together (in effect)
                if (digit > 9) {
                    digit=digit - 9;
                }
            }
            // Total up the digits
            total = total + parseInt(digit);
      }

      // If the total mod 10 equals 0, the number is valid
      if (total % 10 == 0) {
        return true;
      } 
      else {       
        return false;
      }
    }
    
function ValidateCreditCardExpiry(expMonth, expYear)
    {
        
//        alert('entered common.js for validate card expiry');
        
        //Set expiry date as last day of the month depending upon the month value
        var expDate = 30;
        if(expMonth == 1 || expMonth == 3 || expMonth == 5 || expMonth == 7 || expMonth == 8 || expMonth == 10 || expMonth == 12)
        {
            expDate = 31;
        }
        else if(expMonth == 4 || expMonth == 6 || expMonth == 9 || expMonth == 11)
        {
            expDate = 30;
        }
        else
        {
            expDate = 28;
        }

        //Fetch current Date
        var today = new Date();
        
        //Set Expiry Date
        var expiryDate = new Date();
        expiryDate.setFullYear(expYear,expMonth-1, expDate);
//       alert(expiryDate + '   ' + today);
                
        //Verify expiryDate is later than today's date                
        if(expiryDate >= today) {
            return true;}
        else {
            return false; }
    }
 	
	/*--------Booking Summary Functions Start Here--------------*/
function BookingStepsClick(index)
{
	if (document.all("BookingSteps_imgStep" + index))
	  document.getElementById("BookingSteps_imgStep" + index).click()
}



/*------------Booking Summary Functions End Here------------*/


/*--------Departure Info Functions Start Here--------------*/

function ShowDepartureInfo()
{
	var windowPrms="width=350,height=250";
	window.open("WhyDepartureInfo.aspx","WhyDepartureInfo",windowPrms);
}

/*------------Departure Info Functions End Here------------*/
	
	/* Primary Guest - start*/
	function PopUpModalWindowAddPastGuestPG(){
		ReturnVal = new Object();
		window.showModalDialog('AddPastGuestNumber.aspx', ReturnVal, 'dialogHeight=450,dialogWidth=650', PopUpModalWindowAddPastGuestClose);
	}
	
	function PopUpModalWindowAddPastGuestClose(){

		var PastGuestNumber = ReturnVal.PastGuestNumber;
		if((PastGuestNumber != 0) && (PastGuestNumber != null)){	
			if (PastGuestNumber == -1){
				document.location.href  = "UpdateProfile.aspx";					
			}else{
				document.frmMyProfile.submit();
			}
		}
		ReturnVal = new Object();
	}
	
	function ShowSpecialneed()
	{	    
	    if(document.getElementById('trSpecialNeed').style.display == 'none')
	    {
	        document.getElementById('trSpecialNeed').style.display = '';
	        document.getElementById('Span1').innerHTML = '<A href="javascript:ShowSpecialneed();">less</A>';
	    }
	    else
	    {
	        document.getElementById('Span1').innerHTML = '<A href="javascript:ShowSpecialneed();">more</A>';
	        document.getElementById('trSpecialNeed').style.display='none';
	    }
	}
	function SpecialNeedsModalWindow(){
		var CalledPage="cms/Static_Templates/SpecialNeeds.aspx?Page="+window.parent.document.title;
		window.showModalDialog(CalledPage, "SpecialNeeds" , "dialogHeight:250px;dialogWidth:500px;resizable:1;status:0;help:0")						
	}
//	function ShowStateroomCategory(shipCode, shipName, catCode)
//{
//	var windowPrms="width=420,height=450,top=0,left=0, scrollbars=1";
//	window.open("/StateroomDetail.aspx?ShipName=" + shipName + "&ShipCode=" + shipCode + "&CatCode=" + catCode,"StateroomCategory",windowPrms);
//}
	/* Primary Guest - end*/
	
/*ShoreExcursionDetails.ascx  ------ start*/
  function DisplayDetails()
    {
        var divDetails = document.getElementById('divDetails');
        divDetails.style.display = "inline";
    }

    function CloseActiveToolTip()
    {
        setTimeout(function(){            
            var controller = Telerik.Web.UI.RadToolTipController.getInstance();
            var tooltip = controller.get_ActiveToolTip();
            if (tooltip) tooltip.hide();
        }, 1000);
    }

 function closeVideo()
    {
        StopFlashMovie("shoreExVideo");
    }
    
    function closePhotos()
    {
        StopPhotos("shoreExPhotos");
    }
    
    function getFlashMovieObject(movieName)
    {
      if (window.document[movieName]) 
      {
          return window.document[movieName];
      }
      if (navigator.appName.indexOf("Microsoft Internet")==-1)
      {
        if (document.embeds && document.embeds[movieName])
          return document.embeds[movieName]; 
      }
      else 
      {
        return document.getElementById(movieName);
      }
    }
    
    function StopFlashMovie(movieName)
    {
	    var flashMovie=getFlashMovieObject(movieName);
	    flashMovie.sendEvent('STOP',null); 
    }
    
    function StopPhotos(movieName)
    {
        var flashMovie=getFlashMovieObject(movieName);
	    flashMovie.StopPlay();
    }
/*ShoreExcursionDetails.ascx  ------ end*/

/* AddToCart ----Start*/
function ValidSailDate(source, arguments) 
{
    var today = new Date();
    var currentYear = today.getFullYear();
    var inputvalue = arguments.Value;
    var inputyear = inputvalue.split("/");
    var count = inputyear.length;
    if (inputyear[count - 1] < currentYear) 
    {
        arguments.IsValid = false;
    }
}
/* AddToCart ----End*/

/* ProductDetails.ascx functions starts here*/
function pdCalcCruiseCerts(num1, ctlTotalID, ctlquantityID, dollaramount) 
{
    var ctlTotalText = document.getElementById(txtTotalSummCruiseCerts);
    var texttosplit = TOTAL_IDS.split(",");
    var summ = 0;
    summ = parseInt(summ);
    var ctlTotal = document.getElementById(ctlTotalID);
    var ctlQuantity = document.getElementById(ctlquantityID);

    if (isNaN(num1) == true)
        return false;

    if (num1.substr(0, 1) == "-") {
        ctlTotal.innerText = "";
        return false;
    }

    if (num1.indexOf(".") >= 0) {
        ctlTotal.innerText = "";
        return false;
    }
    if (ctlTotal != null && ctlQuantity != null) 
    {
        if (num1 != null && num1 != "") 
        {
            ctlTotal.innerText = "$" + num1 * dollaramount + ".00";
            for (var i = 0; i < texttosplit.length; i++) 
            {
                var ctlSumm = document.getElementById(texttosplit[i]);
                var dirtyvalue = ctlSumm.innerText;
                var decimalposition = dirtyvalue.indexOf(".");
                var cleanvalue = dirtyvalue.substr(1, decimalposition - 1);
                var numericvalue = parseInt(cleanvalue);

                if (isNaN(numericvalue) == false) 
                {
                    summ = summ + numericvalue;
                    if (ctlTotalText != null) 
                    {
                        ctlTotalText.innerText = "$" + summ + ".00";
                    }
                }
            }
        }
        else 
        {
            ctlTotal.innerText = "";
            ctlTotalText.innerText = "";
            for (var i = 0; i < texttosplit.length; i++) 
            {
                var ctlSumm = document.getElementById(texttosplit[i]);
                var dirtyvalue = ctlSumm.innerText;
                var decimalposition = dirtyvalue.indexOf(".");
                var cleanvalue = dirtyvalue.substr(1, decimalposition - 1);
                var numericvalue = parseInt(cleanvalue);
                if (isNaN(numericvalue) == false) 
                {
                    summ = summ + numericvalue;
                    if (ctlTotalText != null) 
                    {
                        ctlTotalText.innerText = "$" + summ + ".00";
                    }
                }
            }
        }
    }
}

function pdCalcFunShipDollars(num1, ctlTotalID, ctlquantityID, dollaramount) 
{
    var ctlTotalText = document.getElementById(txtTotalSummary);
    var texttosplit = TOTAL_IDS.split(",");
    var summ = 0;
    summ = parseInt(summ);
    var ctlTotal = document.getElementById(ctlTotalID);
    var ctlQuantity = document.getElementById(ctlquantityID);

    if (isNaN(num1) == true)
        return false;

    if (num1.substr(0, 1) == "-") {
        ctlTotal.innerText = "";
        return false;
    }

    if (num1.indexOf(".") >= 0) {
        ctlTotal.innerText = "";
        return false;
    }
    
    if (ctlTotal != null && ctlQuantity != null) 
    {
        if (num1 != null && num1 != "") 
        {
            ctlTotal.innerText = "$" + num1 * dollaramount + ".00";
            for (var i = 0; i < texttosplit.length; i++) 
            {
                var ctlSumm = document.getElementById(texttosplit[i]);
                var dirtyvalue = ctlSumm.innerText;
                var decimalposition = dirtyvalue.indexOf(".");
                var cleanvalue = dirtyvalue.substr(1, decimalposition - 1);
                var numericvalue = parseInt(cleanvalue);

                if (isNaN(numericvalue) == false) 
                {
                    summ = summ + numericvalue;
                    if (ctlTotalText != null) 
                    {
                        ctlTotalText.innerText = "$" + summ + ".00";
                    }
                }
            }
        }
        else
        {
            ctlTotal.innerText = "";
            ctlTotalText.innerText = "";
            for (var i = 0; i < texttosplit.length; i++) 
            {
                var ctlSumm = document.getElementById(texttosplit[i]);
                var dirtyvalue = ctlSumm.innerText;
                var decimalposition = dirtyvalue.indexOf(".");
                var cleanvalue = dirtyvalue.substr(1, decimalposition - 1);
                var numericvalue = parseInt(cleanvalue);

                if (isNaN(numericvalue) == false) 
                {
                    summ = summ + numericvalue;
                    if (ctlTotalText != null) 
                    {
                        ctlTotalText.innerText = "$" + summ + ".00";
                    }
                }
            }
        }
    }
}
/* ProductDetails.ascx functions ends here*/

/*AdditionalGuests*/
    function ShowHide(chk,tbl)
    {
        if(document.getElementById(chk).checked)
        {
            document.getElementById(tbl).style.display = '';
        }
        else
        {
            document.getElementById(tbl).style.display = 'none';
        }
    }
    
    function ClearAll(chk,tbl, dTitle,tFirstName,tLastName,rGenderMale,rGenderFeMale,dDobMonth,dDobYear,dDobDay,tPhone1, tPhone2,tPhone3,tPastGuest,dResidency,dNationality,dTravelCompanion)
    {
        if(document.getElementById(chk).checked)
        {
            document.getElementById(dTitle).selectedIndex = 0;
            document.getElementById(tFirstName).value = "";
            document.getElementById(tLastName).value = "";
            //document.getElementById(rGenderMale).checked = true;
            //document.getElementById(rGenderFeMale).checked = false;
            document.getElementById(dDobMonth).selectedIndex = 0;
            document.getElementById(dDobYear).selectedIndex = 0;
            document.getElementById(dDobDay).selectedIndex = 0;
            document.getElementById(tPhone1).value = "";
            document.getElementById(tPhone2).value = "";
            document.getElementById(tPhone3).value = "";
            document.getElementById(tPastGuest).value = "";
            document.getElementById(dResidency).selectedIndex = 0;
            document.getElementById(dNationality).selectedValue = "US";
            document.getElementById(tbl).style.display = '';
            document.getElementById(dTravelCompanion).selectedIndex = 0;
            document.getElementById(dTravelCompanion).selectedValue = "";
            document.getElementById(tbl).style.display = '';
        }
        else
        {
            document.getElementById(tbl).style.display = 'none';
        }
    }
    
    // Implemented CR on Special Needs - Hemanta [Begin]
    function ShowSpecialneeds(seq)
    {
        var trShow = 'trMore'+seq;
        var trSpecial = 'trSpecialNeed'+seq;
        var Span = 'Span1'+seq;
	    if(document.getElementById(trSpecial).style.display == 'none')
	    {
	        document.getElementById(trSpecial).style.display = '';
	        document.getElementById(Span).innerHTML = '<A href="javascript:ShowSpecialneeds('+seq+');">less</A>';
	    }
	    else
	    {
	        document.getElementById(Span).innerHTML = '<A href="javascript:ShowSpecialneeds('+seq+');">less</A>';
	        document.getElementById(trSpecial).style.display='none';
	    }
    }
    // [End]
    
      
    function Hide(seq)
    {
        var seqTable = 'tbl'+seq;
        var seqChk = 'chk'+seq;
        document.getElementById(seqChk).style.display = 'none';
    }
    function SpecialNeedsModalWindow(){
		var CalledPage="/cms/Static_Templates/SpecialNeeds.aspx?Page="+window.parent.document.title;
		window.showModalDialog(CalledPage, "SpecialNeeds" , "dialogHeight:250px;dialogWidth:500px;resizable:1;status:0;help:0")						
	}
	// Script Externalized from BookEngine.aspx
    function BGPModalWindow(){
		var CalledPage="http://www.carnival.com/cms/Static_Templates/best-price-guarantee.htm?height=600&width=700&TB_iframe";
		tb_show("",CalledPage,null);
	}

   /* FindATravelAgent.aspx - start*/
   
    function SetError()
    {
 		var Error = document.getElementById("lblError");
 		if(Error != null){
			Error.innerText = "";
		}
 	}
 	function validateZipCode(oSrc, args){
		var zip;
		zip = args.Value;	
		args.IsValid = true;				
		if (!isNaN(parseInt(zip))){
			if (zip.length < 3){
				args.IsValid = false;
			}
		}		
	}
	/* FindATravelAgent.aspx - End*/
	
	/*BookGuest.ascx - start*/
	    
  
	
	function TitleValidation(ctl){		
	    var titleValue = ctl.options[ctl.selectedIndex].value;
		var genderFemaleCtl = document.getElementById('Guest_rdoGenderFemale');
		var genderMaleCtl = document.getElementById('Guest_rdoGenderMale');
		var bValid = ((genderFemaleCtl != null) && (genderMaleCtl != null));
		if (bValid){
			    switch (titleValue){  
				    case 'MR' :
					    genderMaleCtl.checked = true;
					    break;
				    case 'MRS' :
					    genderFemaleCtl.checked = true;
					    break;
				    case 'MS' :  
					    genderFemaleCtl.checked = true;
					    break;
				    case 'MISS' :  
					    genderFemaleCtl.checked = true;
					    break;
		        }  
		  }
	}
	
	function CheckCelebration(){
		if(ArrayCheck){
			for(var i = 0 ; i < ArrayCheck.length; i ++){	
				var objService = document.getElementById(ArrayCheck[i]) ;
				var objDate = document.getElementById(ArrayCombo[i]);
				if (objService && objDate){
					if(objService.checked && objDate.selectedIndex ==0){	
						alert("Select the Celebration Date");
						return(false);
					}
				}
			}
		}
		return(true);
	}

    function ValidateTransfer(Code)
    {
    
       var checked = 0;
       
       var ActiveItem = document.activeElement; 
       
       var ActiveItemId = ActiveItem.id;
       
       if(Code.charAt(0) == "X")
       {
          var datalst = document.getElementById(ActiveItemId.substring(0,ActiveItemId.lastIndexOf("_ctl")));
          
          var control;
             
          for(var i=0; i<datalst.rows.length; i++)
          {
            control = document.getElementById(ActiveItemId.substring(0,ActiveItemId.lastIndexOf("_ctl")) + "_ctl0" + i + "_chkPref");  
            
            if(control.checked)
            {
               checked++;
            }
          }
          
          if(checked > 1)
            {
              for(var i=0; i< datalst.rows.length; i++)
               {
                    control = document.getElementById(ActiveItemId.substring(0,ActiveItemId.lastIndexOf("_ctl")) + "_ctl0" + i + "_chkPref"); 
                    control.checked = false;
               } 
                
                ActiveItem.checked = true;
                
            }
        }  
  }
	/*BookGuest.ascx - end*/
	
	/*BookPayment.ascx - start*/
	
    function __validateCheckbox(source, arguments)
    {
        //Changed chkSameAsPresent to chkTerms
        if(document.getElementById('chkTerms').checked)
        {
            arguments.IsValid = true;
        }
        else
        {
            arguments.IsValid = false;
            try {
                s.sendFormEvent('e', s.pageName, 'frmBookEngine', source.errormessage);
            } catch (err) {}
            return;
        }
    }
    function TermsConditionsModalWindow(){
        
		var CalledPage="http://www.carnival.com/CMS/Static_Templates/Reservation_TandC.aspx?Page="+window.parent.document.title;
		//window.showModalDialog(CalledPage, "TermsConditions" , "dialogHeight:450px;dialogWidth:700px;resizable:1;status:0;help:0")						
		
		url = CalledPage + "&KeepThis=true&TB_iframe=true&width=700&height=450";
		tb_show("", url, null);
	}

    function SuperSaverModalWindow()
    {
		    var CalledPage="http://www.carnival.com/cms/fun/earlysaver/default.aspx";
		    //window.showModalDialog(CalledPage, "TermsConditions" , "dialogHeight:450px;dialogWidth:700px;resizable:1;status:0;help:0")						
    		
		    url = CalledPage + "?KeepThis=true&TB_iframe=true&width=700&height=450";
		    tb_show("", url, null);

    }

	/*BookPayment.ascx - end*/
	
	/*ClickToCall.ascx - start*/
	    function PopUpModalwindow()
		{
			var CalledPage;
			CalledPage="ClickToCall.aspx?Page="+window.parent.document.title+ "&From=" + window.parent.document.location.pathname;
			
			window.showModalDialog(CalledPage, "ClickToCall" , "dialogHeight:330px;dialogWidth:456px;help:0;resizable:0;status:0;scroll:0;");
		}
	/*ClickToCall.ascx - end*/
	
	/*PhoneNumberInternational.ascx - start*/
	
	// Code Start, By Pratul Tripathi For CQ# 74509
    //Function modified by VikasJ for CQ 75409; Evening Phone number Validation
    function ApplyValidator(CountryId,CtrlId,CtrlVal1,CtrlVal2,CtrVal3,CtrVal4)
    {
        
         var MaxDigit =4;
        // Changes done by VikasJ for CQ# 75409
        if(CtrVal3 != null)
        {
            if(CtrlId == CtrVal3)
            {
                MaxDigit = 3; 
            }
        }
        
        if(document.getElementById(CountryId).value == "1")
        {
            
           document.getElementById(CtrlVal2).validationexpression = "^[0-9]{" + MaxDigit + "}$"; 
           document.getElementById(CtrVal4).validationexpression = "^[0-9]{3}$";
        }
        else
        {
          document.getElementById(CtrlVal2).validationexpression = "^[0-9]{1," + MaxDigit + "}$"; 
        
        }
       
           std_OnDeactivateControl(CtrlId,CtrlVal1,CtrlVal2);
    }

    //Code Added by VikasJ for CQ 75409

    function ReApplyValidator( id, boolValue )
    {   
            var objEveningPhoneCountryCode = document.getElementById(id + "_txtPhCountryCode");
            var objEveningPhoneAreaCode = document.getElementById(id + "_txtPhAreaCode");
            var objEveningPhoneFirstDigits=document.getElementById( id +"_txtPhFirstDigits");
            var objEveningPhoneLastDigits =document.getElementById( id+"_txtPhLastDigits");
            var objEveningPhoneExtension =document.getElementById(id+"_txtPhExtension");
            
           
            var reqEveningPhoneCountryCode = document.getElementById(id + "_reqPhCountryCode");
            var reqEveningPhoneAreaCode = document.getElementById(id + "_reqPhAreaCode");
            var reqEveningPhoneFirstDigits=document.getElementById( id +"_reqPhFirstDigits");
            var reqEveningPhoneLastDigits =document.getElementById( id+"_reqPhLastDigits");
            
            
            var cvEveningPhoneCountryCode = document.getElementById(id + "_cvPhCountryCode");
            var cvEveningPhoneAreaCode = document.getElementById(id + "_cvPhAreaCode");
            var cvEveningPhoneFirstDigits=document.getElementById( id +"_cvPhFirstDigits");
            var cvEveningPhoneLastDigits =document.getElementById( id+"_cvPhLastDigits");
            var cvEveningPhoneExtension =document.getElementById(id+"_cvPhExtension");
            
            
            if  (   
                   (boolValue == true) ||
                    (
                        objEveningPhoneCountryCode !=null
                        &&
                        objEveningPhoneCountryCode.value !="" 
                     )
                    ||
                    ( 
                        objEveningPhoneAreaCode != null
                        &&
                        objEveningPhoneAreaCode.value != "" 
                    )
                    ||
                    (
                        objEveningPhoneFirstDigits !=null
                        &&
                        objEveningPhoneFirstDigits.value !=""
                    )
                    ||
                    (
                        objEveningPhoneLastDigits !=null
                        &&
                        objEveningPhoneLastDigits.value !=""
                    )
                    ||
                    (
                        objEveningPhoneExtension != null
                        &&
                        objEveningPhoneExtension.value != ""
                    )
                 )
            {
           
                
            var MaxDigit = 4;
            
            if(objEveningPhoneCountryCode != null && objEveningPhoneCountryCode.value == "1")
            {
                
               cvEveningPhoneLastDigits.validationexpression = "^[0-9]{4}$"; 
               cvEveningPhoneAreaCode.validationexpression = "^[0-9]{3}$";
            }
            else
            {
            cvEveningPhoneLastDigits.validationexpression = "^[0-9]{1," + MaxDigit + "}$"; 
            cvEveningPhoneAreaCode.validationexpression = "^[0-9]{1," + MaxDigit + "}$"; 
            }
               
               
           ValidatorEnable(cvEveningPhoneCountryCode, true);
           ValidatorEnable(cvEveningPhoneAreaCode, true);
           ValidatorEnable(cvEveningPhoneFirstDigits, true);
           ValidatorEnable(cvEveningPhoneLastDigits, true);
           ValidatorEnable(cvEveningPhoneExtension, true);
               
               
           ValidatorEnable(reqEveningPhoneCountryCode, true);
           ValidatorEnable(reqEveningPhoneAreaCode, true);
           ValidatorEnable(reqEveningPhoneFirstDigits, true);
           ValidatorEnable(reqEveningPhoneLastDigits, true);
         
           ValidatorValidate(reqEveningPhoneCountryCode);
           ValidatorValidate(reqEveningPhoneAreaCode);
           ValidatorValidate(reqEveningPhoneFirstDigits);
           ValidatorValidate(reqEveningPhoneLastDigits);
           
           ValidatorValidate(cvEveningPhoneCountryCode);
           ValidatorValidate(cvEveningPhoneAreaCode);
           ValidatorValidate(cvEveningPhoneFirstDigits);
           ValidatorValidate(cvEveningPhoneLastDigits);
           ValidatorValidate(cvEveningPhoneExtension);
           
           
           
           
           }
           else if (
                     (boolValue == false) &&
                    (
                        objEveningPhoneCountryCode ==null
                        ||
                        objEveningPhoneCountryCode.value =="" 
                     )
                    &&
                    ( 
                        objEveningPhoneAreaCode == null
                        ||
                        objEveningPhoneAreaCode.value == "" 
                    )
                    &&
                    (
                        objEveningPhoneFirstDigits ==null
                        ||
                        objEveningPhoneFirstDigits.value ==""
                    )
                    &&
                    (
                        objEveningPhoneLastDigits ==null
                        ||
                        objEveningPhoneLastDigits.value ==""
                    )
                    &&
                    (
                        objEveningPhoneExtension == null
                        ||
                        objEveningPhoneExtension.value == ""
                    )
                 )
            {
           
               
           ValidatorEnable(cvEveningPhoneCountryCode, false);
           ValidatorEnable(cvEveningPhoneAreaCode, false);
           ValidatorEnable(cvEveningPhoneFirstDigits, false);
           ValidatorEnable(cvEveningPhoneLastDigits, false);
           ValidatorEnable(cvEveningPhoneExtension, false);
               
               
           ValidatorEnable(reqEveningPhoneCountryCode, false);
           ValidatorEnable(reqEveningPhoneAreaCode, false);
           ValidatorEnable(reqEveningPhoneFirstDigits, false);
           ValidatorEnable(reqEveningPhoneLastDigits, false);
               
           ValidatorValidate(reqEveningPhoneCountryCode);
           ValidatorValidate(reqEveningPhoneAreaCode);
           ValidatorValidate(reqEveningPhoneFirstDigits);
           ValidatorValidate(reqEveningPhoneLastDigits);
           
           
           ValidatorValidate(cvEveningPhoneCountryCode);
           ValidatorValidate(cvEveningPhoneAreaCode);
           ValidatorValidate(cvEveningPhoneFirstDigits);
           ValidatorValidate(cvEveningPhoneLastDigits);
           ValidatorValidate(cvEveningPhoneExtension);
         } 
        
        
           std_OnChangeControl(id + "_txtPhCountryCode",id + "_reqPhCountryCode",id + "_cvPhCountryCode");
           std_OnChangeControl(id + "_txtPhAreaCode",id + "_reqPhAreaCode",id + "_cvPhAreaCode");
           std_OnChangeControl(id +"_txtPhFirstDigits",id +"_reqPhFirstDigits",id +"_cvPhFirstDigits");
           std_OnChangeControl(id+"_txtPhLastDigits",id+"_reqPhLastDigits",id+"_cvPhExtension");
           
           std_OnDeactivateControl(id + "_txtPhCountryCode",id + "_reqPhCountryCode",id + "_cvPhCountryCode");
           ApplyValidator(id + "_txtPhCountryCode",id + "_txtPhAreaCode",id + "_reqPhAreaCode",id + "_cvPhAreaCode",id + "_txtPhAreaCode",id + "_cvPhAreaCode");
           std_OnDeactivateControl(id +"_txtPhFirstDigits",id +"_reqPhFirstDigits",id +"_cvPhFirstDigits");
           ApplyValidator(id + "_txtPhCountryCode",id+"_txtPhLastDigits",id+"_reqPhLastDigits",id+"_cvPhLastDigits",id + "_txtPhAreaCode",id + "_cvPhAreaCode");
                
                
    }




// Code End, By Pratul Tripathi For CQ# 74509


    function EnableDisableInternationalPhone(id,boolValue)
    {
    // Changes done by VikasJ for CQ# 75409
            
            
            var objPhoneCountryCode = document.getElementById(id + "_txtPhCountryCode");
            var objPhoneAreaCode = document.getElementById(id + "_txtPhAreaCode");
            var objPhoneFirstDigits=document.getElementById( id +"_txtPhFirstDigits");
            var objPhoneLastDigits =document.getElementById( id+"_txtPhLastDigits");
            var objPhoneExtension =document.getElementById(id+"_txtPhExtension");
        
            // changes commented for CQ#78262 to show international guest day phone no.[start] 
            //objPhoneCountryCode.value ='';
            //objPhoneAreaCode.value ='';
            //objPhoneFirstDigits.value ='';
            //objPhoneLastDigits.value='' ;
            //objPhoneExtension.value ='' ;
            // changes commented for CQ#78262 to show international guest day phone no.[end] 
                
            var reqPhoneCountryCode = document.getElementById(id + "_reqPhCountryCode");
            var reqPhoneAreaCode = document.getElementById(id + "_reqPhAreaCode");
            var reqPhoneFirstDigits=document.getElementById( id +"_reqPhFirstDigits");
            var reqPhoneLastDigits =document.getElementById( id+"_reqPhLastDigits");
            
            
            var cvPhoneCountryCode = document.getElementById(id + "_cvPhCountryCode");
            var cvPhoneAreaCode = document.getElementById(id + "_cvPhAreaCode");
            var cvPhoneFirstDigits=document.getElementById( id +"_cvPhFirstDigits");
            var cvPhoneLastDigits =document.getElementById( id+"_cvPhLastDigits");
            var cvPhoneExtension =document.getElementById(id+"_cvPhExtension");
            
           ValidatorEnable(cvPhoneCountryCode, boolValue);
           ValidatorEnable(cvPhoneAreaCode, boolValue);
           ValidatorEnable(cvPhoneFirstDigits, boolValue);
           ValidatorEnable(cvPhoneLastDigits, boolValue);
           ValidatorEnable(cvPhoneExtension, boolValue);
               
               
           ValidatorEnable(reqPhoneCountryCode, boolValue);
           ValidatorEnable(reqPhoneAreaCode, boolValue);
           ValidatorEnable(reqPhoneFirstDigits, boolValue);
           ValidatorEnable(reqPhoneLastDigits, boolValue);
 
    }
	//Added by Eswar CQ 99637 
	
	function autoFocus(currentControl, maxLength, nextControl)
    {
        if(document.getElementById(currentControl).value.length >= maxLength)
        document.getElementById(nextControl).focus();
    }
	/*PhoneNumberInternational.ascx - end*/
	
	/*PricingSummary.ascx - start*/
	function modInsurance(sAction, modInsuranceUrl)
	{

	    var i = 0;
	    var bFormFound = false;
	    for (i = 0; i < document.forms.length; i ++){	  			
		    if (document.forms[i].name == "frmEnterPayment"){
			    document.forms[i].insuranceaction.value = sAction;
			    bFormFound = true;
			    break;
		    }			
	    }
	    // The do post back does not work 
	    //if (bFormFound){
	    //	__doPostBack('','');
	    //}else{	
    		
		    window.location.href = modInsuranceUrl;
	    //}
    }
    function PopUpWindow(PageName)
    {
	window.open(PageName,null,"height=250,width=450,status=no,toolbar=no,menubar=no,location=no");
    }
	/*PricingSummary.ascx - end*/


    /* form validation for footer email form */


function MM_validateForm() { //v4.0
 if (document.getElementById){
 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
 for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
 if (val) { nm=val.name; if ((val=val.value)!="") {
 if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
 if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
 } else if (test!='R') { num = parseFloat(val);
 if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
 if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
 min=test.substring(8,p); max=test.substring(p+1);
 if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
 } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
 } if (errors) alert('The following error(s) occurred:\n'+errors);
 document.MM_returnValue = (errors == '');
}
 }

 function isNotEmpty(value)
{
 if (value != null && value.replace(/^\s*|\s*$/g,'').length > 0)
 return true;
 else
 return false;
}