processing=false;

function loadCss(ls){
var sc = document.createElement("LINK")
sc.setAttribute("href",ls);
sc.setAttribute("rel","stylesheet");
sc.setAttribute("content-type","text/css");
document.body.appendChild(sc);

}

function loadScript(ls){
var sc = document.createElement("SCRIPT")
sc.setAttribute("src",ls + "?" + new Date());
//alert(ls)
document.body.appendChild(sc);
}

var formHTML = ""

function formClose(){
closeBusy()
hid_valiDiv()
document.getElementById('formShow').style.display = 'none'; 
document.getElementById("formPlot").innerHTML = formHTML
//	alert(typeof(clse_cal))
	if (typeof(clse_cal) == "function")
	{
	eval(clse_cal())
	}
}


function formComplete(httpresp){
if (httpresp.indexOf("Redirect :") > 0){
	var l = httpresp.split("Redirect :")
	window.location = l[1]

}
else{
var fs = document.getElementById("formShow")
document.getElementById("formPlot").innerHTML = "<br>" + trim(httpresp) + "<center><br><a href=javascript:void(0) onclick=formClose()><img src='/core/images/b_close.gif' border=0></a></center>"
				fs.style.left = ((document.body.clientWidth - fs.offsetWidth) / 2)
				fs.style.top = ((document.body.clientHeight - fs.offsetHeight) / 2)  + document.body.scrollTop
				fs.style.zIndex="98"
				showBusy(fs.style.zIndex - 1)
}

//closeBusy()
hid_valiDiv()
}

var loadData = "";




function shw_frm(x){
loadData = x;


if (!(document.getElementById("formShow")))
{
setTimeout("pullForm()",1400)
}
else{


var fs = document.getElementById("formShow")
fs.style.display = "block";
var tp = (document.body.clientHeight - fs.offsetHeight) / 2
//mapfields()
putVals()
fs.style.top = document.body.scrollTop + tp;
}

setTimeout("showBusy(10)",200)

}
function getRequest(str,paramName){
var request = str
var l = request.split("&")
for (var i=0;i<l.length;i++)
	{
		var d = l[i].split("=")
		if (d[0] == paramName)
		{
		return d[1]
		}
	}
	return ""

}


function putVals(){
		/*var valspl = loadData.split("&")
for (var i=0;i<valspl.length;i++)
{
			var nval = valspl[i].split("=")
				
			document.getElementsByName(nval[0])[0].value = nval[1]
}*/

var d = new Date()
var x = dateAdd("d","3",d)

var dy=x.getYear()
        dy = dy.toString()
        dy = "20" + dy.substring(dy.length-2,dy)
var m = x.getDate() + "/" + (x.getMonth()+1) + "/" + dy
document.adventureForm.dep_date.value = m







var str=window.location
	var loc=str.toString()
document.getElementsByName("link")[0].value=loc
document.getElementsByName("dept_name")[0].value=getRequest(loadData,"dept_name")

if(!getRequest(loadData,"rout")){
if (document.getElementById("pkgName"))
{	
	document.getElementById("pkgName").innerHTML = getRequest(loadData,"package")	
}

if (document.getElementById("durtn"))
{	
	document.getElementById("durtn").innerHTML = getRequest(loadData,"duration")	
}


if(document.getElementById("package")){
	if(document.all){
		document.adventureForm.package.value = getRequest(loadData,"package")
	}else{
		document.getElementById("package").value = getRequest(loadData,"package")
	}
}
if(document.getElementById("duration")){

			if(document.all){
			document.adventureForm.duration.value = getRequest(loadData,"duration")
		}else{
			document.getElementById("duration").value = getRequest(loadData,"duration")
	}

}
document.getElementById("pack").innerHTML="&nbsp;&nbsp;Package"

}else{
	if(document.all){
document.getElementById("rut").style.display='block'
	}else{
	document.getElementById("rut").style.display='table-row'
	}
if (document.getElementById("pkgName"))
{	
	document.getElementById("pkgName").innerHTML = getRequest(loadData,"package")	
}

if (document.getElementById("durtn"))
{	
	document.getElementById("durtn").innerHTML = getRequest(loadData,"duration")	
}
if (document.getElementById("rout"))
{	
	document.getElementById("rout").innerHTML = getRequest(loadData,"rout")	
}

if(document.getElementById("package")){
	if(document.all){
		document.adventureForm.package.value = getRequest(loadData,"package")
	}else{
		document.getElementById("package").value = getRequest(loadData,"package")
	}
}
if(document.getElementById("duration")){

			if(document.all){
			document.adventureForm.duration.value = getRequest(loadData,"duration")
		}else{
			document.getElementById("duration").value = getRequest(loadData,"duration")
	}

}
if(document.getElementById("rout")){

			if(document.all){
			document.adventureForm.route.value = getRequest(loadData,"rout")
		}else{
			document.getElementById("route").value = getRequest(loadData,"rout")
	}

}

document.getElementById("pack").innerHTML="&nbsp;&nbsp;Itinerary"

}
}


