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());
document.body.appendChild(sc);
}

var formHTML = ""

function formClose(){
closeBusy()
hid_valiDiv()
document.getElementById('formShow').style.display = 'none'; 
document.getElementById("formPlot").innerHTML = formHTML
	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)
}
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
putVals()
fs.style.top = document.body.scrollTop + tp;
}
setTimeout("showBusy(10)",200)
}

function getRequest(bunch, paramName){
//alert(bunch)
var request = bunch
var l = request.split("&")
for (var i=0;i<l.length;i++){
                var d = l[i].split("=")
                if (d[0] == paramName){
                return unescape(d[1]);
                }
        }
        return ""
}

function putVals(){
//alert("gt")
		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]
}
//alert("hj")
if (document.getElementById("pkgName")){
document.getElementById("pkgName").innerHTML = getRequest(loadData,"package")
}
}

function pullForm(){
	  var url = "/core/ui/enqForm/vacForm.html?dt=" + new Date();
      var xmlhttp = getXMLHttpRequest();
      xmlhttp.open("POST",url,true);
      xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {


					var fs = createFrame('formShow', 'formPlot',"formClose()")
					document.body.appendChild(fs)
					fs.className = "formShow"
/*
				if (!(document.getElementById("formShow")))
				{
				var fs = document.createElement("DIV")
				//floadScript("/lib/cookie.js");
				fs.id = "formShow"
				fs.className = "formShow"
				document.body.appendChild(fs)
				}

*/
				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/booknow.gif") > 1)
	{
		var ttl = imgs[i].alt
		var ttlSp = ttl.split(":")
		if (ttlSp[1])
		{
			if (document.all)
			{
				var tElm = imgs[i].parentElement
			}
				else{
				var tElm = imgs[i].parentNode
				}
tElm.href = "javascript:shw_frm('dept_name=kff&package=" + ttlSp[1] + "')"
		}

	}
}

}

//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()
loadScript("/core/commonJs/uiCreate.js");
loadScript("/core/commonJs/jsString.js");
loadScript("/core/commonJs/validiv.js");
loadScript("/core/commonJs/busydiv.js");
loadScript("/core/commonJs/jsDate.js");
loadScript("/core/commonJs/calender_date.js");
loadScript("/core/commonJs/formfuncs.js");
loadScript("/core/commonJs/ajaxFetch.js");
loadCss("/core/commonCss/commons.css");
loadCss("/core/commonCss/calender.css");
loadCss("/core/ui/frameTable/CSS/form-stylesheet.css");

}

