
function confirmYesNo(evt)
{
	var isConfirm = confirm('do you really want to cancel this booking?');
	
	if(!isConfirm)
	{
		evt.returnValue = false;
	}
}

function validateAdults(e,ccholder,ccnumber,adult,adult312,adult02,lblcardno,lblccholder,maxpersons,lblMaxPersons,chkCreditCard,ccvarification)
{
	// this method used in admin side Edit Booking page.
	var adlt=0;
	var adlt312=0;
	var adlt02=0;
	
	if(!isNaN(parseInt(adult.value)))
	{
		adlt =parseInt(adult.value);
	}
	if(!isNaN(parseInt(adult312.value)))
	{
		adlt312 =parseInt(adult312.value);
		if (adlt312==0)
			adlt312.value='';
	}
	if(!isNaN(parseInt(adult02.value)))
	{
		adlt02 =parseInt(adult02.value);
		if (adlt02==0)
			adlt312.value='';
	}
	if((adlt + adlt312) > eval(maxpersons))//(adlt + adlt312 + adlt02)
	{
		lblMaxPersons.style.display = "inline";
		e.returnValue = false;
	}
	else
	{
		lblMaxPersons.style.display = "none";
	}
	if (chkCreditCard.checked == true)
	{
		if (ccnumber.value == "")
		{
			//alert('Enter Credit Card Number');
			lblcardno.style.display = "inline";
			e.returnValue = false;
			
		}else
		{
			var s = ccnumber.value ;
			
			if (!checkCC(s))
			{
				lblcardno.style.display = "inline";
				e.returnValue = false;
			}else
			{
				lblcardno.style.display = "none";
			}
		}
		
		if (ccholder.value == "")
		{
			//alert('Enter Credit Card Holder Name');
			lblccholder.style.display = "inline";
			e.returnValue = false;
			
		}else
		{
			lblccholder.style.display = "none";
		}
	
	}
	else
	{
		ccnumber.value = '';
		ccholder.value = '';
		ccvarification.value = '';
		lblcardno.style.display = "none";
		lblccholder.style.display = "none";
	}
}

function validate(e,adult,adult312,adult02,maxpersons,lblMaxPersons)
{	
// this function directly check values on customer side personal informatin page is directly checki
	var doc = document.forms[0];
	//alert(doc.payart[0].checked);
	var adlt=0;
	var adlt312=0;
	var adlt02=0;
	
	
	if(!isNaN(parseInt(adult.value)))
	{
		adlt =parseInt(adult.value);
	}
	if(!isNaN(parseInt(adult312.value)))
	{
		adlt312 =parseInt(adult312.value);
		if (adlt312==0)
			adlt312.value='';
	}
	if(!isNaN(parseInt(adult02.value)))
	{
		adlt02 =parseInt(adult02.value);
		if (adlt02==0)
			adlt312.value='';
	}
	//alert((adlt + adlt312 + adlt02) > eval(maxpersons));
	//alert(eval(maxpersons));
	if((adlt + adlt312) > eval(maxpersons))//(adlt + adlt312 + adlt02)
	{
//	    alert (lblMaxPersons);
//	    alert (lblMaxPersons.style);
//	    alert(lblMaxPersons.style.display);
//	    
//		alert('The number of persons travelling you have entered is greater than the maximum number of the property ( 8 people over 3 years of age). Please check your entry.');
		lblMaxPersons.style.display = "inline";
		
		e.returnValue = false;
	}
	else
	{
		lblMaxPersons.style.display = "none";
	}
}


//function validate(e, ccholder, ccnumber, adult, adult312, adult02, lblcardno, lblccholder, maxpersons, lblMaxPersons) {
//    // this function directly check values on customer side personal informatin page is directly checki
//    var doc = document.forms[0];
//    //alert(doc.payart[0].checked);
//    var adlt = 0;
//    var adlt312 = 0;
//    var adlt02 = 0;


