// JavaScript Document
function Inint() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

function process_dock(src, type){
		
		var con = document.getElementById('condition').value;
		
		document.getElementById(src).innerHTML='<br><br><br><center><img src="traveler/assets/loading.gif"><br>Loading...</center><br><br><br>';
		//document.getElementById('solveheight').style.height = "290px";
		//document.getElementById('solveheight').style.border = "1px solid #FF0000";
		var req = Inint();
		req.onreadystatechange = function () { 
		if (req.readyState==4) {
			if (req.status==200) {
				document.getElementById(src).innerHTML=req.responseText; 
			} 
		}
		 };
			if(con==1){
				var url = "explore_includes/pageLoad.php?type="+type+"&con=1&browseId="+Math.random();
			}else{
				var url = "explore_includes/pageLoad.php?type="+type+"&con=0&browseId="+Math.random();
				}
			 
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
}

function process_dock2(src, type){
	var con = document.getElementById('condition').value;
	document.getElementById(src).innerHTML='<br><br><br><center><img src="traveler/assets/loading.gif"><br>Loading...</center><br><br><br>';
		
		var req = Inint();
		req.onreadystatechange = function () { 
		if (req.readyState==4) {
			if (req.status==200) {
				document.getElementById(src).innerHTML=req.responseText; 
			} 
		}
		 };
		 	if(con==1){
					var url = "explore_includes/loader.php?type=flight&con=1&browseId="+Math.random();
				}else{
					var url = "explore_includes/loader.php?type=flight&con=0&browseId="+Math.random();
				}
			 
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
}

function sendFlight_home(src, type){
	
	var curdate = document.getElementById('curdate').value;
	var date = document.getElementById('date').value;
	var from = document.getElementById('destination').value;
	//var to = document.getElementById('to').value;
	var name = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	var contact = document.getElementById('contact').value;
	var reservation = document.getElementById('reservation').value;
	var cont = true;
	//alert(IsNumeric(contact));
	if(date.length>0 & from.length>0 & name.length>0 & reservation.length>0 & email.length>0 & contact.length>0){	
		
		if(CheckEmail(email) == false){
			alert("Please make sure you have entered a valid email.");	
			cont = false;
		}
		if(!IsNumeric(contact) & contact.length>0 & cont == true){
			alert("Contact should be a number.");
			cont = false;	
		}
			
		if(cont==true){	
				
				
		document.getElementById(src).innerHTML='<br><br><br><center><img src="traveler/assets/loading.gif"><br>Loading...</center><br><br><br>';
		var req = Inint();
		req.onreadystatechange = function () { 
		if (req.readyState==4) {
			if (req.status==200) {
				document.getElementById(src).innerHTML=req.responseText; 
			} 
		}
		 };
		 	
	var l = "&date="+date+"&from="+from+"&name="+name+"&reservation="+reservation+"&email="+email+"&contact="+contact+"&service="+type+"&curdate="+curdate;
			 var url = "explore_includes/loader.php?type=send"+l+"&browseId="+Math.random();
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
				
		}
	}else{
		alert("Please fill up all the fields.");	
	}
}

