var invalid4 = /[$\\\\#%\^\&\*\!\<\>\?\:\;\"\'\,\>\(/)\[\]\+\{\}\`\~\=\|\[]/;
function emailcharcheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(invalid4) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
   }
}

var invalid3 = /[$\\@\\\#%\^\&\*\!\<\>\?\:\;\"\'\,\.\>\(/)\[\]\+\_\{\}\`\~\=\|\[]/;
function specialcharcheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(invalid3) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
   }
}

var invalid1 = /[$\\@\\\#%\^\&\*\!\<\>\?\:\;\"\'\,\.\>\(/)\[\]\+\_\{\}\`\~\=\|\[^0-9]/;
function charcheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(invalid1) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
   }
}

var invalid2 = /[$\\@\\\#%\^\&\*\!\<\>\?\:\;\"\'\,\>\.\(/)\[\]\+\_\ \{\}\`\~\=\|\[^a-zA-Z]/;
function numcheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(invalid2) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
   }
}

rollimage = new Array();
rollimage[0] = new Image(17,8);
rollimage[0].src = "/images/top_nav_arrow.gif";		
rollimage[1] = new Image(8,8);
rollimage[1].src = "/images/top_nav_arrow_down.gif";
/*rollimage[0] = new Image(17,8);
rollimage[0].src = "/images/top_nav_arrow.gif";			   
rollimage[1] = new Image(17,8);
rollimage[1].src = "/images/top_nav_arrow_down.gif";
rollimage[2] = new Image(17,17);
rollimage[2].src = "/images/scroll_arrow_up.gif";
rollimage[3] = new Image(17,17);
rollimage[3].src = "/images/scroll_arrow_up_on.gif";
rollimage[4] = new Image(17,17);
rollimage[4].src = "/images/scroll_arrow_down.gif";
rollimage[5] = new Image(17,17);
rollimage[5].src = "/images/scroll_arrow_down_on.gif";
rollimage[6] = new Image(8,8);
rollimage[6].src = "/images/build_arrow.gif";
rollimage[7] = new Image(8,8);
rollimage[7].src = "/images/build_arrow_down.gif";
*/
moz = (document.getElementById && !document.all) ? 1 : 0; // Browser detect for scroll detection
var browser = navigator.appName;
if (browser == "Opera") moz = true;

function rollover(id, className, id2, className2) {
	document.getElementById(id).className = className;

	/** Handle the unique nature of the green buttons.*/
	if (id2 != 'null') {
		document.getElementById(id2).className = className2;
	}
	
}

function verifi_login_div()
{
pagesVisitedCount();
adds_random_images();

if(Get_Cookie( 'useremailid' ))
{
document.getElementById("sign_in_div").innerHTML= "<span class=top_nav_text><center>Sign Out</center></span>";
}
else
   {
	document.getElementById("sign_in_div").innerHTML= "<img id=sign_in_arrow src=/images/top_nav_arrow.gif  border=\"0\" height=\"8\" width=\"17\" /><span class=top_nav_text>Sign In</span>";
   }	
}

function swapOut(element, index) {
 /**this is used to change the arrow direction down when we click signin or register.*/
	document.getElementById(element).src = rollimage[index + 1].src;		  
}

function swapBack(element, index) {
/**this is used to change the arrow direction(as it is) right when we click signin or register.*/
	document.getElementById(element).src = rollimage[index].src; 
}

function newregister(newregister)
/**this function is used show in the registration form ,if it is not registerd.*/
{

document.register_form.userid.value=newregister;

}
function userexist(existuser)
/**this function is used to show the userid in signin form if it is existed.*/
{
document.sign_in_form.sign_in_email_input.value=existuser;

}