function pullForm(){

	  var url = "http://www.travelguru.com/core/ui/Vacation_form/Vacation_form.htm?dt=" + new Date();
//alert(url)
      var xmlhttp = getXMLHttpRequest();
      xmlhttp.open("GET",url,true);
      xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {


					var fs = createFrame('formShow', 'formPlot',"formClose()")
					document.body.appendChild(fs)
					//fs.className = "formShow"
					fs.style.position="absolute"; 
					fs.style.background="white";
					fs.style.zIndex="999"
/*
				if (!(document.getElementById("formShow")))
				{
				var fs = document.createElement("DIV")
				//floadScript("/lib/cookie.js");
				fs.id = "formShow"
				fs.className = "formShow"
				document.body.appendChild(fs)
				}

*/

 var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;  

				document.getElementById("formPlot").innerHTML = xmlhttp.responseText
formHTML = xmlhttp.responseText
					
				
				fs.style.left = ((document.body.clientWidth - fs.offsetWidth) / 2)
				fs.style.top = ((document.body.clientHeight - fs.offsetHeight) / 2)  + document.body.scrollTop
				
				
				fs.style.zIndex="98"
//				showBusy(document.getElementById("formShow").style.zIndex - 1)
					fs.onmousemove = function(e){

						if (!processing)
						{
							showBusy(document.getElementById("formShow").style.zIndex - 1)
						}
						}
				fs.style.top = ((document.body.clientHeight - fs.offsetHeight) / 2)  + document.body.scrollTop

putVals()
//				mapfields()
				//loadValues()
					if (document.getElementById("formDiv"))
					{
					document.getElementById("formDiv").onscroll = function(){
			document.title = noflashed
						if (noflashed > 1)
						{
							hid_valiDiv()
						}

					}
				}

          
        }
      }
      xmlhttp.send(null);
    }    

function fix_form_link(){
var imgs = document.getElementsByTagName("img")
for (var i=0;i<imgs.length;i++)
{
	var l = imgs[i].src
	
	if (l.indexOf("/images/buttons/book-now.jpg") > 1)
	{
		var ttl = imgs[i].alt
			if(ttl=="Book Now"){
			if(document.all){
			var a = imgs[i].parentElement
			}else{
			var a = imgs[i].parentNode
			}
		var href=a.href
		var varble=href.split("?")
		var pckg_dept=varble[1].split("&")
			if(pckg_dept.length==3){
		var dept=pckg_dept[0].split("=")
		var pckg=pckg_dept[1].split("=")
		var durtn=pckg_dept[2].split("=")

		var dept_name=dept[1]
		var pckg_name=pckg[1]
		var duration=durtn[1]
		}else{
		var dept=pckg_dept[0].split("=")
		var iten=pckg_dept[1].split("=")
		var durtn=pckg_dept[2].split("=")
		var rout=pckg_dept[3].split("=")

		var dept_name=dept[1]
		var iten_name=iten[1]
		var duration=durtn[1]
		var route=rout[1]

		}
		


		//var ttlSp = ttl.split(":")
		if (dept_name)
		{
			if (document.all)
			{
				var tElm = imgs[i].parentElement
			}
				else{
				var tElm = imgs[i].parentNode
				}
if(pckg_dept.length==3){
tElm.href = "javascript:shw_frm('dept_name="+dept_name+"&package=" + pckg_name + "&duration="+duration+"')"
}else{
tElm.href = "javascript:shw_frm('dept_name="+dept_name+"&package=" + iten_name + "&duration="+duration+"&rout="+route+"')"
}
		}




	}

	}
}

}

//var st = setTimeout("fix_form_link()",1000)


var tl

if (document.all)
{
	tl = document.body
}
else{
	tl = window
}


window.onload = function(e){

fix_form_link()
loadCss("/core/commonCss/commons.css");
loadCss("/ui/datepicker/css/calender.css");
loadScript("/core/commonJs/uiCreate_VacForm.js");
loadScript("/core/commonJs/jsString.js");
loadScript("/core/commonJs/validiv.js");
loadScript("/core/commonJs/busydiv.js");
loadScript("/core/commonJs/jsDate.js");
loadScript("/ui/datepicker/lib/calender_date.js");
loadScript("/core/commonJs/formfuncs.js");

//loadCss("/core/ui/frameTable/CSS/form-stylesheet.css");

}



