var url = window.location.href;
function StartFloat() {	
if(document.all) {	
	document.all.AdFloater.style.pixelLeft = document.body.clientWidth - document.all.AdFloater.offsetWidth;
	document.all.AdFloater.style.visibility = 'visible';
	Type = 'A';
	}
else if(document.layers) {	
	document.AdFloater.left = window.innerWidth - document.AdFloater.clip.width - 16;
	document.AdFloater.visibility = 'show';
	Type = 'B';
	}
else if(document.getElementById) {	
	document.getElementById('AdFloater').style.left = (window.innerWidth - 0) + 'px';
	document.getElementById('AdFloater').style.visibility = 'visible';
	Type = 'C';
	}
if (document.all) {window.onscroll = Float;
}
else {setInterval('Float()', 100); 
}
}
function Float() {	
if (Type == 'A') {document.getElementById('aqbc').style.top = document.body.scrollTop; }
else if (Type == 'B') { document.AdFloater.top = window.pageYOffset; }
else if (Type == 'C') {document.getElementById('AdFloater').style.top = window.pageYOffset+0+ 'px'; }
}
function quickvalidationheader() {
  var productheader = document.getElementById('product_name');
  var quantityheader = document.getElementById('quantity');
  var productheadervalue = document.getElementById('product_name').value;
  var quantityheadervalue = document.getElementById('quantity').value;
  if (productheadervalue == "Product ID #" || productheadervalue == "") {
    alert("Enter Product id");
    return false;
  }
  if (quantityheadervalue == "") {
    alert("Enter some quantity");
    return false;
  }
  if (quantityheadervalue == "Qty") {
    alert("Please enter numbers for quantity");
    return false;
  }
  if (quantityheadervalue <= 0) {
    alert("Enter some positive quantity number");
    return false;
  }
  if (isNumeric(quantityheader, "Please enter numbers for quantity")) {
    return true;
  }
  return false;
}

function isNumeric(elem, helperMsg) {
  var numericExpression = /^[0-9]+$/;
  if (elem.value.match(numericExpression)) {
    return true;
  } else {
    alert(helperMsg);
    elem.focus();
    return false;
  }
}

function inputValue() {
  if (document.getElementById('searchTxt').value == "") {
    document.getElementById('searchTxt').value = "Search Carnation";
    //document.getElementById('searchTxt').focus();
  }
}

function titleFocus() {
  var headline = document.getElementById('searchTxt').value;
  if (headline == "Search Carnation") {
    document.getElementById('searchTxt').value = "";
    document.getElementById('searchTxt').focus();
    return false;
  } else {
    document.getElementById('searchTxt').focus();
    return true;
  }
}

function inputValuePassword() {
  if (document.getElementById('recoverPasswordHeader').value == "") {
    document.getElementById('recoverPasswordHeader').value = "Username or email";
    //document.getElementById('recoverPasswordHeader').focus();
  }
}

function titleFocusPassword() {
  var headline = document.getElementById('recoverPasswordHeader').value;
  if (headline == "Username or email") {
    document.getElementById('recoverPasswordHeader').value = "";
    document.getElementById('recoverPasswordHeader').focus();
    return false;
  } else {
    document.getElementById('recoverPasswordHeader').focus();
    return true;
  }
}