/**this function will be called when the user clicks signin or register or signout.*/
function toggleTopNavDiv(id, id2, imgId)
 {
 
/**this if condition will be executed when user clicks the signout.*/
if(Get_Cookie( 'useremailid' ) && id == 'sign_in_dropdown_container')
{
user_signout_register('sign_in_dropdown_container');
}/**end of the signout condition.*/

else
{/**this else condition will be executed when user clicks the button signin or regester.(other then signout).*/
	
	if (document.getElementById(id).style.visibility == 'visible')
	 {/**this if condition will be executed when user clicks container(signin or register) is visible*/
		document.getElementById(id).style.visibility = "hidden";
		swapBack(imgId, 0);
		if (id == 'sign_in_dropdown_container') 
		{/**this if condition will be executed when user clicks the signin when it is visible(to close signin form).*/
			rollover('sign_in_div', 'sign_in', 'null', 'null');
		} 
		
		else 
		{/**this else condition will be executed when user clicks the register when it is visible(to close register form).*/
			rollover('register_div', 'register', 'null', 'null');
		}
     }/**this end for if condition for executing when user clicks container(signin or register) is visible.*/
	
	 else 
	 
	 {/**this else condition will be executed when user clicks container(signin or register) when it is hide*/
		
		if (id == 'sign_in_dropdown_container')
		 {/**this if condition will be executed when user clicks signin when it is hide.*/
	   getsigninPage("signin");
		document.getElementById("sign_in_dropdown_container").style.height ="210px";
     	rollover('sign_in_div', 'sign_in_over', 'null', 'null');
			swapBack('register_arrow', 0);
			rollover('register_div', 'register', 'null', 'null');
		 } // end of signin if condition
		 
		else if (Get_Cookie( 'useremailid' ) && id == 'register_dropdown_container')
		{/**this elseif condition will be executed when user clicks the register when he is in login mode.(cookie is set on)*/
		
		if(document.getElementById('existed_register_dropdown_container').style.visibility == 'visible')
		{ /**this if condition is to chech existed_register_dropdown_container hide or visible*/
		document.getElementById('existed_register_dropdown_container').style.visibility = 'hidden';
		swapBack(imgId, 0);
		
		rollover('register_div', 'register', 'null', 'null');
		
		}//end of if
		else
		{/**this existed_register_dropdown_container will denotes the user is already login*/
		
		document.getElementById("existed_register_dropdown_container").innerHTML= "<span class=orange_text_small_bold><center>&nbsp;  You are logged in as "+Get_Cookie( 'useremailid' )+", if you are not "+Get_Cookie( 'useremailid' )+" and would like to register with us </span><a href=\"#\" onmousedown=\"user_signout_register('existed_register_dropdown_container');\"><span class=\"top_nav_text\">click here</span></a>";
	    document.getElementById('existed_register_dropdown_container').style.visibility = 'visible';
		document.getElementById(id2).style.visibility = 'hidden';
		swapOut(imgId, 0);
			rollover('register_div', 'register_over', 'null', 'null');
			rollover('sign_in_div', 'sign_in', 'null', 'null');
		}//end of existed_register_dropdown_container else
		}//endof ifelse
	
	else 
	{/**this block wil be executed when the user clicks the regester button when he is in signout mode.(cookie set off).*/
	
	getsigninPage("register");
	
			rollover('register_div', 'register_over', 'null', 'null');
			swapBack('sign_in_arrow', 0);
			rollover('sign_in_div', 'sign_in', 'null', 'null');
	
	
	}//end of else
	
	}/**this end of else condition for when user clicks container(signin or register) is hide*/
}/**this is end of else condition executed when user clicks the button signin or regest.(other then signout).*/
}/**end of toggleTopNavDiv function*/


function toggleTopNavDiv2(id, id2, imgId)
 {/**this function is called automatically when the user registerd successfully*/

 if (document.getElementById(id).style.visibility == 'visible') {
	 
		document.getElementById(id).style.visibility = "hidden";
		swapBack(imgId, 0);
		if (id == 'register_success_dropdown_container') 
		{
		
			rollover('register_div', 'register', 'null', 'null');
		}
	} else {
		
		document.getElementById(id).style.visibility = 'visible';
		document.getElementById(id2).style.visibility = 'hidden';
		swapOut(imgId, 0);
		if (id == 'register_success_dropdown_container') {
		
			rollover('register_div', 'register_over', 'null', 'null');
			swapBack('sign_in_arrow', 0);
			rollover('sign_in_div', 'sign_in', 'null', 'null');
		document.getElementById("sign_in_div").innerHTML= "<span class=orange_text_small_bold><center>Signing In..</center></span>";
		 setTimeout("toggleTopNavDiv2('register_success_dropdown_container', 'sign_in_dropdown_container', 'register_arrow');",2400);
	 setTimeout('signin("home");',2500);
		} 
	}
}/**end of toggleTopNavDiv2 function*/


function signin(sign_type)
{/**this function will be called when the user is signined successfully*/
document.getElementById("sign_in_div").innerHTML= "<span class=top_nav_text><center>Sign Out</center></span>";
rollover('sign_in_div', 'sign_in', 'null', 'null');
if(sign_type=="home")
{
if ( Get_Cookie( 'useremailid' ) ) 
{
 if ( Get_Cookie( 'i_agree_terms_Conditions' )==0 ) 
 window.location = "/pages/agree_terms_and_conditions.jsp?requestURI=/registered-pages/my_profile.jsp";
 else
 window.location = "/";
}else if ( Get_Cookie( 'manageremailid' ) ) 
window.location = "/admin/admin_index.html";
}
else 
{
if ( Get_Cookie( 'useremailid' ) ) 
{
 if ( Get_Cookie( 'i_agree_terms_Conditions' )==0 ) 
 window.location = "/pages/agree_terms_and_conditions.jsp?requestURI=/registered-pages/my_profile.jsp";
 else
 window.location = "/";
}
else if ( Get_Cookie( 'manageremailid' ) ) 
window.location = "/admin/admin_index.html";

}
}/**end of signin function*/