function sendFlight2_home(src, type){
	var curdate = document.getElementById('curdate').value;
	var date = document.getElementById('date').value;
	var from = document.getElementById('from').value;
	var to = document.getElementById('to').value;
	var name = document.getElementById('name').value;
	var email = document.getElementById('email').value;
	var contact = document.getElementById('contact').value;
	var reservation = document.getElementById('reservation').value;
	var cont = true;
	//alert(IsNumeric(contact));
	if(name.length>0 & reservation.length>0 & email.length>0 & contact.length>0 & date.length>0 & from.length>0 & to.length>0){	
		
		if(CheckEmail(email) == false){
			alert("Please make sure you have entered a valid email.");	
			cont = false;
		}
		if(!IsNumeric(contact) & contact.length>0 & cont == true){
			alert("Contact should be a number.");
			cont = false;	
		}
			
		if(cont==true){	
				
				
		document.getElementById(src).innerHTML='<br><br><br><center><img src="traveler/assets/loading.gif"><br>Loading...</center><br><br><br>';
		var req = Inint();
		req.onreadystatechange = function () { 
		if (req.readyState==4) {
			if (req.status==200) {
				document.getElementById(src).innerHTML=req.responseText; 
			} 
		}
		 };
		 	
	var l = "&curdate="+curdate+"&date="+date+"&from="+from+"&to="+to+"&name="+name+"&reservation="+reservation+"&email="+email+"&contact="+contact+"&service="+type;
			 var url = "explore_includes/loader.php?type=send2"+l+"&browseId="+Math.random();
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
				
		}
	}else{
		alert("Please fill up all the fields.");	
	}
}
function IsNumeric(strString) {
   //  check for valid numeric strings	
  
   var strValidChars = "0123456789.,-#+/";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

function CheckEmail(email){
    var firstchunk,indx,secondchunk;

    if (email == ""){
        //alert("Please make sure you have entered a valid email.");

        return false;
    }

    //get the zero-based index of the "@" character
    indx = email.indexOf("@");

    //if the string does not contain an @ then then return true
    if (indx == -1 ){

       // alert("Please make sure you have entered a valid email.");

        return false;
    }

    //if the first part of email is < 2 chars and second part < 7 chars
    //(arbitrary but workable criteria) then reject the input address

    firstchunk = email.substr(0,indx); //up to but not including the "@"

    //start at char following the "@" and include up to end of email addr
    secondchunk = email.substr(indx + 1); 

    //if the part  following the "@" does not include a period "." then
    //also return false
    if ((firstchunk.length < 2 ) || (secondchunk.length < 7) ||
    (secondchunk.indexOf(".") == -1)){ 

    //alert("Please make sure you have entered a valid email.");

    return false;
	}
	return true;
}

function CheckEmail2(email, temp){
    var firstchunk,indx,secondchunk;

    if (email == ""){
        alert("Please make sure you have entered a valid email.");

        return false;
    }

    //get the zero-based index of the "@" character
    indx = email.indexOf("@");

    //if the string does not contain an @ then then return true
    if (indx == -1 ){

        alert("Please make sure you have entered a valid email.");

        return false;
    }

    //if the first part of email is < 2 chars and second part < 7 chars
    //(arbitrary but workable criteria) then reject the input address

    firstchunk = email.substr(0,indx); //up to but not including the "@"

    //start at char following the "@" and include up to end of email addr
    secondchunk = email.substr(indx + 1); 

    //if the part  following the "@" does not include a period "." then
    //also return false
    if ((firstchunk.length < 2 ) || (secondchunk.length < 7) ||
    (secondchunk.indexOf(".") == -1)){ 

    alert("Please make sure you have entered a valid email.");

    return false;
	}
	return true;
}

function Close(src){
	document.getElementById(src).innerHTML='<br><br><br><center><img src="traveler/assets/loading.gif"><br>Loading...</center><br><br><br>';
		var req = Inint();
		req.onreadystatechange = function () { 
		if (req.readyState==4) {
			if (req.status==200) {
				document.getElementById(src).innerHTML=req.responseText; 
			} 
		}
		 };
		 	
	
			 var url = "explore_includes/loader.php?type=BACK&browseId="+Math.random();
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
}

function subscribe(src){
	var letter_mail = document.getElementById('letter_mail').value;
	var temp = 0;
	if(CheckEmail2(letter_mail,temp)==true){
		document.getElementById(src).innerHTML='<br><br><br><center><img src="traveler/assets/ajax-loader.gif"><br>Loading...</center><br><br><br>';
		var req = Inint();
		req.onreadystatechange = function () { 
		if (req.readyState==4) {
			if (req.status==200) {
				document.getElementById(src).innerHTML=req.responseText; 
			} 
		}
		 };
		 	
	
			 var url = "includes/loader.php?type=insertEmail&email="+letter_mail;
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
				
	}
}

function changeLabel(src){
	document.getElementById(src).innerHTML="";
}

function changeLabel2(src){
	document.getElementById(src).innerHTML="<div style='text-align:justify; padding:6px;'><span style='text-align:justify; font-size:11px; font-weight:100; color:#666666;'><b>Our Services:</b> Topworld caters in any kind of Travel services in all kind of travelers. This is possible because we have partner hotels and tour providers all over the world. Topworld is your local, worldwide travel agency. Search for your hotel above or click on the icons below to make your request.We are working 24/7 for your safety travel.</span></div>";
}

function sendPartner(src){
	var partnerType = document.getElementById('partnerType').value;
	var propertyName = document.getElementById('propertyName').value;
	var entityType = document.getElementById('entityType').value;
	var streetAddress = document.getElementById('streetAddress').value;
	var postalCode = document.getElementById('postalCode').value;
	var country = document.getElementById('country').value;
	var starRating = document.getElementById('starRating').value;
	var numRooms = document.getElementById('numRooms').value;
	var structureType = document.getElementById('structureType').value;
	var website = document.getElementById('website').value;
	var salutation = document.getElementById('salutation').value;
	var fname = document.getElementById('fname').value;
	var lname = document.getElementById('lname').value;
	var title = document.getElementById('title').value;
	var role = document.getElementById('role').value;
	var email = document.getElementById('email').value;
	var phone = document.getElementById('phone').value;
	var fax = document.getElementById('fax').value;
	var comment = document.getElementById('comment').value;
	var cont=true;
	
	var l ="&partnerType="+partnerType+"&propertyName="+propertyName+"&entityType="+entityType+"&streetAddress="+streetAddress+"&postalCode="+postalCode;
	l+="&country="+country+"&starRating="+starRating+"&numRooms="+numRooms+"&structureType="+structureType+"&website="+website;
	l+="&salutation="+salutation+"&fname="+fname+"&lname="+lname+"&title="+title+"&role="+role+"&email="+email+"&phone="+phone;
	l+="&fax="+fax+"&comment="+comment;
	
	
	
	if(cont==true){
		if(partnerType.length>0 & propertyName.length>0 & entityType.length>0 & streetAddress.length>0 & postalCode.length>0 & country.length>0 & 
		   starRating.length>0 & numRooms.length>0 & structureType.length>0 & fname.length>0 & lname.length>0 & role.length>0 &
		   phone.length>0 & fax.length>0 & cont==true){
				if(CheckEmail(email)==false){
				alert('Your email is seems to be invalid.');
				cont=false;
				}
				
				if(cont==true & (IsNumeric(fax)==false)){
					alert('Your fax number is invalid.');
					cont=false;
				}
				
				if(cont==true & (IsNumeric(phone)==false)){
					alert('Your phone number is invalid');
					cont=false;
				}
				
				if(cont==true & (IsNumeric(postalCode)==false)){
					alert('Your postal code is invalid');
					cont=false;
				}
			//send==============================================================
				if(cont==true){
						document.getElementById(src).innerHTML='<br><br><br><center><img src="traveler/assets/ajax-loader.gif"><br>Loading...</center><br><br><br>';
		var req = Inint();
		req.onreadystatechange = function () { 
		if (req.readyState==4) {
			if (req.status==200) {
				document.getElementById(src).innerHTML=req.responseText; 
			} 
		}
		 };
		 	
	
			 var url = "includes/loadLib.php?type=insertPartner"+l;
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
				
				}
			//============================================================================================
		}else{
			alert('Some of the required fields are empty or invalid. Please check your form.');
			}
	}
}