function quickAdd() {     
  if (url.indexOf("CompareCar") != -1) {
    loadCityName();
    defaultSelect();
    check('rad1');
    loadRecentViewCar();
  } else if (url.indexOf("CompareUsedCar") != -1) {
    loadCityName();
    loadYearName();
    defaultSelect();
    check('rad1');
    loadRecentViewCar();
  } else if (url.indexOf("Certification") != -1) {
    loadCityNameForVVCS();
    defaultSelectForVVCS();
  } else if (url.indexOf("SuccessCertification") != -1) {
    loadCityName();
    defaultSelect();
  } else if (url.indexOf("SuccessValuation") != -1) {
    loadCityName();
    defaultSelect();
  } else if (url.indexOf("Valuation") != -1) {
    loadCityNameForVVCS();
    defaultSelectForVVCS();
  } else if (url.indexOf("QuizPage") != -1) {
    loadCityNameForSell();
  } else if (url.indexOf("SellCar") != -1) {
    loadCityNameForSell();
  } else if (url.indexOf("SellCarCenter") != -1) {
    loadCityNameForSell();
  } else if (url.indexOf("MyCarGarage") != -1 || url.indexOf("tradeinemi") != -1) {
    //StartFloat();
    check('rad1');
    defaultSelect();
  } else if (url.indexOf("UsedCarHome") != -1) {
    check('rad1');
    defaultPocSelect();
  } else if (url.indexOf("/main") != -1) {
    ////StartFloat();
    photoGallery();
    checkHome('rad1');
    defaultPocSelect();
  } else if (url.indexOf("addanewdiscussion") != -1) {
    check('rad1');
    defaultForumSelect();
  } else if (url.indexOf("Home") != -1) {	  
    ////StartFloat();
    check('rad1');
    defaultSearchSelect();
  } else if (url.indexOf("onroadprice") != -1 || url.indexOf("tradeinemicalculation") != -1) {
    //StartFloat();
    defaultSelect();
  } else if (url.indexOf("standardemi") != -1) {
    check('rad1');
    defaultSelect();
    autoPopulate();
  } else if (url.indexOf("testdrive") != -1 || url.indexOf("caralert") != -1) {
    defaultSelect();
    check('rad1');
  } else if (url.indexOf("exchangeyourcar") != -1) {
    check('rad1');
    //StartFloat();
    defaultSelect();
  } else if (url.indexOf("pricingTool") != -1) {
    check('rad1');
    defaultSelect();
  } else if (url.indexOf("tradeinprice") != -1) {
   
    displayloan();
  } else if (url.indexOf("Comparision_Detailsr") != -1) {
    document.getElementById('selectedcar_area1').style.display = '';
    document.getElementById('selectedcar_area2').style.display = '';
    document.getElementById('selectedcar_area3').style.display = '';
    //document.getElementById('selectedcar_area4').style.display='';
    document.getElementById('selectedcar_area5').style.display = '';
    loadComparision();
    showDetails('OverviewPricing');
  } else if (url.indexOf("Comparision_DetailsrUsed") != -1) {
    document.getElementById('selectedcar_area1').style.display = '';
    document.getElementById('selectedcar_area2').style.display = '';
    document.getElementById('selectedcar_area3').style.display = '';
    document.getElementById('selectedcar_area4').style.display = '';
    document.getElementById('selectedcar_area5').style.display = '';
    loadComparision();
    loadYearNameSecondPage();
  } else if (url.indexOf("products") != -1) {
    //StartFloat();
    auto();
    //setProductDetails();
  } else if (url.indexOf("tco?productId") != -1) {
    checkAuto('rad1');
  } else if (url.indexOf("tco") != -1 || url.indexOf("Tco") != -1) {
    defaultSelecttco();
    checktco('rad1');
  } else if (url.indexOf("formForPlacingAdd") != -1) {
    defaultSelecttco();
    checktco('rad1');
  } else if (url.indexOf("createAddPreview") != -1) {
    renderOnLoadCreateAdd();
    loadCityNameTco();
    defaultSelecttco();
  }   
   else if (url.indexOf("verificationInsurance") != -1) {
	   checktco('rad1');
	     defaultSelecttco();
	        //StartFloat();
		 
	  }
	  else if (url.indexOf("verificationrenew") != -1) {
	   checktco('rad1');
	     defaultSelecttco();
	        //StartFloat();
		 
	  }
	  else if (url.indexOf("verification") != -1) {
	   checktco('rad1');
	     defaultSelecttco();
	        //StartFloat();
		 
	  }
	  
 else if (url.indexOf("proposalForm") != -1) {
  
	  defaultSelecttco();
	  checktco('rad1');
	  }
	
 }