function user_signout_register(id)
{/**this function will be called when the user is signout successfully*/
registered_user_signOut(id);

}/**end of user_signout_register function*/


function user_signout_register_delete_cookies(id)
{
if ( Get_Cookie( 'managerid' ) ) 
Delete_Cookie('managerid', '/', '');
Delete_Cookie('useremailid', '/', '');
Delete_Cookie('userfname', '/', '');
Delete_Cookie('userlname', '/', '');
Delete_Cookie('user_db_id', '/', '');
document.getElementById("sign_in_div").innerHTML= "<img id=sign_in_arrow src=/images/top_nav_arrow.gif  border=\"0\" height=\"8\" width=\"17\" /><span class=top_nav_text>Sign In</span>";
document.getElementById('existed_register_dropdown_container').style.visibility = 'hidden';
		rollover('register_div', 'register', 'null', 'null');
		swapBack('register_arrow', 0);
	if(id == 'existed_register_dropdown_container')
	{	
Set_Cookie( 'register_expand', 'visible', '', '/', '', '' );
   }
   window.location = "/";
}

function checkDivStatus(divId, id1, className, id2, className2) {
var cookie=Get_Cookie( 'userfname');
if( document.getElementById('existed_register_dropdown_container').style.visibility == 'hidden' && document.getElementById(divId).style.visibility == 'hidden')
{
	rollover(id1, className, id2, className2);
}
else if( document.getElementById('existed_register_dropdown_container').style.visibility == 'visible' && document.getElementById(divId).style.visibility == 'hidden' && id1=='sign_in_div')
{
rollover(id1, className, id2, className2);
}
}

// Create top portion of popup div. Have to declare the png inline for transparancy to work in IE6.
function createPopup(id, width, height, top, title) {
  document.getElementById(id).style.left = parseInt((840 - width) / 2) + 'px';
  document.getElementById(id).style.top = winOfy() + top + 'px';
  document.getElementById(id).style.width = width + 'px';

  if (moz) {

    document.write('<div id="popup_left" style="background-image: url(/images/rounded_left.png);"></div><div id="popup_right" style="background-image: url(/images/rounded_right.png);width:' + (width - 18) + 'px;"><span class="white_title_text">' + title + '</span></div><div id="clear"></div><div id="popup_body" style="height:' + (height - 41) + 'px;width:' + (width - 4) + 'px;"><div id="error_display" style="width:' + (width - 4) + 'px;height:' + (height - 32) + 'px;">');
          } else if (navigator.appName=="Microsoft Internet Explorer")
 			{
  				
  				version = parseFloat(navigator.appVersion.split("MSIE")[1]);
  			if (version < 7)  {
               document.write('<div id="popup_left" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + "'/images/rounded_left.png',sizingMethod='scale');" + '"></div><div id="popup_right" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + "'/images/rounded_right.png',sizingMethod='scale');" + 'width:' + (width - 18) + 'px;"><span class="white_title_text">' + title + '</span></div><div id="clear"></div><div id="popup_body" style="height:' + (height - 51) + 'px;width:' + (width - 36) + 'px;"><div id="error_display" style="width:' + (width - 36) + 'px;height:' + (height - 52) + 'px;">'); 
               }
               else{
               document.write('<div id="popup_left" style="background-image: url(/images/rounded_left.png);"></div><div id="popup_right" style="background-image: url(/images/rounded_right.png);width:' + (width - 18) + 'px;"><span class="white_title_text">' + title + '</span></div><div id="clear"></div><div id="popup_body" style="height:' + (height - 41) + 'px;width:' + (width - 4) + 'px;"><div id="error_display" style="width:' + (width - 4) + 'px;height:' + (height - 32) + 'px;">');
               }
           }   
}

function winOfy(){
 //alert("winOfy");
   return (moz) ? window.pageYOffset : document.body.scrollTop;
}

function displayError(formNode, validators) {
       document.getElementById("error_display").innerHTML="";
	for (var i=0;i<validators.length;i++) {
		document.getElementById("error_display").innerHTML += "<img id=sign_in_arrow src=/images/top_nav_arrow.gif  border=\"0\" height=\"8\" width=\"17\" />";
		document.getElementById("error_display").innerHTML += validators[i].message + '<br />';
	}
	
	document.getElementById("popup1").style.visibility = 'visible';
	
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
	
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {

if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 25-aug-2007 00:00:01 GMT";
}

function close_div()
	{
	window.location.reload(false);
	//document.getElementById("faq_dropdown_container").style.visibility = "hidden";
	}

	
	function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

//this function is to display signin or signout in customer care pages. 

function  verifi_login_div_customer()
			{

				if(Get_Cookie( 'useremailid' ))
				{
				document.getElementById("sign_in_div").innerHTML= "<span class=top_nav_text><center>Sign Out</center></span>";
				}
				else if(Get_Cookie( 'customerCare' ))
				{
				document.getElementById("sign_in_div").innerHTML= "<span class=top_nav_text><center>Sign Out</center></span>";
				}
				else
				   {
					document.getElementById("sign_in_div").innerHTML= "<img id=sign_in_arrow src=/images/top_nav_arrow.gif  border=\"0\" height=\"8\" width=\"17\" /><span class=top_nav_text>Sign In</span>";
				   }	
			}
			
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){		   
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){		    
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){		    
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){		    
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){		    
		    return false
		 }
		
 		return true 					
	}
	