//    if (!isNaN(parseInt(adult.value))) {
//        adlt = parseInt(adult.value);
//    }
//    if (!isNaN(parseInt(adult312.value))) {
//        adlt312 = parseInt(adult312.value);
//        if (adlt312 == 0)
//            adlt312.value = '';
//    }
//    if (!isNaN(parseInt(adult02.value))) {
//        adlt02 = parseInt(adult02.value);
//        if (adlt02 == 0)
//            adlt312.value = '';
//    }
//    //alert((adlt + adlt312 + adlt02) > eval(maxpersons));
//    //alert(eval(maxpersons));
//    if ((adlt + adlt312) > eval(maxpersons))//(adlt + adlt312 + adlt02)
//    {
//        //alert('The number of persons travelling you have entered is greater than the maximum number of the property ( 8 people over 3 years of age). Please check your entry.');
//        lblMaxPersons.style.display = "inline";
//        //alert(lblMaxPersons.style.display);
//        e.returnValue = false;
//    }
//    else {
//        lblMaxPersons.style.display = "none";
//    }
//    //if (doc.payart[0].checked == true) {
//        if (ccnumber.value == "") {
//            //alert('Enter Credit Card Number');
//            lblcardno.style.display = "inline";
//            e.returnValue = false;

//        } else {
//            var s = ccnumber.value;

//            if (!checkCC(s)) {
//                lblcardno.style.display = "inline";
//                e.returnValue = false;
//            } else {
//                lblcardno.style.display = "none";
//            }
//        }

//        if (ccholder.value == "") {
//            //alert('Enter Credit Card Holder Name');
//            lblccholder.style.display = "inline";
//            e.returnValue = false;

//        } else {
//            lblccholder.style.display = "none";
//        }

//    }
//    else {
//        ccnumber.value = '';
//        lblcardno.style.display = "none";
//        lblccholder.style.display = "none";
//    }
//}
	
/*
<input type=checkbox name="field" value="01"> 
    <input type=checkbox name="field" value="02"> 
    <input type=checkbox name="field" value="03"> 
    <input type=checkbox name="field" value="04"> 
 
<a href="javascript:valCheckBox('field','CHECK BOX');">VALIDATE</a>
*/