function showAddToFav() {   	
	  
	  var y = Get_Cookie("fav");
	   if(y[0]=='y')
		{
			alert("please click on add to my favourite link.");
			Set_Cookie1('fav','',30,'/','','' );
		}
}

function onclickusernam() {
	  var headline = document.getElementById('textfield2').value;
	  if (headline == "Username") {
	    document.getElementById('textfield2').value = "";
	    document.getElementById('textfield2').focus();
	    return false;
	  } else {
	    document.getElementById('textfield2').focus();
	    return true;
	  }
	}

function onblurusernam() {
	  if (document.getElementById('textfield2').value == "") {
	    document.getElementById('textfield2').value = "Username";
	    //document.getElementById('recoverPasswordHeader').focus();
	  }
	}


function onclickpasswor() {
	  var headline = document.getElementById('textfield3').value;
	  if (headline == "Password") {
	    document.getElementById('textfield3').value = "";
	    document.getElementById('textfield3').focus();
	    return false;
	  } else {
	    document.getElementById('textfield3').focus();
	    return true;
	  }
	}

function onblurpasswor() {
	  if (document.getElementById('textfield3').value == "") {
	    document.getElementById('textfield3').value = "Password";
	    //document.getElementById('recoverPasswordHeader').focus();
	  }
	}
	
function stringMakeModelFormat() {
var makeModelList = document.getElementsByTagName('span');
 for (var i = 0; i < makeModelList.length; i++) {
	 var makeModelID = makeModelList[i].id;
   if (makeModelID == 'makemodel') {
       var finalString = makeModelList[i].innerHTML;
       var intIndexOfMatch = finalString.indexOf("_");
		while (intIndexOfMatch != -1){
  		finalString = finalString.replace( "_", " " )
  		intIndexOfMatch = finalString.indexOf( "_" );
}
       makeModelList[i].innerHTML = finalString ;
    
     }
}
}

function retrievepassword()
  {
      var USERNAME=document.getElementById("recoverPasswordHeader").value;
         $.fancybox.showActivity();   
      new Ajax.Request("/control/forgotPassword", {
      method: "get",
      parameters: {
      USERNAME: USERNAME
    },
    onSuccess: function (transport) {
   
      var strdata = transport.responseText.evalJSON(true);
      data=strdata._ERROR_MESSAGE_;
        $.fancybox.hideActivity();    
      if (data==undefined){
      
          //alert("A new password will be e-mailed to you");
          $.fancybox({content : 'A new password will be e-mailed to you',modal : true}); 
      }
      else{ 
    	  data = '<div style="margin-right:30px;">'+data+'</div>';
      	  $.fancybox({content : data,modal : true}); 
      }
      
    }
  });           
            
 }
 function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function checkCookie()
{
var username=getCookie("loginUsername");
var password=getCookie("loginPwd");
var rememberMe=getCookie("loginrememberMe");
if (username!=null && username!="")
  {   
  decryptdata(username,password,rememberMe); 
  }
}
  function showThird(mvcounter)
  {
var i = 0;
  var ctr = "";
    for (i = 0; i< 10 ; i++)
    {//alert("zss");
	    if ( i == parseInt(mvcounter))
	    {
	    ctr='THIRD'+i;
	    //alert(ctr+" show");
	    document.getElementById(ctr).style.display = 'block';
	    }
	    else
	    {
	    ctr='THIRD'+i;
	    //alert(ctr+" hide");
	    document.getElementById(ctr).style.display = 'none';
	    }
    
    }
 // document.getElementById('THIRD').style.display = 'block';
  }
  var classNamee = "";
  var classID = "";
 
   function showThird2()
  {
  //document.getElementById('THIRD2').style.display = 'block';
  }
  function hideThird2()
  {
  //document.getElementById('THIRD2').style.display = 'none';
  }