/**
 * DHTML phone number validation script.
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";

var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
   
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

       function open_terms_and_conditions(page)
	    {
	    window.open(""+page+"","Window1","left=70,top=40,menubar=no,width=838,height=605,toolbar=no,scrollbars=yes,resizable=yes,status=yes");
	    }

//GetXmlHttpObject() this function is used to get XmlHttpObject
//this function is called in every ajax functions in TravelMarg to get XmlHttpObject
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

//this getsigninPage(page_type) function is used for signin and register in all pages
var xmlHttp;

function getsigninPage(page_type)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
 // alert("ajaxblock");
 if(page_type=="signin")
 {
var url="/pages/signin.html";
xmlHttp.onreadystatechange=getsigninPage_stateChanged;
dhtmlLoadScript("/js/reset_password.js");
dhtmlLoadScript("/js/signInUser.js");
}
else if(page_type=="register")
{
//alert("register block");
var url="/pages/register.html";
dhtmlLoadScript("/js/user_register.js");
xmlHttp.onreadystatechange=getregisterPage_stateChanged;
}

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function getsigninPage_stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
var res=xmlHttp.responseText;
//alert("response:"+res);
document.getElementById("sign_in_dropdown_container").innerHTML=res;
	//document.getElementById("sign_in_dropdown_container").style.height ="210px";
/**signin  validation errors ids.*/
document.getElementById("SignIn_EmailError").style.display = "none";
document.getElementById("SignIn_PasswordError").style.display = "none";
document.getElementById("SignIn_reset_password_response").style.display = "none";
/**signin form  fields.*/
document.sign_in_form.sign_in_email_input.value="";
document.sign_in_form.sign_in_password_input.value="";
		
document.getElementById("sign_in_dropdown_container").style.visibility = 'visible';
document.getElementById("register_dropdown_container").style.visibility = 'hidden';
		swapOut("sign_in_arrow", 0);
}
}

function getregisterPage_stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
var res=xmlHttp.responseText;
document.getElementById("register_dropdown_container").innerHTML=res;

 document.getElementById("register_dropdown_container").style.height ="265px";
/**register validation errors ids.*/
document.getElementById("reg_emailError").style.display = "none";
document.getElementById("reg_user_response").style.display = "none";
document.getElementById("reg_pwdError").style.display = "none";
document.getElementById("reg_cpwdError").style.display = "none";

/**regester form fields.*/
document.register_form.userid.value="";
document.register_form.fname.value="";
document.register_form.mname.value="";
document.register_form.lname.value="";
document.register_form.password.value="";
document.register_form.cpassword.value="";

//alert( "userid cookie have been set:"+Get_Cookie('useremailid'));

document.getElementById("sign_in_dropdown_container").style.visibility = 'hidden';
document.getElementById("register_dropdown_container").style.visibility = 'visible';
swapOut("register_arrow", 0);
}
}
// end of getsigninPage(page_type)

function update_current_time()
{
//setInterval('blinkIt()',500)
//alert("2");
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
 // alert("ajaxblock");
var myDate = new Date(); 
var time=myDate.getTime();
var url="/pages/get_current_time.jsp";
    url+="?time="+time;
xmlHttp.onreadystatechange=update_current_time_stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function update_current_time_stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
var res=xmlHttp.responseText;
if(document.getElementById("current_time_display")!= null)
{
document.getElementById("current_time_display").innerHTML=res;
}
if(document.getElementById("time_display_in_call_me_back")!= null)
{
document.getElementById("time_display_in_call_me_back").innerHTML=res;
}
setTimeout('update_current_time()',60000); 
}
}
//this  registered_user_signOut(id) is used for sign out for all pages

function registered_user_signOut(id)
{ 
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

var url="/pages/ValidateUser?registered_user=yes";


xmlHttp.onreadystatechange=signout_stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

function signout_stateChanged() 
{ 

if (xmlHttp.readyState==4)
{

user_signout_register_delete_cookies(id)
}
}

}
//end of registered_user_signOut(id)




