// 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(src, type){
	
		document.getElementById(src).innerHTML='<br><br><br><center><img src="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 = "includes/pageLoad.php?type="+type+"&browseId="+Math.random();
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
}

function process2(src, type){
	document.getElementById(src).innerHTML='<br><br><br><center><img src="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 = "includes/loader.php?type=convention&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(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(date.length>0 & from.length>0 & to.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="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+"&to="+to+"&name="+name+"&reservation="+reservation+"&email="+email+"&contact="+contact+"&service="+type+"&curdate="+curdate;
			 var url = "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(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){	
		
		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="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 = "&name="+name+"&reservation="+reservation+"&email="+email+"&contact="+contact+"&service="+type;
			 var url = "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 sendFlight2(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){	
		
		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 = "&name="+name+"&reservation="+reservation+"&email="+email+"&contact="+contact+"&service="+type;
			 var url = "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 backMenu(src){
	document.getElementById(src).innerHTML='<br><br><br><center><img src="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 = "includes/loader.php?type=backMenu";
			 
			 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="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 showFullImage(src, id, albumId){
	document.getElementById(src).innerHTML='<br><br><br><br><br><br><br><br><br><center><img src="assets/ajax-loader.gif"><br>Loading...</center><br><br><br><br><br><br><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=showImage&id="+id+"&albumId="+albumId;
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
}

function showFullImage2(src, id, albumId){
	
	document.getElementById(src).innerHTML='<br><br><br><br><br><br><br><br><br><center><img src="assets/ajax-loader.gif"><br>Loading...</center><br><br><br><br><br><br><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=showImage2&id="+id+"&albumId="+albumId;
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
}

function paginateMyFriendsAll(src,page){
	
	document.getElementById(src).innerHTML='<br><br><br><br><br><br><br><br><br><center><img src="assets/ajax-loader.gif"><br>Loading...</center><br><br><br><br><br><br><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=paginateMyFriends&page="+page;
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
}

function paginateUserFriendsAll(src, page){
	document.getElementById(src).innerHTML='<br><br><br><br><br><br><br><br><br><center><img src="assets/ajax-loader.gif"><br>Loading...</center><br><br><br><br><br><br><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=paginateUserFriends&page="+page;
			 
			 req.open("GET", url); 
			 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");     
			 req.send(null);
}

function insertComment(src){
	
	var comment = document.getElementById('comment').value;
		
	if(comment.length>0){
			//var n = document.getElementById('ncomment').value;
			//n = parseFloat(n)+1;
			//document.getElementById('ncomment').value = n;
			document.getElementById(src).innerHTML='<center><img src="assets/ajax-loader.gif"><br>Loading...</center>';
		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=insertComment&comment="+comment;
			 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 the form.");	
		}
	
}

function paginateFavoriteAdvUser(src,page,uid){
	document.getElementById(src).innerHTML='<br><br><br><center><img src="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/travelerLoad.php?type=paginateAdvUser&browseId="+Math.random()+"&uid="+uid+"&page="+page;
    req.open("GET", url); 
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");    req.send(null); 
}

function paginateFavoriteHotelUser(src,page,uid){
	document.getElementById(src).innerHTML='<br><br><br><center><img src="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/travelerLoad.php?type=paginateFavHotelUser&browseId="+Math.random()+"&uid="+uid+"&page="+page;
    req.open("GET", url); 
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");    req.send(null); 
}