$(document).ready(function() {
	//NEW CARS TAB//
	
	$("#MOREE").mouseover(function() { 
	    $("#content5").show('slow');
	    $("#content6").show('slow');
	    $("#content7").show('slow');
	    $("#content8").show('slow');
	    $("#content9").show('slow');
	    $("#MOREE").hide();
	 			
	});
	
	$("#content0").mouseover(function() { 
	    $("#THIRD1").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD0").show('medium');
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD9").hide();
				
	});
	$("#content1").mouseover(function() { 
	    $("#THIRD0").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD1").show('medium');
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD9").hide();
				
	});
	$("#content2").mouseover(function() { 
	    $("#THIRD1").hide();
	    $("#THIRD0").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD2").show('medium');
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD9").hide();
				
	});$("#content3").mouseover(function() { 
	    $("#THIRD1").hide();
	    $("#THIRD2").hide();
	    $("#THIRD0").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD3").show('medium');
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD9").hide();
				
	});
	$("#content4").mouseover(function() { 
	    $("#THIRD0").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD1").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD4").show('medium');
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD9").hide();
				
	});
	$("#content5").mouseover(function() { 
	    $("#THIRD1").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD0").hide();
	    $("#THIRD6").hide();
		$("#THIRD5").show('medium');
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD9").hide();
				
	});$("#content6").mouseover(function() { 
	    $("#THIRD1").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD0").hide();
		$("#THIRD6").show('medium');
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD9").hide();
				
	});
	$("#content7").mouseover(function() { 
	    $("#THIRD1").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD7").show('medium');
		$("#THIRD8").hide();
		$("#THIRD0").hide();
		$("#THIRD9").hide();
				
	});
	$("#content8").mouseover(function() { 
	    $("#THIRD1").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD8").show('medium');
		$("#THIRD0").hide();
		$("#THIRD7").hide();
		$("#THIRD9").hide();
				
	});
	$("#content9").mouseover(function() { 
	    $("#THIRD1").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD9").show('medium');
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD0").hide();
				
	});
	
	$("#NEW_CARS").mouseover(function() { 
	    out();
	});
	$("#NEW_CARS").mouseover(function() { 
	    newShow();		
		$("#THIRD1").hide();
	    $("#THIRD2").hide();
	    $("#THIRD3").hide();
	    $("#THIRD4").hide();
	    $("#THIRD5").hide();
	    $("#THIRD6").hide();
		$("#THIRD9").hide();
		$("#THIRD8").hide();
		$("#THIRD7").hide();
		$("#THIRD0").hide();
		
		//$("#CHILD_").show();
		
		var ie = document.all ? true : false;
	 if(ie)
	 {
	     $("#CHILD_").css('height', 275);
	 }
		setBack(this);
	});
	
	
	//NEW CARS TAB//
	//USED CARS TAB//
	$("#USED").mouseover(function() { 
	    usedShow();
	    setBack(this);
	    
		
	});
	$("#USED").mouseout(function() { 
	    out();
	    document.getElementById('CHILD2').style.display="block";
		document.getElementById('CHILDX').style.display="block";
	});
	//USED CARS TAB//
	//INSURANCE TAB//
	$("#INSURANCE").mouseover(function() { 
	   insuShow();
	   $("#submenu1").hide();
	    $("#submenu6").hide();
	    $("#submenu2").hide();
	    $("#submenu4").hide();
	    $("#submenu5").hide();
	    $("#submenu7").hide();
	    $("#submenu3").css('zIndex', 1000);
		$("#submenu3").slideDown('slow');
		setBack(this);
		
	});
	$("#INSURANCE").mouseout(function() { 
	    out();
		document.getElementById('CHILD3').style.display="block";
	});
	
	//INSURANCE TAB//
	
	$("#compareHeader").fancybox({'modal' : 'true','width':1150,'height':800,'type':'iframe','autoScale':'true','scrolling':'yes','padding': 10});
	$("#tcoHeader").fancybox({'modal' : 'true'});
	$("#onroadHeader").fancybox({ 'modal' : 'true'});	
	$("#emiHeader").fancybox({'modal' : 'true'});
	$("#testdriveHeader1").fancybox({'modal' : 'true','width':1014,'height':500,'type':'iframe','autoScale':'false','scrolling':'no'});
	$("#testdriveHeader2").fancybox({'modal' : 'true','width':1014,'height':500,'type':'iframe','autoScale':'false','scrolling':'no'});
	$("#affordHeader").fancybox({'modal' : 'true'});
	$("#sellcarsfancyHeaderMenu").fancybox({'modal' : 'true'});
	$("#contactEmail").fancybox({'modal' : 'true'});
	$("#certifiedcarsfancyHeader").fancybox({'modal' : 'true'});			
	$("#sellcarsfancyHeader").fancybox({'modal' : 'true'});
	$("#CompareUsedCarHeader").fancybox({'modal' : 'true','width':1150,'height':800,'type':'iframe','autoScale':'true','scrolling':'yes','padding': 10});
	$("#buyHeader").fancybox({'modal' : 'true'});
	$("#sellCarHeader").fancybox({'modal' : 'true', 'href':'/control/sell'});
	$(function() {
	 var ie = document.all ? true : false;
	 if(ie)
	 {
	var zIndexNumber = 1000;
	$('div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 1;
	});
	}
}); 
	
});
function out(){
document.getElementById('CHILD3').style.display="none";
//document.getElementById('CHILD1').style.display="none";
document.getElementById('CHILD2').style.display="none";
document.getElementById('CHILDX').style.display="none";
/*document.getElementById('content3').style.display="none";
document.getElementById('content4').style.display="none";
document.getElementById('content5').style.display="none";
document.getElementById('content6').style.display="none";
document.getElementById('content7').style.display="none";
document.getElementById('content8').style.display="none";
document.getElementById('content9').style.display="none";*/

}
function newShow(){
document.getElementById('CHILD3').style.display="none";
//document.getElementById('CHILD1').style.display="block";
document.getElementById('CHILD2').style.display="none";
document.getElementById('CHILDX').style.display="none";

}
function usedShow(){
document.getElementById('CHILD3').style.display="none";
//document.getElementById('CHILD1').style.display="none";
document.getElementById('CHILD2').style.display="block";
document.getElementById('CHILDX').style.display="block";

}
function insuShow(){
document.getElementById('CHILD3').style.display="block";
//document.getElementById('CHILD1').style.display="none";
document.getElementById('CHILD2').style.display="none";
document.getElementById('CHILDX').style.display="none";

}
 function setBack(b)
  {
  if(b.className != 'BACK')
  classNamee = b.className;
  classID = b.id;
  b.className = 'BACK';
  if (classID == 'SUPPORT')
  b.className = 'BACK2';
  }
   function setMore(b)
  {
  b.style.color = "#fff";
  }