//this dhtmlLoadScript(url) function is used for dynamically load js
function dhtmlLoadScript(url)
{ 
var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
   //alert('js created');
}
//end dhtmlLoadScript(url) function 
function dhtmlLoadCssStyle(url)
{ //alert(url);
var e = document.createElement("style");
   e.src = url;
   e.type="text/css";
   document.getElementsByTagName("head")[0].appendChild(e);
}




//this validate_email(field,field_name) function is used for email validation
 function validate_email(field,field_name)
{

apos=field.indexOf("@")
dotpos=field.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {
 
if(field_name=="subscription_email")
{
document.getElementById("subscription_email_message").innerHTML= "Please enter a valid E-Mail in the format xx@yy.zz.";
document.getElementById("subscription_email_message").style.display = "inline";
flag=1;

 return false;
}

  }
}
//end of validate_email(field,field_name)




var xmlHttpPages;

function getPage(page_type,hotelName,hotelId,price,noofnights)
{ 
//alert("getPage called");
	xmlHttpPages=GetXmlHttpObject();
	if (xmlHttpPages==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
 			// alert("ajaxblock");
 	if (navigator.appName=="Microsoft Internet Explorer")
 			{
  				document.getElementById("blockUI_footer").style.height = (document.body.scrollHeight)+10+'px';
  				version = parseFloat(navigator.appVersion.split("MSIE")[1]);
  				if (version < 7) {
  				if(document.getElementById("city2")){
  						document.getElementById("city2").style.visibility = "hidden";
  						}
  					if(document.getElementById("select_city")){
  						document.getElementById("select_city").style.visibility = "hidden";
  					}
  					if(document.getElementById("package_period")){
  						document.getElementById("package_period").style.visibility = "hidden";
  					}
  					if(document.getElementById("adult_input")){
  						document.getElementById("adult_input").style.visibility = "hidden";
  					}
  					if(document.getElementById("child_input")){
  						document.getElementById("child_input").style.visibility = "hidden";
  					}
  					if(document.getElementById("infant_input")){
  						document.getElementById("infant_input").style.visibility = "hidden";
  					}
  					if(document.getElementById("package_category")){
  						document.getElementById("package_category").style.visibility = "hidden";
  					}
  					if(document.getElementById("select_city")){
  						document.getElementById("select_city").style.visibility = "hidden";
  					}
  					if(document.getElementById("package_budget")){
  						document.getElementById("package_budget").style.visibility = "hidden";
  					}
  					if(document.getElementById("package_no_of_nights")){
  						document.getElementById("package_no_of_nights").style.visibility = "hidden";
  					}
  					if(document.getElementById("package_period")){
  						document.getElementById("package_period").style.visibility = "hidden";
  					}
  				
  					}
 			}
 			else {
 				document.getElementById("blockUI_footer").style.height = document.height+10+'px';
 			}
 	document.getElementById("blockUI_footer").style.display="inline";
 			
  if(page_type=="EmailLink")
		{
			//alert("inside EmailLink");
			
			
				var url="/pages/emailFriendLink.jsp";
				xmlHttpPages.open("POST",url,true);	
				xmlHttpPages.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
				xmlHttpPages.onreadystatechange=getEmailLinkPage_stateChanged;
				xmlHttpPages.send("page_url=" + encodeURI(hotelName) + "&pkgIdParam=" + encodeURI(hotelId));
		
				document.getElementById("link_email").style.display="inline";
			
			
		}
	else if(page_type=="ContactUs")
		{

			//alert("inside ContactUs:"+page_type);

			dhtmlLoadScript("/js/contactUs.js");
			//alert("b4");
				var url="/pages/contact_us.html";
				
				xmlHttpPages.open("POST",url,true);	
				xmlHttpPages.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
				
				xmlHttpPages.onreadystatechange=getContactUsPage_stateChanged;
				xmlHttpPages.send(null);
				
				
				document.getElementById("link_email_footer").style.display="inline";
				//alert("a4");
			
		}
else if(page_type=="SubmitRequest")
		{
			//alert("SubmitRequest:"+page_type);
			
			dhtmlLoadScript("/js/submitRequest.js");
				var url="/pages/submit_request.html";
				xmlHttpPages.open("POST",url,true);	
				xmlHttpPages.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
				xmlHttpPages.onreadystatechange=getContactUsPage_stateChanged;
				xmlHttpPages.send(null);
				
				
				document.getElementById("link_email_footer").style.display="inline";
				
			
		}
}

function getEmailLinkPage_stateChanged() 
{ 
	if (xmlHttpPages.readyState==4){
		if(xmlHttpPages.status == 200) { 
			//alert("inside stateChanged");
		document.getElementById("link_email").innerHTML=xmlHttpPages.responseText;
		document.getElementById("send_emaillink_your_emailError").style.display = "none";
		document.getElementById("send_emaillink_friend_emailError").style.display = "none";		
		document.getElementById("sendInfoStatusBar").style.display = "none";
		document.getElementById("messageEmailLink").style.display = "none";	
		document.getElementById("friend_name").focus();	
		
	}
	else {
        alert("Error during AJAX call. Please try again");
        
     }
	}// xmlHttpPages.readyState ---if
}

function getContactUsPage_stateChanged() 
{    
	if (xmlHttpPages.readyState==4){
		if(xmlHttpPages.status == 200) { 
			//alert("inside ContactUs stateChanged");
		document.getElementById("link_email_footer").innerHTML=xmlHttpPages.responseText;
		if(document.getElementById("customerName1")){
			document.getElementById("customerName1").focus();
		}
		
  		if(document.getElementById("tableDiv1")){
			document.getElementById("tableDiv1").style.display="inline";
		}
		if(document.getElementById("sendInfoStatusBar_footer")){
			document.getElementById("sendInfoStatusBar_footer").style.display="none";
		}
		if(document.getElementById("messageEmailLink_footer")){
			document.getElementById("messageEmailLink_footer").style.display="none";
		}
		if(document.getElementById("messageEmailLink")){
			document.getElementById("messageEmailLink").style.display="none";
		}
		if(document.getElementById("customerName1")){
			document.getElementById("customerName1").focus();
		}
	} else {
        alert("Error during AJAX call. Please try again");
        
     }
	}// xmlHttpPages.readyState ---if
}


function hidePage(id){
				if(document.getElementById("calendar_container")){
  						document.getElementById("calendar_container").style.visibility = "hidden";
  					}
				document.getElementById(id).style.display="none"
				document.getElementById(id).innerHTML="";
				document.getElementById("blockUI_footer").style.display="none";
				version = parseFloat(navigator.appVersion.split("MSIE")[1]);
  				if (version < 7) {
  					if(document.getElementById("city2")){
  						document.getElementById("city2").style.visibility = "visible";
  					}
  					if(document.getElementById("select_city")){
  						document.getElementById("select_city").style.visibility = "visible";
  					}
  					if(document.getElementById("package_period")){
  						document.getElementById("package_period").style.visibility = "visible";
  					}
  					if(document.getElementById("adult_input")){
  						document.getElementById("adult_input").style.visibility = "visible";
  					}
  					if(document.getElementById("child_input")){
  						document.getElementById("child_input").style.visibility = "visible";
  					}
  					if(document.getElementById("infant_input")){
  						document.getElementById("infant_input").style.visibility = "visible";
  					}
  					if(document.getElementById("package_category")){
  						document.getElementById("package_category").style.visibility = "visible";
  					}
  					if(document.getElementById("select_city")){
  						document.getElementById("select_city").style.visibility = "visible";
  					}
  					if(document.getElementById("package_budget")){
  						document.getElementById("package_budget").style.visibility = "visible";
  					}
  					if(document.getElementById("package_no_of_nights")){
  						document.getElementById("package_no_of_nights").style.visibility = "visible";
  					}
  					if(document.getElementById("package_period")){
  						document.getElementById("package_period").style.visibility = "visible";
  					}
  				}
	
}

function validateValues(nameFieldId,emailFieldId)
{

var name="";
var email="";

if(nameFieldId != null)
name = document.getElementById(nameFieldId).value;
if(emailFieldId != null)
email = document.getElementById(emailFieldId).value;
if(name == "" )
	{
	alert("Error:Please enter Your name");
		       document.getElementById(nameFieldId).select();
		       document.getElementById(nameFieldId).focus();
		       return false;		     
}
var at="@";
    		 var dot=".";
     		 var str=email;
     		 var lat=str.indexOf(at);
     		 var lstr=str.length;
     		 var ldot=str.indexOf(dot);
		     if(str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr || str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr || str.indexOf(at,(lat+1)) != -1 || str.substring(lat-1,lat) == dot || str.substring(lat+1,lat+2) == dot || str.indexOf(dot,(lat+2)) == -1 || str.indexOf(" ") != -1)
			 {
			 	alert("Error:Please enter valid email id");
			 	document.getElementById(emailFieldId).select();
			 	document.getElementById(emailFieldId).focus();
			 	return false;
	        
			 }
			 else
			 {
        			return true;
        		
			 }
}

function adds_page()
{
window.location="/best-deals-on-goa.html";
}
function adds_redirect(url)
{
window.location=''+url+'';
}

function srilanka_best_deals()
{
window.location="/leonia-resort-hyderabad.html";
}

function adds_random_images()
{
//var keywords = ["travelmarg_ads_goa&/best-deals-on-goa.html","travelmarg_ads_kerala&/kerala-tour-packages.html","travelmarg_ads_new_year&/new-year-package-at-leonia.jsp"]
//var keywords = ["travelmarg_ads_goa&/best-deals-on-goa.html","travelmarg_ads_kerala&/kerala-tour-packages.html","travelmarg_ads_new_year&/dubai-shopping-festival-package.html"]
var keywords = ["travelmarg_ads_kerala&/kerala-tour-packages.html","travelmarg_ads_new_year&/europe","travelmarg_ads_goa&/best-deals-on-goa.html"]
var keyword = keywords[Math.floor(Math.random()*keywords.length)];

var split_array=keyword.split("&");
var className=split_array[0];
var urlRedirect=split_array[1];

document.getElementById("travelmarg_adds_1").className = ''+className+'';
document.getElementById("travelmarg_adds_1").onclick = function() {adds_redirect(urlRedirect);}
adds_random_images2();
}

function adds_random_images2()
{
//var keywords = ["travelmarg_ads_srilanka&/leonia-resort-hyderabad.html","travelmarg_ads_cruise&/cruises/star-cruises.html","india_cruise_add&/cruises/louis-cruises-in-india.jsp"]
//var keywords = ["travelmarg_ads_srilanka&/leonia-resort-hyderabad.html","india_cruise_add&/cruises/louis-cruises-in-india.jsp"]
var keywords = ["travelmarg_ads_srilanka&/leonia-resort-hyderabad.html","india_cruise_add&/cruises/star-cruises.jsp","international_add&/jalsa-beach-hotel-and-spa","travelmarg_ads_cruise&/kailash-and-mansarovar-yatra"]
var keyword = keywords[Math.floor(Math.random()*keywords.length)];

var split_array=keyword.split("&");
var className=split_array[0];
var urlRedirect=split_array[1];

document.getElementById("travelmarg_adds_2").className = ''+className+'';
document.getElementById("travelmarg_adds_2").onclick = function() {adds_redirect(urlRedirect);}
}

// Included by prathiba
function callMeBackDiv(package_id)
{


document.getElementById("blockUI_footer").style.height = (document.body.scrollHeight)+10+'px';
document.getElementById("blockUI_footer").style.display="inline";
xmlHttp=GetXmlHttpObject();
var url="/call-me-back.jsp?package_id="+package_id+"";
document.getElementById("popupDiv").style.height = "200px";
document.getElementById("popupDiv").style.width = "620px";
document.getElementById("popupDiv").style.marginLeft="250px";
document.getElementById("popupDiv").style.marginTop="200px";
xmlHttp.onreadystatechange=pageToLoad;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function pageToLoad() 
{
if (xmlHttp.readyState==4)
{ 
var res=xmlHttp.responseText;
document.getElementById("popupDiv").innerHTML=res;
document.getElementById("requestSentUrl").value = location.href;
//alert(document.getElementById("requestSentUrl").value);
document.getElementById("popupDiv").style.display = "inline";
update_current_time();

}

}
var xmlHttp;
function formSubmission()
{
flag = false;
var name = document.getElementById('cust_name').value;
var mobile = document.getElementById('cust_mobile').value;

name = name.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
mobile = mobile.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');


document.getElementById("nameError").style.display="none";
document.getElementById("mobileError").style.display="none";
var requestSentUrl = document.getElementById("requestSentUrl").value;
var packageId = document.getElementById("package_id").value;
if(name==null || name=="" || name=="null" || name==" ")
{
document.getElementById("nameError").style.display="inline";
document.getElementById('nameError').innerHTML = 'Please enter your name';
return false;
}
else if (mobile==null || mobile=="" || mobile=="null" || mobile==" ")
{
document.getElementById("mobileError").style.display="inline";
document.getElementById('mobileError').innerHTML = 'Please enter your phone number';
return false;
}
else{
xmlHttp=GetXmlHttpObject();
document.getElementById("sendLink").innerHTML = ""+
							"<div id='search_flights' class='search_flights'  >"+
								"<div id='green_outside_inner' class='green_button_outside' >"+

									"<div id='green_inside_inner' class='green_button_inside' style='margin-right:2px;'    >"+
										"<span class='white_text_bold'>SENDING</span>"+
									"</div>"+
								"</div>"+
							"</div>"+
						"";


//alert("city: "+encodeURI( document.getElementById("pkgCity").value));
  if(xmlHttp) { 
  var is_international_package=0;
     
     if(document.getElementById("is_international_package"))
      is_international_package=document.getElementById("is_international_package").value;
  
   document.getElementById("call_me_back_progress").style.display = "inline";
	document.getElementById("call_me_back_progress").innerHTML='<img src="/images/travelmargProgress.gif" style="vertical-align:middle;height:25px;">&nbsp;&nbsp;Sending information to TravelMarg...<br/>&nbsp;'; 
	    xmlHttp.open("POST","/CallMeBack",true); // the servlet name
    xmlHttp.onreadystatechange  = handleResp;
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.send("customerName=" + name + "&customerMobile=" +mobile +"&requestSentUrl="+requestSentUrl+"&is_international_package="+is_international_package+"&package_id="+packageId); //Posting parameters to Servlet
  
  }  	


}
}

function handleResp() {
	//alert("entered ServerResponse3");
   if (xmlHttp.readyState == 4) {
     if(xmlHttp.status == 200) {	
     	//alert("entered ServerResponse4");
     	document.getElementById("tableDiv").style.display = "none";
     	document.getElementById("call_me_back_progress").style.display = "none";     	
     	document.getElementById("message").style.display = "inline";
     	
        document.getElementById('message').innerHTML=xmlHttp.responseText; //Update the HTML Form element 
       //alert(document.getElementById('message').innerHTML);
       	document.getElementById("sendLink").innerHTML = "<a  name='send' id='send' onMouseOver = 'rollover('green_outside_inner', 'dark_green_button_outside', 'green_inside_inner', 'dark_green_button_inside');' onMouseOut = 'rollover('green_outside_inner', 'green_button_outside', 'green_inside_inner', 'green_button_inside');' onClick='return ValidateForm();'>"+
							"<div id='search_flights' class='search_flights'  >"+
								"<div id='green_outside_inner' class='green_button_outside' >"+

									"<div id='green_inside_inner' class='green_button_inside'  >"+
										"<span class='white_text_bold'>SEND</span>"+
									"</div>"+
								"</div>"+
							"</div>"+
						"</a>";
     }
     else {
        //alert("Error during AJAX call. Please try again");
        
     } 
   }
}


function hideDiv(id){
	if(document.getElementById("calendar_container")){
  						document.getElementById("calendar_container").style.visibility = "hidden";
  					}
				document.getElementById(id).style.display="none";				
				document.getElementById("blockUI_footer").style.display="none";
				version = parseFloat(navigator.appVersion.split("MSIE")[1]);
  				if (version < 7) {
  					if(document.getElementById("city2")){
  						document.getElementById("city2").style.visibility = "visible";
  					}
  				}  						
}
function funncall(noteToDisplay)
{
alert(noteToDisplay);
}
var xmlHttp;
function pagesVisitedCount()
{
var pagesVisited;
		if ( Get_Cookie( 'pages_visited' ) ) 
		{
			 pagesVisited=Get_Cookie( 'pages_visited' );
			 
			 // alert('pagesVisited first : '+pagesVisited);
			 if(pagesVisited!=0)
			 pagesVisited++;
			 //alert('pagesVisited222: '+pagesVisited);
			 Set_Cookie( 'pages_visited', pagesVisited, '', '/', '', '' );
			// alert("If  :"+Get_Cookie( 'pages_visited' ));
			 if(pagesVisited==20)
			 {
			 //alert('ifffffff: '+pagesVisited);
			 createDiv();
			 pagesVisited=0;
			    Set_Cookie( 'pages_visited', pagesVisited, '', '/', '', '' );
				document.getElementById("blockUI_footer").style.height = (document.body.scrollHeight)+10+'px';
		  		document.getElementById("blockUI_footer").style.display="inline";
		  		xmlHttp=GetXmlHttpObject();
		  		dhtmlLoadScript("/js/customerneedmore.js");
				var url="/what-you-are-looking-for.jsp";
				document.getElementById("lookingForMoreDiv").style.zIndex = "2000";
				document.getElementById("lookingForMoreDiv").style.height = "410px";
				document.getElementById("lookingForMoreDiv").style.width = "400px";
				document.getElementById("lookingForMoreDiv").style.marginLeft="30%";
			 	xmlHttp.onreadystatechange=getPage_toLoad_LookingForMore;
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null);
			}
			//else
			//alert("else  "+pagesVisited);
		 //alert("If  "+pagesVisited);
		}
		else
		{
		Set_Cookie( 'pages_visited', '1', '', '/', '', '' );
		//pagesVisited=Get_Cookie( 'pages_visited' );
		//alert("Else  "+pagesVisited);
		}
}
function getPage_toLoad_LookingForMore() 
{
	if (xmlHttp.readyState==4)
	{ 
	var res=xmlHttp.responseText;
	document.getElementById("lookingForMoreDiv").innerHTML=res;
	
	document.getElementById("lookingForMoreDiv").style.display = "inline";
	}
}



function createDiv()
{ 
var _body = document.getElementsByTagName('body') [0];
var _div = document.createElement('div');
_div.setAttribute('name', 'lookingForMoreDiv');
_div.setAttribute('id', 'lookingForMoreDiv');
_div.setAttribute('class', 'contactUs');
_body.appendChild(_div);
//alert(document.getElementById('link_email_footer'));
}

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}


function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
   
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
   
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function validDate(days){
var today = new Date();
today.setDate(today.getDate() + 2); 
return today;

}