﻿// JScript File

var xmlHttp=null;
function servervariable(urln,ref,currQuery,domainname,count)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
 var url;
if(count==1){url="Ip_Common.aspx";}
else{url="../Ip_Common.aspx";}
url=url+"?urln="+urln;
url=url+"&ref="+ref;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged(){}

function sendSubScript(num)
{if(emailCheck(document.getElementById("reqMail").value)!=true){document.getElementById("reqMail").focus();    }
 else{sendMail(document.getElementById("reqMail").value,num);}
}
function showSubscriptionBox()
{document.getElementById("SubscriptionBox").style.visibility="visible";
 document.getElementById("result").style.visibility="hidden";
}
function sendMail(emailID,num)
{
xHttp=GetXmlHttpObject();
if (xHttp==null) 
{alert("Your browser does not support Ajax");
return;
}
if(num==1){var address="subscript.aspx";}
else {var address="../subscript.aspx";}
address=address+"?requiredMail="+emailID;
xHttp.onreadystatechange=function()
{
  if (xHttp.readyState==4)
    {
    if (xHttp.status==200)
        {
              document.getElementById("result").style.visibility="visible";
              document.getElementById("SubscriptionBox").style.visibility="hidden";
              document.getElementById("reqMail").value="please enter your email"
        }
    }
};
xHttp.open("GET",address,true);
xHttp.send(null); 
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try{xmlHttp=new XMLHttpRequest();}
catch (e){
try{xmlHttp=new  ActiveXObject("Msxml2.XMLHTTP");}
catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
}return xmlHttp;}

function changeOpacFH(opacity, id)
{   var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function emailCheck (emailStr)
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)");
//document.FlightSearch.requiredEmail.focus()
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;}}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;}}
if (user.match(userPat)==null) {
alert("The username doesn't seem to be valid.");
return false;}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;}}
return true;}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;}}
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;}
if (len<2){
alert("This address is missing a hostname!");
return false;}
return true;
}
function FLTHTL_NoRes(sngRoom,twnRoom,dblRoom,tplRoom,DptDate,RetDate,sGUID,Type)
{ var address;  
  xHttp=GetXmlHttpObject();
  if(xHttp==null){alert("Your browser does not support Ajax");return;}
  if(Type=="FLT"){address="HtlFlt_NoHtlOrFltAvail.aspx?sGUID="+sGUID+"&Type="+Type; }
  else if(Type=="HTL"){address="HtlFlt_NoHtlOrFltAvail.aspx?sngRoom="+sngRoom+"&twnRoom="+twnRoom+"&dblRoom="+dblRoom+"&tplRoom="+tplRoom+"&DptDate="+DptDate+"&RetDate="+RetDate+"&sGUID="+sGUID+"&Type="+Type; }
  else {address="HtlFlt_NoHtlOrFltAvail.aspx?sGUID="+sGUID+"&Type="+Type;}
  xHttp.onreadystatechange=function()
    {if (xHttp.readyState==4){if(xHttp.status==200){document.getElementById("SorryHTlFLT_NoRes").innerHTML=xHttp.responseText;}
            else{alert("There is techincal problem while retrieving data from server");}
     }}
    xHttp.open("GET",address,true);
    xHttp.send(null); 
}

function sendValue(DestFrom,DestTo,dptDD,DptMonYr,retDD,RetMonYr,siteurl,htlName)
{	
	document.offer_book.FHDestFrom.value=DestFrom;
	document.offer_book.FHDestTo.value=DestTo;
	document.offer_book.FHDptDate.value=dptDD;
	document.offer_book.FHDptMonYr.value=DptMonYr;
	document.offer_book.FHRetDate.value=retDD;
	document.offer_book.FHRetMonYr.value=RetMonYr;
	document.offer_book.FHAdult.value="2";
	document.offer_book.FHChild.value="0";
	document.offer_book.FHInfant.value="0";
	document.offer_book.FHSngRoom.value="0";
	document.offer_book.FHTwnRoom.value="0";
	document.offer_book.FHDblRoom.value="1";
	document.offer_book.FHTplRoom.value="0";
	document.offer_book.FHNonStop.value="0";
	document.offer_book.FHRequestType.value="flighthotel";
	document.offer_book.FlightClassFH.value="ECONOMY";
	document.offer_book.siteurl.value=siteurl;
	document.offer_book.htlName.value=htlName;	
	//document.offer_book.method="post";
	//document.offer_book.target="_top";	
	//document.offer_book.action="flighthotel.aspx";	
	document.offer_book.submit();	
	}