function loginAjax()
{
var uName=document.loginform.USERNAME.value;
var pwd=document.loginform.PASSWORD.value;
var remem=document.loginform.rememberMe.checked;
if(pwd.length>16)
{
alert("Invalid username or password");
}
else
{
  new Ajax.Request('/control/loginSlider', {
        asynchronous: false,
        onSuccess: function(transport) {      
            var data = transport.responseText.evalJSON(true);             
              var res = transport.responseText;              
                var errmsg=data._ERROR_MESSAGE_; 
                 var requirePwdChange=data.requirePasswordChange;   
                if(errmsg) 
                {
                document.getElementById('serviceErr').innerHTML="<h3>"+errmsg+"</h3>";
                $.fancybox({'href' : '#serviceErr',modal : true}); 
                }
                else if(requirePwdChange)
                {
                window.location="/control/requirePasswordChange?USERNAME="+uName+"";
                }
                else
                {
                 $.fancybox.showActivity();
                if(remem)
                {
                encrptdata(uName,pwd,remem);
                }
                else
                {
                 location.reload(true);    
                }
                }
        }, parameters: $('#login').serialize()
    });  
}    
}

function encrptdata(uName,pwd,remem)
{
new Ajax.Request("/control/encrptData", {
        method: "post",
        parameters: {
              USERNAME:   uName,
              PASSWORD: pwd
        },
        onSuccess: function (transport) {
         var data = transport.responseText.evalJSON(true);             
              var res = transport.responseText;              
                var funame=data.funame;    
                var fpwd=data.fpwd;    
                if(funame != null && funame != "")
                {
                setCookie("loginUsername",funame,365);
                }
                if(fpwd != null && fpwd != "")
                {
                setCookie("loginPwd",fpwd,365);
                }
                setCookie("loginrememberMe",remem,365); 
                location.reload(true);                
        }
    });
}