function valCheckBox( fieldName, evt,row) { 
    
    //alert('checkbox is ' + fieldName.checked);
    //alert( row.style.display );
    
    
	
    if (fieldName.checked)
    {
		//alert('true');
	}
    else
    {
		//alert('false');
		row.style.display  = "inline";
		//alert( row.style.display );
		evt.returnValue = false;
    }
    //selection  = null; 
    //thisButton = document.forms[0][fieldName]; 
    
   /* for( var i=0; i<thisButton.length; i++ ) { 
        if( thisButton[i].checked ) { 
           selection = thisButton[i].value; 
        } 
        
        if (thisButton.checked == false)
        {
			alert( "Please read and accept the booking conditions before you continue." ); 
			evt.returnValue = false;	
        }
        else
        {
			document.location = 'PersonalInfo.aspx' ;
        }
    } 
    if( selection == null ) { 
        alert( "Please read and accept the booking conditions before you continue." ); 
        evt.returnValue = false;
    } */
} 

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=5) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		index_14Stic_ali = newImage("images/index_14Stic_ali.jpg");
		index_17Stic_ali = newImage("images/index_17Stic_ali.jpg");
		index_19_stic_ali = newImage("images/index_19_stic_ali.jpg");
		index_21Stic_ali = newImage("images/index_21Stic_ali.jpg");
		
		preloadFlag = true;
	}
}
function popUp(URL) {day = new Date();id = day.getTime();eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=799,height=600,left = 0,top = 0');");}

function openPopUp(url, width, height, scrollbar, toolbar, menubar, statusbar, resize) 
{
	if(document.all) {
		Left = (screen.availWidth - width) / 2;
		Top = (screen.availHeight - height) / 2;
	} else {
		Left = (self.outerWidth - width) / 2;
		Top = (self.outerHeight - height) / 2;
	}
	child = window.open(url, self.name + 'ROCAPP_571child', "toolbar=" + toolbar + ",location=0,directories=0,menubar=" + menubar + ",scrollbars=" + scrollbar + ",status=" + statusbar + ",resizable=" + resize + ",width=" + width + ",height=" + height + ",top=" + Top + ",left=" + Left);
}
function openBookedDayPopUp(url,ddlprop,ddltype,txtstart,txtend,e, width, height, scrollbar, toolbar, menubar, statusbar, resize) 
{
	var pid = document.getElementById(ddlprop).options[document.getElementById(ddlprop).selectedIndex].value;
	var type = document.getElementById(ddltype).options[document.getElementById(ddltype).selectedIndex].value;
	var start = document.getElementById(txtstart).value;
	var end = document.getElementById(txtend).value;
	
	if (start!='' && end != '' && start>end)
	{
		alert('Start Date cannot greater than End Date');
		e.returnValue = false;
		return false;
	}
	if(document.all) {
		Left = (screen.availWidth - width) / 2;
		Top = (screen.availHeight - height) / 2;
	} else {
		Left = (self.outerWidth - width) / 2;
		Top = (self.outerHeight - height) / 2;
	}
	
	url = url + '?pid='+pid+'&type='+type+'&sdate='+start+'&edate='+end;
	child = window.open(url, self.name + 'ROCAPP_571child', "toolbar=" + toolbar + ",location=0,directories=0,menubar=" + menubar + ",scrollbars=" + scrollbar + ",status=" + statusbar + ",resizable=" + resize + ",width=" + width + ",height=" + height + ",top=" + Top + ",left=" + Left);
}

function openAvailableDayPopUp(url,ddlprop,ddltype,txtstart,txtend,e, width, height, scrollbar, toolbar, menubar, statusbar, resize) 
{
	var pid = document.getElementById(ddlprop).options[document.getElementById(ddlprop).selectedIndex].value;
	var type = document.getElementById(ddltype).options[document.getElementById(ddltype).selectedIndex].value;
	var start = document.getElementById(txtstart).value;
	var end = document.getElementById(txtend).value;
	
	if (start!='' && end != '' && start>end)
	{
		alert('Start Date cannot greater than End Date');
		e.returnValue = false;
		return false;
	}
	if(document.all) {
		Left = (screen.availWidth - width) / 2;
		Top = (screen.availHeight - height) / 2;
	} else {
		Left = (self.outerWidth - width) / 2;
		Top = (self.outerHeight - height) / 2;
	}
	
	url = url + '?pid='+pid+'&type='+type+'&sdate='+start+'&edate='+end;
	//alert(url);
	child = window.open(url, self.name + 'ROCAPP_571child', "toolbar=" + toolbar + ",location=0,directories=0,menubar=" + menubar + ",scrollbars=" + scrollbar + ",status=" + statusbar + ",resizable=" + resize + ",width=" + width + ",height=" + height + ",top=" + Top + ",left=" + Left);
}


function checkCC(s) {

  var i, n, c, r, t;

  // First, reverse the string and remove any non-numeric characters.

  r = "";
  for (i = 0; i < s.length; i++) {
    c = parseInt(s.charAt(i), 10);
    if (c >= 0 && c <= 9)
      r = c + r;
  }

  // Check for a bad string.

  if (r.length <= 1)
    return false;

  // Now run through each single digit to create a new string. Even digits
  // are multiplied by two, odd digits are left alone.

  t = "";
  for (i = 0; i < r.length; i++) {
    c = parseInt(r.charAt(i), 10);
    if (i % 2 != 0)
      c *= 2;
    t = t + c;
  }

  // Finally, add up all the single digits in this string.

  n = 0;
  for (i = 0; i < t.length; i++) {
    c = parseInt(t.charAt(i), 10);
    n = n + c;
  }

  // If the resulting sum is an even multiple of ten (but not zero), the
  // card number is good.

  if (n != 0 && n % 10 == 0)
    return true;
  else
    return false;
}