function decryptdata(uName,pwd,rememberMe)
{ 
new Ajax.Request("/control/decrptData", {
        method: "post",
        parameters: {
              USERNAME:   uName,
              PASSWORD: pwd
        },
        onSuccess: function (transport) {
         var data = transport.responseText.evalJSON(true);             
              var res = transport.responseText; 
                var funame=data.funame;    
                var fpwd=data.fpwd;    
                if(funame != null && funame != "")
                {
               document.loginform.USERNAME.value=funame;
			  document.loginform.PASSWORD.value=fpwd; 
			  document.loginform.rememberMe.checked=rememberMe;
			  loginAjax();  
                }
        }
    });
}
function logoutAjax()
{
new Ajax.Request("/control/autoLogoutCreatedUser", {
        method: "post",
        parameters: {
                         
        },
        onSuccess: function (transport) {   
        setCookie("loginUsername","",365);
        setCookie("loginPwd","",365);
        setCookie("loginrememberMe",false,365); 
          //window.open(location.href, '_blank');
           //window.close(); 
         location.reload(true);
        }
    });
}
$(function($) { 
        $(".registeropenclose").click( function() {
            if ($("#openCloseIdentifier").is(":hidden")){$("#sliderLogin").animate({marginTop: "-420px"}, 500 );                
                $("#openCloseIdentifier").show();   
                $("#wrapper").unblock();            
            } else {
                $("#sliderLogin").animate({paddingLeft: "120", marginTop: "0", height: "420px"}, 500 );
                $("#openCloseIdentifier").hide();
                $("#wrapper").block({message: null});   
            }
        });  
    });
function checkDOB(elem, helperMsg)
{
var thetime = new Date();
var bookedDate= elem.value;
var ONE_DAY = 1000 * 60 * 60 * 24 * 365;
var thetime_ms = thetime.getTime();
var x=bookedDate.split("-"); 
var dateBooked=new Date(x[2],(x[1]-1),x[0]);
var month1=x[1]-1;
var bookedDate_ms = dateBooked.getTime();
var difference_ms = Math.round(thetime_ms - bookedDate_ms);
var difference=Math.round(difference_ms/ONE_DAY);
if(difference >= 18)
{
    elem.style.backgroundColor="#ffffff";
return true;
}
else
{
alert(helperMsg);
elem.style.backgroundColor="#fde4c6";
return false;
}
}
function isleap(year)
{
 var yr=year;
 if ((parseInt(yr)%4) == 0)
 {
  if (parseInt(yr)%100 == 0)
  {
    if (parseInt(yr)%400 != 0)
    {
    //alert("Not Leap");
    return "false";
    }
    if (parseInt(yr)%400 == 0)
    {
    //alert("Leap");
    return "true";
    }
  }
  if (parseInt(yr)%100 != 0)
  {
    //alert("Leap");
    return "true";
  }
 }
 if ((parseInt(yr)%4) != 0)
 {
    //alert("Not Leap");
    return "false";
 } 
}
