//begin ajax variable instantiation
var xmlHttp = false;
var xmlHttp2 = false;
var xmlHttp3 = false;
var initing = false;
var loggingoff = false;
var sfrom;
var sinc;
var ssearchby;
var suserid;
var stotal;
var sresponse;
var sresults;
var smenu = 'default';
var shmenu = 'default';
var sinterval = 0;
var saction;
var srefresh;
var sdiv;
var fdiv;
var mdiv;
var icall = false;
var shistrefresh;
var thishist;
var srole;
var proid = 0;
var procount = 0;
var win;
var menuchange = false;
var changemenu = false;
var changeamenu = false;
var menurestore = false;
var dothishist = false;
var hist = new Array();
var histmenu = new Array();
var future = new Array();
var addOptionsTo = new Array();
var addOptionsText = new Array();
var addOptionsValue = new Array();
var addOptionsAt = new Array();
var IE;
var IE7 = false;
var clicked = false;
var date = new Date();
var cashprevent = date.getTime();
var openelement;
var openaction;
var upx;
var upy;
var pid;
var timeout;
var nullcall = false;
var sfun;
//var inner = '<center><img src="/images/odometer.gif" title="Processing..." alt="Processing..."/><br/>Processing...</center>';
var inner = '<center><img src="/images/loadingani.gif" alt="Loading..."/>';
var select_box=0;


if (document.documentElement && typeof document.documentElement.style.maxHeight != "undefined") {
    //alert('lo'+ navigator.appName);
    if (navigator.appName == "Microsoft Internet Explorer") {
        IE7 = true;
    }
} else {
    //alert('hi');
    IE7 = false;
}
//try{
//  var jav = new java.lang.String('notie7');
// IE7=false;
//}catch(e){
//  IE7=true;
//}
window.onload = function() {
    init();
}
window.onresize = function() {
    detectWindow();
}
try {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    IE = true;
} catch (e) {
    try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        IE = true;
    } catch (e2) {
        xmlHttp = false;
    }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
    IE = false;
}
try {
    xmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    try {
        xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e2) {
        xmlHttp2 = false;
    }
}
if (!xmlHttp2 && typeof XMLHttpRequest != 'undefined') {
    xmlHttp2 = new XMLHttpRequest();
}
try {
    xmlHttp3 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    try {
        xmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e2) {
        xmlHttp3 = false;
    }
}
if (!xmlHttp3 && typeof XMLHttpRequest != 'undefined') {
    xmlHttp3 = new XMLHttpRequest();
}

//end ajax variable instantiation
function loopSelected(id333)
{
	var selectedArray = new String;
	var selObj = document.getElementById(id333);	
	var i;
	
	for (i=0; i<selObj.options.length; i++) {
		if (selObj.options[i].selected) {
			selectedArray = selectedArray + selObj.options[i].value + ",";	
		}
	}
	return selectedArray;
}


function doHistory() {
    var fun;
    fun = arguments.callee.caller;
    var fun2 = arguments.callee.caller.arguments.callee.caller;
    var st = fun.toString().indexOf("function");
    var end = fun.toString().indexOf("(");
    var stri = fun.toString().substring((st + 9), end);
    var callargs = fun.arguments;
    shistrefresh = stri;
    thishist = new Array();
    thishist[0] = callargs;
    thishist[1] = fun2;
    hist.unshift(thishist);
    if (fun2.toString().indexOf('doAjaxDualAction') != -1) {
    	histmenu.unshift(shmenu);
    }else{
    	histmenu.unshift(smenu);
    }
    //alert('histmenu:: ' + histmenu);
    dothishist = false;
}
//being ajax request processing
function callServer(url, fun) {
    if (!dothishist) {
        doHistory();

    } else {
        dothishist = false;
    }
    if (url.indexOf('?') == -1) {
        url = url + '?refreshprevent=' + (++cashprevent);
    }
    else {
        url = url + '&refreshprevent=' + (++cashprevent);
    }
	//alert(url);
    if (!nullcall) {
        xmlHttp.open("GET", url, true);
        if (fun == mainData) xmlHttp.onreadystatechange = mainData;
        if (fun == mainDataMgr) xmlHttp.onreadystatechange = mainDataMgr;
        if (fun == pageUpdate) xmlHttp.onreadystatechange = pageUpdate;
        if (fun == logoff)xmlHttp.onreadystatechange = logoff;
        if (fun == mainDual)xmlHttp.onreadystatechange = mainDual;
        if (fun == mainDual2)xmlHttp.onreadystatechange = mainDual2;
        if (fun == mainDual3)xmlHttp.onreadystatechange = mainDual3;
        if (fun == calendarupdate)xmlHttp.onreadystatechange = calendarupdate;
        if (fun == popuptoWin)xmlHttp.onreadystatechange = popuptoWin;
        xmlHttp.send(null);
    } else {
        nullcall = false;
    }

}
function callServer2(url, fun) {
    if (url.indexOf('?') == -1) {
        url = url + '?refreshprevent=' + (++cashprevent);
    }
    else {
        url = url + '&refreshprevent=' + (++cashprevent);
    }
    xmlHttp2.open("GET", url, true);
    if (fun == mainData2) xmlHttp2.onreadystatechange = mainData2;
    if (fun == mainDataMgr2) xmlHttp2.onreadystatechange = mainDataMgr2;
    if (fun == pageUpdate) xmlHttp2.onreadystatechange = pageUpdate;
    if (fun == pageUpdate2) xmlHttp2.onreadystatechange = pageUpdate2;
    if (fun == logoff)xmlHttp2.onreadystatechange = logoff;
    if (fun == mainDual)xmlHttp2.onreadystatechange = mainDual;
    if (fun == mainDual2)xmlHttp2.onreadystatechange = mainDual2;
    if (fun == mainDual3)xmlHttp2.onreadystatechange = mainDual3;
    if (fun == calendarupdate)xmlHttp2.onreadystatechange = calendarupdate;
    if (fun == popuptoWin)xmlHttp2.onreadystatechange = popuptoWin;
    xmlHttp2.send(null);
}
function callServer3(url, fun) {
    if (url.indexOf('?') == -1) {
        url = url + '?refreshprevent=' + (++cashprevent);
    }
    else {
        url = url + '&refreshprevent=' + (++cashprevent);
    }
    xmlHttp3.open("GET", url, true);
    if (fun == mainData2) xmlHttp3.onreadystatechange = mainData2;
    if (fun == mainDataMgr2) xmlHttp3.onreadystatechange = mainDataMgr2;
    if (fun == pageUpdate) xmlHttp3.onreadystatechange = pageUpdate;
    if (fun == pageUpdate2) xmlHttp3.onreadystatechange = pageUpdate2;
    if (fun == logoff)xmlHttp3.onreadystatechange = logoff;
    if (fun == mainDual)xmlHttp3.onreadystatechange = mainDual;
    if (fun == mainDual2)xmlHttp3.onreadystatechange = mainDual2;
    if (fun == mainDual3)xmlHttp3.onreadystatechange = mainDual3;
    if (fun == calendarupdate)xmlHttp3.onreadystatechange = calendarupdate;
    if (fun == popuptoWin)xmlHttp3.onreadystatechange = popuptoWin;
    xmlHttp3.send(null);
}
function callServerPost(url, parameters, fun) {
	BrowserDetect.init();
    parameters = parameters + '&refreshprevent=' + (++cashprevent);
    if (dothishist)dothishist = false;
    //xmlHttp.open("POST", url, true);
    if (BrowserDetect.browser == "Explorer"){
    	xmlHttp.open("POST", url, true);
    	if (fun == mainData) xmlHttp.onreadystatechange = mainData;
    	if (fun == mainDataMgr) xmlHttp.onreadystatechange = mainDataMgr;
    	if (fun == pageUpdate) xmlHttp.onreadystatechange = pageUpdate;
    	if (fun == logoff)xmlHttp.onreadystatechange = logoff;
    	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    	xmlHttp.setRequestHeader("Content-length", parameters.length);
    	xmlHttp.setRequestHeader("Connection", "close");
    	xmlHttp.send(parameters);
    }else{
    	xmlHttp2.open("POST", url, true);
    	if (fun == mainData) xmlHttp2.onreadystatechange = mainData2;
    	if (fun == mainDataMgr) xmlHttp2.onreadystatechange = mainDataMgr2;
    	if (fun == pageUpdate) xmlHttp2.onreadystatechange = pageUpdate2;
    	if (fun == logoff) xmlHttp2.onreadystatechange = logoff;
    	xmlHttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    	xmlHttp2.setRequestHeader("Content-length", parameters.length);
    	xmlHttp2.setRequestHeader("Connection", "close");
    	xmlHttp2.send(parameters);
    }
}
function mainData() {
    //alert('maindata');
    var ini = true;
    if (xmlHttp.readyState != 4) {
        //alert('read state is not 4 ' + sdiv);
        disableLinks();
	
        var results;
        if (sdiv == undefined) {
            results = icall ? parent.document.getElementById('MainDataDiv') : document.getElementById('MainDataDiv');
        } else {
            ini = false;
            results = icall ? parent.document.getElementById(sdiv) : document.getElementById(sdiv);
        }
        results.innerHTML = '';
        //var inner = '<table align="center"><tr><td><div id="d2" style="position:relative;top:0px;left:0px;background-color:#333333;height:30px;width:0px;padding-top:5px;padding:0px;">'+
        //              '<div id="d1" style="position:relative;top:0px;left:0px;color:#f0ffff;height:30px;text-align:center;font:bold;padding:0px;padding-top:5px;border:1px;border-color:#05143F;background-color:#F77D47;">'+
        //              '</div></div></td></tr></table>';
        if (sdiv != undefined && sdiv != 'MainDataDiv') {
            results.innerHTML = inner;
        } else {
            results.innerHTML = '<br/><br/><br/><br/>' + inner;
        }
        prog();
    }
    if (xmlHttp.readyState == 4) {
        //alert('read state == 4 ' + sdiv);
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp.responseText;
	
			
        var results;
        if (sdiv == undefined) {
            results = icall ? parent.document.getElementById('MainDataDiv') : document.getElementById('MainDataDiv');
        }
        else {
            results = icall ? parent.document.getElementById(sdiv) : document.getElementById(sdiv);
            ini = false;
            sdiv = undefined;
        }
        results.innerHTML = '';
        results.innerHTML = response; 		
		if(select_box==1)
		{
			
			check();
		}
		
        if (sinterval > 0) {
            if (saction == 'rdcclients')  {
                sfun = 'doAjaxAction2(\'rdcmanager\',' + sinterval + ')';
                srefresh = window.setInterval(sfun, sinterval);
            }
            else    {
                sfun = 'doAjaxAction2(\'' + saction + '\',' + sinterval + ')';
                srefresh = window.setInterval(sfun, sinterval);
            }
        }
        if (changemenu) {
        	var url = '/corejsp/utils/leftactivity.jsp?ajax=' + srole + '&action=' + smenu;
            //var url = '/corejsp/utils/menu.jsp?ajax=' + srole + '&action=' + smenu;
            callServer2(url, mainDual);
            if(smenu.indexOf('subrogation') != -1){
            	document.getElementById("helpdiv").style.visibility = 'hidden';
            }else{
            	changemenu = false;
            	if(document.getElementById("helpdiv") != null){
            		document.getElementById("helpdiv").style.visibility = 'visible';
            	}
            }
        }
        
        icall = false;
        if (ini) {
            init();
        }
    }
}

function mainData2() {
    var ini = true;
    if (xmlHttp2.readyState != 4) {
        disableLinks();
        var results;
		add_Check();
        if (sdiv == undefined) {
            results = icall ? parent.document.getElementById('MainDataDiv') : document.getElementById('MainDataDiv');
        } else {
            ini = false;
            results = icall ? parent.document.getElementById(sdiv) : document.getElementById(sdiv);
        }
        results.innerHTML = '';
        //var inner = '<table align="center"><tr><td><div id="d2" style="position:relative;top:0px;left:0px;background-color:#333333;height:30px;width:0px;padding-top:5px;padding:0px;">'+
        //              '<div id="d1" style="position:relative;top:0px;left:0px;color:#f0ffff;height:30px;text-align:center;font:bold;padding:0px;padding-top:5px;border:1px;border-color:#05143F;background-color:#F77D47;">'+
        //              '</div></div></td></tr></table>';
        if (sdiv != undefined && sdiv != 'MainDataDiv') {
            results.innerHTML = inner;
        } else {
            results.innerHTML = '<br/><br/><br/><br/>' + inner;
        }
        prog();
    }
    if (xmlHttp2.readyState == 4) {
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp2.responseText;
		
        //popUpResponse(response);
        var results;
        if (sdiv == undefined) {
            results = icall ? parent.document.getElementById('MainDataDiv') : document.getElementById('MainDataDiv');
        } else {
            results = icall ? parent.document.getElementById(sdiv) : document.getElementById(sdiv);
            ini = false;
            sdiv = undefined;
        }

        results.innerHTML = '';
        if (window.XMLHttpRequest && !IE7) {
            results.innerHTML = response;
        } else if (window.ActiveXObject) {
            // popUpResponse(response);
            results.innerHTML = response;
        }
        if (sinterval > 0) {
            sfun = 'doAjaxAction2(\'' + saction + '\',' + sinterval + ')';
            srefresh = window.setInterval(sfun, sinterval);
        }
        if (changemenu) {
        	var url = '/corejsp/utils/leftactivity.jsp?ajax=' + srole + '&action=' + smenu;
            callServer2(url, mainDual);
            if(smenu.indexOf('subrogation') != -1){
            	document.getElementById("helpdiv").style.visibility = 'hidden';
            }else{
            	changemenu = false;
            	if(document.getElementById("helpdiv") != null){
            		document.getElementById("helpdiv").style.visibility = 'visible';
            	}
            }
        }
        
        icall = false;
        if (ini) {
            init();
        }
    }
}
function popuptoWin() {
	//alert("popuptoWin 1");
    if (xmlHttp.readyState != 4) {
        disableLinks();
    }
    if (xmlHttp.readyState == 4) {
        enableLinks();
        var response = xmlHttp.responseText;
        var bodytag = document.getElementById('bodytag');
        var me = document.createElement('div');
        var td = document.getElementById('td_' + openaction + '_' + pid);
        me.setAttribute('id', 'popup' + pid);
        me.innerHTML = response;
        me.style.visibility = 'hidden';
        me.style.border = '2px';
        bodytag.appendChild(me);
        var tab = document.getElementById('table_' + openaction + '_' + pid);
        if (pid == openelement && me.style.visibility == 'visible') {
            openelement = null;
        }
        if (openelement !== null) {
            var op = document.getElementById('popup' + openelement);
            if (window.XMLHttpRequest && !IE7) { // Mozilla, Safari,...
                var parent = op.parentNode;
                parent.removeChild(op);
            } else if (window.ActiveXObject) {
                var parent = op.parentElement;
                parent.removeChild(op);
            }
        }
        if (pid != openelement && me.style.visibility == 'hidden') {
            openelement = pid;
            me.style.visibility = 'visible';
            me.style.width = '100%';
            me.style.position = 'relative';
            if (window.XMLHttpRequest && !IE7) { // Mozilla, Safari,...
                me.style.left = window.scrollX + 100;
                me.style.top = window.scrollY + 175;
                me.style.marginLeft = 0;
                bodytag.style.zIndex = -1;
                me.style.zIndex = 1;
            } else if (window.ActiveXObject) {
                me.style.left = document.body.scrollLeft + 100;
                me.style.top = document.body.scrollTop + 175;
            }
        } else if (me.style.visibility == 'visible') {
            me.style.visibility = 'hidden';
            me.style.position = 'relative';
        }
    }
}
function mainDataMgr() {
    var ini = true;
    //alert('state' + xmlHttp.readyState);
    if (xmlHttp.readyState != 4) {
        disableLinks();
        var results;
        //alert('mdiv' + mdiv);
        if (mdiv == undefined) {
            results = document.getElementById('screenone');
        } else {
            ini = false;
            results = document.getElementById(mdiv);
        }
        results.innerHTML = '';
        try {
            if (mdiv != undefined && mdiv != 'screenone') {
                results.innerHTML = inner;
            } else {
                results.innerHTML = '<br/><br/><br/><br/>' + inner;
            }
            prog();
        } catch(e) {
        }
    }
    if (xmlHttp.readyState == 4) {
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp.responseText
		Display_EMS1();
        var results;
		
        //alert('mdiv: ' + (mdiv == undefined));
        if (mdiv == undefined) {
            results = document.getElementById('screenone');
        } else {
            //alert('mdiv: ' + mdiv);
            results = document.getElementById(mdiv);
            //alert('results: ' + results);
            mdiv = undefined;
            ini = false;
        }
        if (results == undefined)   {
            results.innerHTML = inner;    
        }
        results.innerHTML = '';
        if (window.XMLHttpRequest && !IE7) {
            results.innerHTML = response;
        } else if (window.ActiveXObject) {
            results.innerHTML = response;
        }
        icall = false;
    }

}
function mainDataMgr2() {
    var ini = true;
    if (xmlHttp2.readyState != 4) {
        disableLinks();
        var results;
        if (mdiv == undefined) {
            results = document.getElementById('screenthree');
        } else {
            ini = false;
            results = document.getElementById(mdiv);
        }
        results.innerHTML = '';
        try {
            //var inner = '<table align="center"><tr><td><div id="d2" style="position:relative;top:0px;left:0px;background-color:#333333;height:30px;width:0px;padding-top:5px;padding:0px;">'+
            //              '<div id="d1" style="position:relative;top:0px;left:0px;color:#f0ffff;height:30px;text-align:center;font:bold;padding:0px;padding-top:5px;border:1px;border-color:#05143F;background-color:#F77D47;">'+
            //              '</div></div></td></tr></table>';
            if (mdiv != undefined && mdiv != 'screenthree') {
                results.innerHTML = inner;
            } else {
                results.innerHTML = '<br/><br/><br/><br/>' + inner;
            }
            prog();
        } catch(e) {

        }
    }
    if (xmlHttp2.readyState == 4) {
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp2.responseText;
        var results;
        if (mdiv == undefined) {
            results = document.getElementById('screenthree');
        } else {
            results = document.getElementById(mdiv);
            mdiv = undefined;
            ini = false;
        }
        results.innerHTML = '';
        if (window.XMLHttpRequest && !IE7) {
            results.innerHTML = response;
        } else if (window.ActiveXObject) {
            results.innerHTML = response;
        }
        icall = false;
    }

}
function mainDual() {
    if (xmlHttp2.readyState != 4) {
        disableLinks();
        //var resultss = document.getElementById('defaultmenudiv');
        var resultss = document.getElementById('leftmenus');
        resultss.innerHTML = '';
        resultss.innerHTML = 'Finding new menu...';
    }
    if (xmlHttp2.readyState == 4) {
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp2.responseText;
        //var resultss = document.getElementById('defaultmenudiv');
        var resultss = document.getElementById('leftmenus');
        resultss.innerHTML = '';
        resultss.innerHTML = response;
        /*if (window.XMLHttpRequest && !IE7) {
            resultss.innerHTML = response;
        } else if (window.ActiveXObject) {
            resultss.innerHTML = response;
        }*/
        init();
    }
}
function mainDual2() {
    if (xmlHttp2.readyState != 4) {
        disableLinks();
        var resultss = document.getElementById('screenone');
        resultss.innerHTML = '';
        resultss.innerHTML = 'Finding users...';
    }
    if (xmlHttp2.readyState == 4) {
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp2.responseText;
        var resultss = document.getElementById('screenone');
        resultss.innerHTML = '';
        if (window.XMLHttpRequest && !IE7) {
            resultss.innerHTML = response;
        } else if (window.ActiveXObject) {
            resultss.innerHTML = response;
        }
        init();
    }
}
function mainDual3(){
	if (xmlHttp3.readyState != 4) {
        disableLinks();
        var resultss = document.getElementById('leftactivitydiv');
        resultss.innerHTML = '';
        resultss.innerHTML = 'Finding new menu...';
    }
    if (xmlHttp3.readyState == 4) {
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp3.responseText;
        var resultss = document.getElementById('leftactivitydiv');
        resultss.innerHTML = '';
        if (window.XMLHttpRequest && !IE7) {
            resultss.innerHTML = response;
        } else if (window.ActiveXObject) {
            resultss.innerHTML = response;
        }
        init();
    }
}
function calendarupdate() {
    var results = document.getElementById('cal');
    if (xmlHttp3.readyState != 4) {
        disableLinks();
        //results.innerHTML = '';
        //results.innerHTML = 'APU is searching for the data you requested please wait...';
    }
    if (xmlHttp3.readyState == 4) {
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp3.responseText;
        try {
            results.innerHTML = '';
            results.innerHTML = response;
        } catch(eu) {
        }
    }

}
function logoff() {
    if (xmlHttp.readyState != 4) {
        disableLinks();
        try {
            var results = document.getElementById('MainDataDiv');
            results.innerHTML = '';
            results.innerHTML = 'APU is searching for the data you requested please wait...';
        } catch(e) {
        }
    }
    if (xmlHttp.readyState == 4) {
        enableLinks();
        window.clearInterval(proid);
        proid = 0;
        procount = 0;
        var response = xmlHttp.responseText;
        if (IE) {
            document.write(response);
        } else {
            document.close();
            document.open();
            document.write(response);
        }
        //document.close();
        //setTimeout(init,10000);
    }
}
//end ajax request processing
function sleep(interval) {
    //setTimeout('sleeping()',interval);
    var starttime = new Date().valueOf();
    var curtime = starttime.valueOf();
    //logWindow("Starting Interval Time: " +interval + " : " + starttime);
    while ((curtime - interval) < starttime) {
        curtime = new Date().valueOf();
    }
}
function loadQuoteInputs(action, rfqid, parttype, div) {
    saction = action;

    sdiv = div;
    var url = '/index.jsp?ajax=1&results=1&ajaxpages=1&action=' + action + '&rfqid=' + rfqid + '&parttype=' + parttype +

              '&sdiv=' + div;
    callServer2(url, pageUpdate2);
}


//functions for pagination
function paginate(action, userid, from, inc, total) {
    saction = action;
    suserid = userid;
    sfrom = from;
    sinc = inc;
    stotal = total;
    var url = '/index.jsp?ajax=1&ajaxpages=1&action=' + action + '&userid=' + userid + '&from=' + from +
              '&inc=' + inc + '&total=' + total;
    callServer(url, pageUpdate);
}
function paginateReport(action, userid, from, inc, total, searchby, div) {
    saction = action;
    suserid = userid;
    sfrom = from;
    sinc = inc;
    stotal = total;
    sdiv = div;
    var url = '/index.jsp?ajax=1&results=1&ajaxpages=1&action=' + action + '&userid=' + userid + '&from=' + from +
              '&inc=' + inc + '&total=' + total + '&searchby=' + searchby;
    callServer2(url, pageUpdate2);
}
function ajaxJump(fun) {
    var from = document.getElementById('page_selfrom');
    sfrom = from.value;
    var id = document.getElementById('page_id');
    suserid = id.value;
    var inc = document.getElementById('page_increment');
    sinc = inc.value;
    var total = document.getElementById('page_total');
    stotal = total.value;
    var action = document.getElementById('page_action');
    saction = action.value;
    var url;
    if (fun == pageUpdate)url = '/index.jsp?ajax=1&ajaxpages=1&action=' + saction + '&id=' + suserid + '&from=' + sfrom + '&increment=' + sinc + '&total=' + stotal;
    callServer(url, fun);
}
function ajaxJump(fun, div) {
    var from = document.getElementById('page_selfrom');
    sfrom = from.value;
    var id = document.getElementById('page_id');
    suserid = id.value;
    var inc = document.getElementById('page_increment');
    sinc = inc.value;
    var total = document.getElementById('page_total');
    stotal = total.value;
    var action = document.getElementById('page_action');
    saction = action.value;
    sdiv = div;
    var url;
    if (fun == pageUpdate)url = '/index.jsp?ajax=1&ajaxpages=1&action=' + saction + '&id=' + suserid + '&from=' + sfrom + '&increment=' + sinc + '&total=' + stotal;
    callServer(url, fun);
}
function ajaxJumpReport(fun, div) {

    var from = document.getElementById('page_selfrom');
    sfrom = from.value;
    var id = document.getElementById('page_id');
    suserid = id.value;
    var inc = document.getElementById('page_increment');
    sinc = inc.value;
    var total = document.getElementById('page_total');
    stotal = total.value;
    var action = document.getElementById('page_action');
    saction = action.value;
    sdiv = div;
    var url;
    if (fun == pageUpdate2)url = '/index.jsp?ajax=1&results=1&ajaxpages=1&action=' + saction + '&id=' + suserid + '&from=' + sfrom + '&increment=' + sinc + '&total=' + stotal;
    callServer2(url, fun);
}
function pageUpdate() {
    if (xmlHttp.readyState != 4)disableLinks();
    if (xmlHttp.readyState == 4) {
        enableLinks();
        var response = xmlHttp.responseText;
        var results;
        if (sdiv == undefined) {
            results = document.getElementById('resultsdiv');
        }
        if (fdiv != undefined) {
            results = document.getElementById(fdiv);
        } else {
            results = document.getElementById(sdiv);
            sdiv = undefined;
        }
        sresponse = response;
        sresults = results;
        if (window.XMLHttpRequest && !IE7 && results != null) {
            results.innerHTML = '';
            results.innerHTML = response;
        } else if (window.ActiveXObject && results != null) {
            results.innerHTML = '';
            results.innerHTML = response;
        }
        init();
    }
}
function pageUpdate2() {
    if (xmlHttp2.readyState != 4)disableLinks();
    if (xmlHttp2.readyState == 4) {
        enableLinks();
        var response = xmlHttp2.responseText;
        var results;
        //alert('sdiv:: ' + sdiv + ' fdiv:: ' + fdiv);
        if (sdiv == undefined) {
            results = document.getElementById('resultsdiv');
        }
        if (fdiv != undefined) {
            results = document.getElementById(fdiv);
        } else {
            results = document.getElementById(sdiv);
            sdiv = undefined;
        }
        sresponse = response;
        sresults = results;
        if (window.XMLHttpRequest && !IE7 && results != null) {
            results.innerHTML = '';
            results.innerHTML = response;
        } else if (window.ActiveXObject && results != null) {
       		results.innerHTML = '';
           	results.innerHTML = response;
        }
    }


}
//end pagination functions

//being navigation functions
function goHome(){
	var shome = document.getElementById('home').value;
	var landing = document.getElementById('landing').value;
	var sesstype = document.getElementById('sesstype').value;
	srole = sesstype;
		if(shome == 'subroinitiate'){
			smenu = 'subrogation';
			switchCSS('subrogation');
		}else if(shome == 'reportlistback'){
			smenu = 'reporting';
			switchCSS('reporting');
		}else if(shome == 'bRFQSubmit'){
			smenu = 'pn';
			switchCSS('pn');
		}else if(shome == 'profile'){
			smenu = 'profile';
			switchCSS('profile');
		}else if(shome == 'sclaimlookup'){
			smenu = 'pn';
			switchCSS('pn');
		}
	menuchange = true;
    doAjaxAction2(document.getElementById('home').value, document.getElementById('interval').value);
    hist = new Array();
    histmenu = new Array();
}

function goBack() {
    if (hist[1] == undefined) {
    	var shome = document.getElementById('home').value;
    	var landing = document.getElementById('landing').value;
    	var sesstype = document.getElementById('sesstype').value;
    	//alert('shome:: ' + shome + ' landing:: ' + landing + ' sesstype:: ' + sesstype);
    	srole = sesstype;
   		if(shome == 'subroinitiate'){
   			smenu = 'subrogation';
   			switchCSS('subrogation');
   		}else if(shome == 'reportlistback'){
   			smenu = 'reporting';
   			switchCSS('reporting');
   		}else if(shome == 'bRFQSubmit'){
   			smenu = 'pn';
   			switchCSS('pn');
   		}else if(shome == 'profile'){
   			smenu = 'profile';
   			switchCSS('profile');
   		}else if(shome == 'sclaimlookup'){
			smenu = 'pn';
			switchCSS('pn');
		}
   		menuchange = true;
        doAjaxAction2(document.getElementById('home').value, document.getElementById('interval').value);
        hist = new Array();
        histmenu = new Array();
    } else {
        dothishist = true;
        var backhist = new Array();
        var backmenu = histmenu.shift();
        backhist = hist[1];
        hist.shift();
        thishist.unshift(backhist);
        if (shistrefresh == 'callServer') {
            var bac = backhist[0];
            var bac2 = backhist[1];
            if (bac2.toString().indexOf('doAjaxDualAction') != -1) {
            	//alert('backmenu:: ' + backmenu);
            	changemenu = true;
            	smenu = backmenu;
            	switchCSS(backmenu);
                //if (smenu == 'default')smenu = 'other';
            }
            var st = backhist[0][0];
            if (st.indexOf('&back=1') == -1) {
                st = st + '&back=1';
                //alert('st:: ' + st);
                backhist[0][0] = st;
            }
            //alert('backhist[0][0]:: ' + backhist[0][0]);
            callServer.apply(this, backhist[0]);
        }
    }

}
function goRefresh() {
    if (thishist == undefined || thishist.length == 0) {
        var action = document.getElementById('home').value;
        var url = '/index.jsp?ajax=1&action=' + action;
        callServer(url, mainData);
    } else {
        if (shistrefresh == 'callServer') callServer.apply(this, thishist[0]);
    }
}
function doAction(action) {
    var form = document.ps.elements;

    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action') {
            form[i].value = action;
        }
    }
   // disableLinks();
    window.document.ps.submit();

}
function doAjaxURL(url) {
    window.clearInterval(srefresh);
    var fun = mainData;
    callServer(url, fun);
}
function doAjaxAction(action) {
    var fun;
    if (action == 'logoff' || action == 'about') {
        fun = logoff;
    } else {
        fun = mainData;
    }
    var url = '/index.jsp?action=' + action;
    if (action != 'about') {
        url = url + '&ajax';
    }
	//alert(url);
    callServer(url, fun);
}
function doAjaxActionLogin(action) {
//alert('hai');
    var fun;
    if (action == 'logoff') {
        loggingoff = true;
    }
    if (action == 'logoff' || action == 'about' || action == 'login') {
        fun = logoff;
    } else {
        fun = mainData;
    }
    if (action == 'login') {
        var url = 'action=' + action + '&login=' + document.getElementById('login').value + '&password=' + document.getElementById('password').value;
        callServerPost('/index.jsp', url, logoff);
    } else if (action == 'logoff') {
        window.location = '/index.jsp?action=logoff';
    } else {
        var url = '/index.jsp?action=' + action;
        callServer(url, logoff);
    }
}
function doAjaxActionTransfer(action) {

    var fun;
    fun = mainData;
    var url = '/index.jsp?action=' + action + '&tclaimid=' + document.getElementById('tclaimid').value;
    callServer(url, logoff);
}
function doAjaxDualAction(action, sessiontype) {
    var url = '/index.jsp?action=' + action + '&ajax';
    window.clearInterval(srefresh);
    srole = sessiontype;
    smenu = 'other';
    var fun = mainData;
    callServer(url, fun);
    changemenu = true;
}

function doAjaxDualAction2(action, sessiontype) {
    var url = '/index.jsp?action=' + action + '&ajax';
    window.clearInterval(srefresh);
    srole = sessiontype;
    var fun = mainData;
    menurestore = true;
    switchCSS('reporting');
    callServer(url, fun);
}

function doAjaxDualAction3(action, sessiontype, id) {
	var url = '/index.jsp?action=' + action + '&ajax';
	window.clearInterval(srefresh);
	srole = sessiontype;
	var fun = mainData;
	menurestrore = true;
	switchCSS(id);
	callServer(url, fun);
}

function doAjaxDualAction4(action, sessiontype, id, menu, interval) {
	
	var url = '/index.jsp?action=' + action + '&ajax';
	window.clearInterval(srefresh);
	if(interval == 0){
		srefresh = 0;
		sinterval = 0;
	}else if(interval != 0){
		sinterval = interval;
	}
	srole = sessiontype;
	
	shmenu = smenu;
	smenu = menu;
	changemenu = true;
	var fun = mainData;
	callServer(url, fun);
	switchCSS(id);
}

function doAjaxAction2(action, interval) {
    window.clearInterval(srefresh);
    if (interval == 0) {
        srefresh = 0;
        sinterval = 0;
    } else if (interval != 0) {
        sinterval = interval;
    }
    if (menuchange)changemenu = true;	
    saction = action;
    if (menurestore){
    	changemenu = true;
    }	
    doAjaxAction(action);
}
function doDefaultAjaxAction2(action, interval) {
    window.clearInterval(srefresh);
    if (interval == 0) {
        srefresh = 0;
        sinterval = 0;
    } else if (interval != 0) {
        sinterval = interval;
    }
    changemenu = false;
    menuchange = true;
    saction = action;
    doAjaxAction(action);
}
function doAjaxAction3(action, id) {
    window.clearInterval(srefresh);
    sinterval = 0;
    var url = '/index.jsp?action=' + action + '&ajax&id=' + id;
    var fun = mainData;	
    callServer(url, fun);
}
function doAjaxAction4(link) {
    window.clearInterval(srefresh);
    var fun = mainData;
    callServer(link, fun);
}
function doAjaxActionPanel(action, id) {
    var form = document.ps.elements;
    var url = "/index.jsp";
    var params = "ajax&action=" + action + "&id=" + id;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'id' || form[i].name == 'action') {
        } else if (form[i].type != 'checkbox') {
            params = params + '&' + form[i].name + '=' + form[i].value;
        } else {
            if (form[i].checked) {
                params = params + '&' + form[i].name + '=' + form[i].value;
            }
        }
    }
    url = url + '?' + params;
    //alert('action:' + action);
    //alert('url: ' + url);
    var fun = mainData;
    callServer(url, fun);
}
function doAjaxAction42(link) {
    window.clearInterval(srefresh);
    var fun = mainData2;
    callServer2(link, fun);
}
function doAjaxAction5(link, divid) {
    window.clearInterval(srefresh);
    sdiv = divid;
    icall = true;
    callServer(link, mainData);
}

function doAjaxActionParent(link, divid) {
    window.clearInterval(srefresh);
    mdiv = divid;
    icall = false;
    parent.document.getElementById('screenthree').innerHTML = '';
    callServer(link, mainDataMgr);
}
function doAjaxActionParent2(link, divid) {
    window.clearInterval(srefresh);
    mdiv = divid;
    icall = false;
    callServer(link, mainDataMgr);
}
function doAjaxActionDiv(action, divid) {
    var fun;
    mdiv = divid;
    sdiv = divid;
    icall = false;
    if (action == 'logoff' || action == 'about') {
        fun = logoff;
    } else {
        fun = mainData;
    }
    var url = '/index.jsp?action=' + action;
    if (action != 'about') {
        url = url + '&ajax';
    }
    //alert('url' + url);
    //alert('function' + fun);
    callServer(url, fun);
}

//end navigation functions

//being form processing
function readForm() {
    window.clearInterval(srefresh);
    var form = document.ps.elements;
    var url = "/index.jsp?ajax";
    var action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action')action = form[i].value;
        if (form[i].type == 'checkbox') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else if (form[i].type == 'radio') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else {
            url = url + '&' + form[i].name + '=' + form[i].value;
        }
    }
    saction = action;
    dothishist = true;
    callServer(url, mainData);
}
function readFormPost() {
    window.clearInterval(srefresh);
    var form = document.getElementById('ps').elements;    
    var url = "ajax=";
    var first = true;
    var action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action') {
            action = form[i].value;
        }
        if (form[i].type == 'checkbox') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else if (form[i].type == 'radio') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else {
            url = url + '&' + form[i].name + '=' + form[i].value;
        }
    }
    saction = action;
    dothishist = true; 
    //alert(url);    
    callServerPost('/index.jsp', url, mainData);
}

function readPLFormPost() {
    window.clearInterval(srefresh);
    var form = document.getElementById('ps').elements;    
    var url = "ajax=";
    var first = true;
    var action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action') {
            action = form[i].value;
        }
        if (form[i].type == 'checkbox') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else if (form[i].type == 'radio') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else {
            url = url + '&' + form[i].name + '=' + form[i].value;
        }
    }
    saction = action;
    dothishist = true; 
    //alert(url);    
    callServerPost('/corejsp/buyer/pl_index.jsp', url, mainData);
}


function readFormNamePost(inputid, taction) {
    var fo = document.getElementsByTagName('select');
    var form = new Array();
    for (var j = 0; j < fo.length; j++) {
        if (fo[j].name.indexOf(inputid) != -1) {
            form.unshift(fo[j]);
        }
    }
    var ins = document.getElementsByTagName('input');
    for (var k = 0; k < ins.length; k++) {
        if (ins[k].type == 'hidden' && ins[k].name.indexOf(inputid) != -1) {
            form.unshift(ins[k]);
        }
    }
    var url = 'ajax=&action=' + taction;
    var first = true;
    var action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action') {
        }
        if (form[i].type == 'checkbox') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else if (form[i].type == 'radio') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else {
            url = url + '&' + form[i].name + '=' + form[i].value;
        }
    }
    saction = action;
    dothishist = true;
    callServerPost('/index.jsp', url, mainData);
}
function readFormAll() {
    var form = document.ps.elements;
    var url = "/index.jsp?ajax";
    var action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action')action = form[i].value;
        if (form[i].type == 'checkbox') {
            if (!form[i].checked)form[i].value = 'off';
            url = url + '&' + form[i].name + '=' + form[i].value;
        }
        else if (form[i].type == 'radio') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
        else {
            url = url + '&' + form[i].name + '=' + form[i].value;
        }
    }
    saction = action;
    dothishist = true;
    callServer(url, mainData);
}
function readFormAction(action) {
 //alert('aa')
    var form = document.ps.elements;	
    var url = "/index.jsp?ajax&action=" + action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name != 'action') {
            if (form[i].type == 'checkbox') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + form[i].value;
                }
            }
            else if (form[i].type == 'radio') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + form[i].value;
                }
            }
            else {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
    }
	//alert(url);
    saction = action;
    dothishist = true;
    callServer(url, mainData);
}
function readFormActionPost(action) {
	//alert(action);
    window.clearInterval(srefresh);
    var form = document.getElementById('ps').elements;
	
    var url = "ajax=&action=" + action;
	
	
    for (var i = 0; i < form.length; i++) {
	
        if (form[i].name != 'action' && form[i].value != null && form[i].value.length > 0) {
            if (form[i].type == 'checkbox') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'radio') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'textarea') {
                if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'hidden') {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'select-multiple') {
                var selectedoptions = '';
                for (var j = 0; j < form[i].options.length; j++) {
                    if (form[i].options[j].selected) {
                        if (selectedoptions.length == 0) {
                            selectedoptions = selectedoptions + encodeURIComponent(form[i].options[j].value);
                        }
                        else {
                            selectedoptions = selectedoptions + ',' + encodeURIComponent(form[i].options[j].value);
                        }
                    }
                }
                if (selectedoptions.length > 0) {
                    url = url + '&' + form[i].name + '=' + selectedoptions;
                }
            } else {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
                else {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
			//alert(url);
        }
    }
    saction = action;
    dothishist = true;	 
    callServerPost('/index.jsp', url, mainData);

}

function readPLFormActionPost(action) {
	//alert(action);
    window.clearInterval(srefresh);
    var form = document.getElementById('ps').elements;
	
    var url = "ajax=&action=" + action;
	
	
    for (var i = 0; i < form.length; i++) {
	
        if (form[i].name != 'action' && form[i].value != null && form[i].value.length > 0) {
            if (form[i].type == 'checkbox') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'radio') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'textarea') {
                if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'hidden') {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'select-multiple') {
                var selectedoptions = '';
                for (var j = 0; j < form[i].options.length; j++) {
                    if (form[i].options[j].selected) {
                        if (selectedoptions.length == 0) {
                            selectedoptions = selectedoptions + encodeURIComponent(form[i].options[j].value);
                        }
                        else {
                            selectedoptions = selectedoptions + ',' + encodeURIComponent(form[i].options[j].value);
                        }
                    }
                }
                if (selectedoptions.length > 0) {
                    url = url + '&' + form[i].name + '=' + selectedoptions;
                }
            } else {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
                else {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
			//alert(url);
        }
    }
    saction = action;
    dothishist = true;	 
    callServerPost('/corejsp/buyer/pl_index.jsp', url, mainData);

}

function readFormActionPostCustom(action,iparam,ivalue) {
	//alert(action);
    window.clearInterval(srefresh);
    var form = document.getElementById('ps').elements;
	
    var url = "ajax=&action=" + action;
	
	
    for (var i = 0; i < form.length; i++) {
	
        if (form[i].name != 'action' && form[i].value != null && form[i].value.length > 0) {
            if (form[i].type == 'checkbox') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'radio') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'textarea') {
                if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'hidden') {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'select-multiple') {
                var selectedoptions = '';
                for (var j = 0; j < form[i].options.length; j++) {
                    if (form[i].options[j].selected) {
                        if (selectedoptions.length == 0) {
                            selectedoptions = selectedoptions + encodeURIComponent(form[i].options[j].value);
                        }
                        else {
                            selectedoptions = selectedoptions + ',' + encodeURIComponent(form[i].options[j].value);
                        }
                    }
                }
                if (selectedoptions.length > 0) {
                    url = url + '&' + form[i].name + '=' + selectedoptions;
                }
            } else {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
                else {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
			//alert(url);
        }
    }
    url = url + '&' + iparam + '=' + encodeURIComponent(ivalue);
    saction = action;
    dothishist = true;	 
    callServerPost('/index.jsp', url, mainData);

}

function readPLFormActionPostCustom(action,iparam,ivalue) {
	//alert(action);
    window.clearInterval(srefresh);
    var form = document.getElementById('ps').elements;
	
    var url = "ajax=&action=" + action;
	
	
    for (var i = 0; i < form.length; i++) {
	
        if (form[i].name != 'action' && form[i].value != null && form[i].value.length > 0) {
            if (form[i].type == 'checkbox') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'radio') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'textarea') {
                if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'hidden') {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'select-multiple') {
                var selectedoptions = '';
                for (var j = 0; j < form[i].options.length; j++) {
                    if (form[i].options[j].selected) {
                        if (selectedoptions.length == 0) {
                            selectedoptions = selectedoptions + encodeURIComponent(form[i].options[j].value);
                        }
                        else {
                            selectedoptions = selectedoptions + ',' + encodeURIComponent(form[i].options[j].value);
                        }
                    }
                }
                if (selectedoptions.length > 0) {
                    url = url + '&' + form[i].name + '=' + selectedoptions;
                }
            } else {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
                else {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
			//alert(url);
        }
    }
    url = url + '&' + iparam + '=' + encodeURIComponent(ivalue);
    saction = action;
    dothishist = true;	 
    callServerPost('/corejsp/buyer/pl_index.jsp', url, mainData);

}

function readFormActionPosttoWindow(action) {

    window.clearInterval(srefresh);
    var form = document.ps.elements;
    var url = "ajax=&action=" + action;
	//alert('raj  = '  +url);
    for (var i = 0; i < form.length; i++) {
        if (form[i].name != 'action' && form[i].value != null && form[i].value.length > 0) {
            if (form[i].type == 'checkbox') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'radio') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'textarea') {
                if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'hidden') {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'select-multiple') {
                var selectedoptions = '';
                for (var j = 0; j < form[i].options.length; j++) {
                    if (form[i].options[j].selected) {
                        if (selectedoptions.length == 0) {
                            selectedoptions = selectedoptions + encodeURIComponent(form[i].options[j].value);
                        }
                        else {
                            selectedoptions = selectedoptions + ',' + encodeURIComponent(form[i].options[j].value);
                        }
                    }
                }
                if (selectedoptions.length > 0) {
                    url = url + '&' + form[i].name + '=' + selectedoptions;
                }
            } else {
                if (form[i].name == 'estimateEMS') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                } else if (form[i].name == 'claimtext') {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
                else {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
        }
    }
    saction = action;
    dothishist = true;
    OpenWin2('/index.jsp?' + url);

}

//Generate the  reports
function readFormActionPosttoReportWindow(action){  
    var url = "ajax=&action=" + action; 
    OpenWin2('/index.jsp?' + url);
}

function getValues(aqtype, div, selectname,actiontype) {
    dothishist = true;
    var action = actiontype;
    sdiv = div;
    var url = '/index.jsp?ajax=1&select=1&action=' + action + '&aqtype=' + aqtype + '&selectname=' + selectname;
    callServer(url, mainData);
}

function getTable(model, aqtype, div, selectname,actiontype) {
    dothishist = true;
    var action = actiontype;
    sdiv = div;
    var url = '/index.jsp?ajax=1&select=1&action=' + action + '&aqtype=' + aqtype + '&selectname=' + selectname + '&model=' + model; 
    callServer(url, mainData);
}


function readFormNewAction(action) {
    document.getElementById('action').value = action;
    readForm();
}

function readFormAction2(action, id, idname) {
    window.clearInterval(srefresh);
    var form = document.ps.elements;
    var url = "/index.jsp?ajax&action=" + action + "&" + idname + "=" + id;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'id' || form[i].name == 'action' || form[i].name == 'idname') {
        }
        else if (form[i].type != 'checkbox') {
            url = url + '&' + form[i].name + '=' + form[i].value;
        }
        else {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
    }
    saction = action;
    dothishist = true;
    callServer(url, mainData);
}
function readFormActionDiv(action, id, idname, div) {
    sdiv = div;
    mdiv = div;
    window.clearInterval(srefresh);
    var form = document.ps.elements;
    var url = "/index.jsp?ajax&action=" + action + "&" + idname + "=" + id;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name != 'action' && form[i].value != null && form[i].value.length > 0) {
            if (form[i].type == 'checkbox') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'radio') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'textarea') {
                if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'hidden') {
                url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
            }
            else if (form[i].type == 'select-multiple') {
                var selectedoptions = '';
                for (var j = 0; j < form[i].options.length; j++) {
                    if (form[i].options[j].selected) {
                        if (selectedoptions.length == 0) {
                            selectedoptions = selectedoptions + encodeURIComponent(form[i].options[j].value);
                        }
                        else {
                            selectedoptions = selectedoptions + ',' + encodeURIComponent(form[i].options[j].value);
                        }
                    }
                }
                if (selectedoptions.length > 0) {
                    url = url + '&' + form[i].name + '=' + selectedoptions;
                }
            }
            else {
                //alert('name ' + form[i].name + '  value ' + form[i].value);
                url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
            }
        }
    }
    saction = action;
    dothishist = true;
    //alert('url' + url);
    callServer(url, mainData);
}

function readFormActionDivInterval(action, id, idname, div, interval) {
    //alert('go go interval! ' + interval);
    sdiv = div;
    mdiv = div;
    window.clearInterval(srefresh);
    if (interval == 0) {
        srefresh = 0;
        sinterval = 0;
    } else if (interval != 0) {
        sinterval = interval;
    }
    var form = document.ps.elements;
    var url = "/index.jsp?ajax&action=" + action + "&" + idname + "=" + id;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name != 'action' && form[i].value != null && form[i].value.length > 0) {
            if (form[i].type == 'checkbox') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'radio') {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            } else if (form[i].type == 'textarea') {
                if (form[i].value != null) {
                    url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
                }
            }
            else if (form[i].type == 'hidden') {
                url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
            }
            else if (form[i].type == 'select-multiple') {
                var selectedoptions = '';
                for (var j = 0; j < form[i].options.length; j++) {
                    if (form[i].options[j].selected) {
                        if (selectedoptions.length == 0) {
                            selectedoptions = selectedoptions + encodeURIComponent(form[i].options[j].value);
                        }
                        else {
                            selectedoptions = selectedoptions + ',' + encodeURIComponent(form[i].options[j].value);
                        }
                    }
                }
                if (selectedoptions.length > 0) {
                    url = url + '&' + form[i].name + '=' + selectedoptions;
                }
            }
            else {
                //alert('name ' + form[i].name + '  value ' + form[i].value);
                url = url + '&' + form[i].name + '=' + encodeURIComponent(form[i].value);
            }
        }
    }
    saction = action;
    dothishist = true;
    //alert('url' + url);
    callServer(url, mainData);
}

function readForm2(action, id) {
    var form = document.ps.elements;
    var url = "/index.jsp";
    var params = "ajax&action=" + action + "&id=" + id;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'id' || form[i].name == 'action') {
        } else if (form[i].type != 'checkbox') {
            params = params + '&' + form[i].name + '=' + form[i].value;
        } else {
            if (form[i].checked) {
                params = params + '&' + form[i].name + '=' + form[i].value;
            }
        }
    }
    saction = action;
    dothishist = true;
    //callServer(url,mainData);
    callServerPost(url, params, mainData)
}
function readURLForm() {
    var form = document.ps.elements;
    var url;
    if (window.XMLHttpRequest && !IE7) {
        url = document.ps.getAttribute("action") + '?ajax';
    }
    else if (window.ActiveXObject) {
        url = document.ps.action + '?ajax';
    }
    var action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action')action = form[i].value;
        if (form[i].name == 'div') {
            sdiv = form[i].value;
        } else if (form[i].type != 'checkbox') {
            url = url + '&' + form[i].name + '=' + form[i].value;
        } else {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
    }
    saction = action;
    dothishist = true;
    callServer(url, mainData);
}
function readURLFormPost() {
    var form = document.ps.elements;
    var url;
    if (window.XMLHttpRequest && !IE7) {
        url = 'ajax';
    } else if (window.ActiveXObject) {
        url = 'ajax';
    }
    var action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action')action = form[i].value;
        if (form[i].type == 'file') {
        } else  if (form[i].name == 'div') {
            sdiv = form[i].value;
        } else if (form[i].type != 'checkbox') {
            url = url + '&' + form[i].name + '=' + form[i].value;
        } else {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        }
    }
    saction = action;
    dothishist = true;
    callServerPost(document.ps.action, url, mainData);
}
function readFormResults(divid) {
    var form = document.ps.elements;
    var url = "ajax=0&results=0";
    var first = true;
    var action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name == 'action')action = form[i].value;
        if (form[i].type == 'select-multiple') {
            var opts = form[i].options;
            var isfirst = true;
            url = url + '&' + form[i].name + '=';
            var addurl = '';
            for (var j = 0; j < opts.length; j++) {
                if (opts[j].selected) {
                    if (isfirst) {
                        addurl = opts[j].value;
                        isfirst = false;
                    } else {
                        addurl = addurl + ',' + opts[j].value;
                    }
                }
            }
            url = url + addurl;
        }
        if (form[i].type == 'checkbox') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        } else if (form[i].type == 'radio') {
            if (form[i].checked) {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
        } else {

            url = url + '&' + form[i].name + '=' + form[i].value;
        }
    }
    saction = action;
    sdiv = divid;
    dothishist = true;
    callServerPost('/index.jsp', url, mainData);
}
function readFormNewAction(action) {
    document.getElementById('action').value = action;
    readForm();
}
function readFormClear(action) {
    window.clearInterval(srefresh);
    var form = document.ps.elements;
    var url = "/index.jsp?ajax&action=" + action;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name != 'action') {
            if (form[i].type != 'checkbox') {
                url = url + '&' + form[i].name + '=' + form[i].value;
            }
            else {
                if (form[i].checked) {
                    url = url + '&' + form[i].name + '=' + form[i].value;
                }
            }
        }
    }
    saction = action;
    dothishist = true;
    if (document.getElementById('pagination'))bord = true;
    callServer(url, mainData);
}
//end form processing

//being pop utils
function popUpProperties(inobj) {
    op = window.open();
    op.document.open('text/plain');
    for (objprop in inobj) {
        op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
    }
    op.document.close();
}
function popUpResponse(res) {
    var wi = window.open();
    wi.document.open("text/html");
    wi.document.write('<textarea cols="100" rows="50">' + res + '</textarea>');
}
//end popup utils

//being link utils
function disableLink(link) {
    if (link.onclick)
        link.oldOnClick = link.onclick;
    link.onclick = cancelLink;
    if (link.style)
        link.style.cursor = 'default';
}
function disableLinks() {
	objLinks = document.links;
    for (var i = 0; i < objLinks.length; i++) {
        disableLink(document.links[i]);
    }
}
function enableLink(link) {
    if (link.onclick) {
        link.onclick = link.href;
    }
    if (link.style) {
        link.style.cursor = 'pointer';
    }
}
function enableLinks() {
    for (var i = 0; i < document.links.length; i++) {
        enableLink(document.links[i]);
    }
}
function cancelLink() {
    return false;
}
//end link utils

//begin image swaps'
function MM_findObj(n, d) { //v4.0
    var p,i,x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && document.getElementById) x = document.getElementById(n);
    return x;
}
function MM_swapImage() { //v3.0
    var i,j = 0,x,a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) {
            document.MM_sr[j++] = x;
            if (!x.oSrc) x.oSrc = x.src;
            x.src = a[i + 2];
        }
}
function MM_swapImgRestore() { //v3.0
    var i,x,a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
//end image swaps

//begin field population
function placeBuyer(what) {
    document.forms[0].buyerid.value = what;
}
function placeSeller(what) {
    document.forms[0].sellerid.value = what;
}
//end field population

//window pop-ups
function OpenWin1(what) {
    if (win != null && !win.closed)
        win.close();

    win = window.open(what, 'new', 'toolbar=no,scrollbars=yes,alwaysRaised=yes,width=400,height=400,resizable=1');
    win.focus();
}
function OpenWin(what) {
    if (win != null && !win.closed)
        win.close();

    win = window.open(what, 'new', 'toolbar=no,scrollbars=yes,alwaysRaised=yes,width=400,height=400,resizable=1');
    win.focus();
}
function OpenWin2(what) {
    //win = window.open(what, 'new', 'toolbar=no,scrollbars=yes,alwaysRaised=yes,width=400,height=400,resizable=1');
    if (win != null && !win.closed)
        win.close();

    win = window.open(what, 'new', 'toolbar=no,scrollbars=yes,alwaysRaised=yes,width=800,height=600,resizable=1');
    win.focus();
    // by apro frequent error with open picture in next string in IE >5
    // win.document.title = "Attachment/Picture";
}
function OpenWinPrint(what) {
    //win = window.open(what, 'new', 'toolbar=no,scrollbars=yes,alwaysRaised=yes,width=400,height=400,resizable=1');
    if (win != null && !win.closed)
        win.close();

    win = window.open(what, 'new', 'toolbar=no,scrollbars=yes,alwaysRaised=yes,width=800,height=800,resizable=1');
    win.focus();
    // by apro frequent error with open picture in next string in IE >5
    // win.document.title = "Attachment/Picture";
}
//end window popups
function append(name, value) {
    if (document.getElementById(name)) {
        document.getElementById(name).setAttribute('value', value);
    } else {
        var input = document.createElement('input');
        input.setAttribute('type', 'hidden');
        input.setAttribute('name', name);
        input.setAttribute('id', name);
        input.setAttribute('value', value);
        document.ps.appendChild(input);
    }
}
function appendString(name, value, id, link) {
    var url = link + '&' + name + '=' + value;
    doAjaxAction4(url, mainData);

}
function appendStringInDiv(name, value, id, link) {
    var url = link + '&' + name + '=' + value;
    sdiv = id;
    doAjaxAction4(url, mainData);

}
function appendString2(name, value, id, link) {
    var url = link + '&' + name + '=' + value;
    doAjaxAction42(url, mainData2);

}
function append2String2(name2, value2, name, value, id, link) {
    var url = link + '&' + name + '=' + value + '&' + name2 + '=' + value2;
    doAjaxAction42(url, mainData2);

}

function appendSelect(url, id) {
    var el = document.getElementById(id);

    url = url + el.value;
    doAjaxAction4(url, mainData);
}
function appendSelect2(url, id) {
    var el = document.getElementById(id);
    url = url + el.value;
    doAjaxAction42(url, mainData2);
}
function appendNewAction(action) {
    document.getElementById('action').value = action;
}
function rfqpopup(rfqid) {
    var url = '/corejsp/buyer/rfqpop.jsp?rfqid=' + rfqid;
    OpenWin(url);
}
//onload functions
function init() {
    var calee = arguments.callee.caller;
    if (document.getElementById("history")) {
        //alert('doing history');
        id = document.getElementById("history").value;
        var form = document.ps.elements;
        var url = "/index.jsp";
        var params = "ajax&action=icontrolpanelaudit&id=" + id;
        for (var i = 0; i < form.length; i++) {
            if (form[i].name == 'id' || form[i].name == 'action') {
            } else if (form[i].type != 'checkbox') {
                params = params + '&' + form[i].name + '=' + form[i].value;
            } else {
                if (form[i].checked) {
                    params = params + '&' + form[i].name + '=' + form[i].value;
                }
            }
        }
        url = url + '?' + params;
        //alert('url: ' + url);
        nullcall = true;
        callServer(url, mainData);
    }
    if (document.getElementById("onload_scrolltop")) {
        document.body.scrollLeft = 0;
        document.body.scrollTop = 0;
    }
    if(document.getElementById("fcountryS")){
    	finitCountry();
    }
    if (document.getElementById("countryS")) {
        initCountry();
    }
    if(document.getElementById("onload_fcountry")){
    	fselectCountry(document.getElementById('onload_fcountry').innerHTML);
    }
    if(document.getElementById("onload_fstate")){
    	selectState(document.getElementById('onload_fstate').innerHTML);
    }
    if (document.getElementById("onload_country")) {
        selectCountry(document.getElementById('onload_country').innerHTML);
    }
    if (document.getElementById("onload_state")) {
        addDefault('Any', -2, 'state');
        selectState(document.getElementById('onload_state').innerHTML);
    }
    if (document.getElementById("onload_city")) {
        getPsInput('city').value = document.getElementById("onload_city").innerHTML;
    }
    if (document.getElementById('getmenu')) {
        doAction('btransferlist');
    }
    if (document.getElementById("onload_address")) {
        getPsInput('address').value = document.getElementById("onload_address").innerHTML;
    }
    if (document.getElementById("onload_address2")) {
        getPsInput('address2').value = document.getElementById("onload_address2").innerHTML;
    }
    if (document.getElementById("onload_zip")) {
        getPsInput('zip').value = document.getElementById("onload_zip").innerHTML;
    }
    if (document.getElementById("onload_company_name")) {
        getPsInput('companyContact').value = document.getElementById("onload_company_name").innerHTML;
    }
    if (document.getElementById("onload_companyContact")) {
        getPsInput('companyContact').value = document.getElementById("onload_companyContact").innerHTML;
    }
    if (document.getElementById("onload_increment")) {
        getPsInput('increment').value = document.getElementById('onload_increment').innerHTML;
    }
    if (document.getElementById("onload_company_name")) {
        getPsInput('companyContact').value = document.getElementById("onload_company_name").innerHTML;
    }
    if (document.getElementById("onload_display_name")) {
        getPsInput('displayname').value = document.getElementById("onload_display_name").innerHTML;
    }
    if (document.getElementById("onload_entity_name")) {
        getPsInput('entityname').value = document.getElementById("onload_entity_name").innerHTML;
    }
    if (document.getElementById("onload_companyContact")) {
        getPsInput('companyContact').value = document.getElementById("onload_companyContact").innerHTML;
    }
    if (document.getElementById("onload_increment")) {
        getPsInput('increment').value = document.getElementById('onload_increment').innerHTML;
    }
    if (document.getElementById("onload_date1")) {
        //getPsInput('date1').value = document.getElementById("onload_date1").innerHTML;
        getDate('date1');
    }
    if (document.getElementById("onload_date2")) {
        //getPsInput('date2').value = document.getElementById("onload_date2").innerHTML;
        getDate('date2');
    }
    if (document.getElementById("onload_date2text")) {
        getPsInput('date2').value = document.getElementById("onload_date2text").innerHTML;
        getDate('date2');
    }
    if (document.getElementById("onload_billday")) {
        getPsInput('billday').value = document.getElementById("onload_billday").innerHTML;
    }
    if (document.getElementById("onload_duplicate")) {
        getPsInput('duplicate').value = document.getElementById("onload_duplicate").innerHTML;
    }
    if (document.getElementById("onload_autoquote")) {
        //getPsInput('autoquote').value = document.getElementById("onload_autoquote").innerHTML;
        selectOptionWithValue(getPsInput('autoquote'), document.getElementById("onload_autoquote").innerHTML);
    }
    if (document.getElementById("onload_gpid")) {
        getPsInput('gpid').value = document.getElementById("onload_gpid").innerHTML;
    }
    if (document.getElementById("onload_catid")) {
        getPsInput('catid').value = document.getElementById("onload_catid").innerHTML;
    }
    if (document.getElementById("onload_fyear")) {
        var fyears = new Array("1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007");
        var fyear = document.getElementById("onload_fyear").innerHTML;
        var ffyear = document.getElementById('fyear');
        setOptionsWithKeys(ffyear, fyears, fyears);
        //setOptionText(ffyear, fyears);
        addDefault('Any', -2, 'fyear');
        if (fyear == -2) {
            ffyear.options[0].selected = true;
        }
        for (var i = 0; i < ffyear.length; i++) {
            if (ffyear.options[i].text == fyear) {
                ffyear.options[i].selected = true;
            }
        }
        getPsInput('fyear').value = document.getElementById("onload_fyear").innerHTML;
    }
    if (document.getElementById("onload_tyear")) {
        var tyears = new Array("2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996", "1995", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1985", "1984", "1983", "1982", "1981", "1980");
        var tyear = document.getElementById("onload_tyear").innerHTML;
        var ttyear = document.getElementById('tyear')
        setOptionsWithKeys(ttyear, tyears, tyears);
        //setOptionText(ttyear, tyears);
        addDefault('Any', -2, 'tyear');
        //document.ps.tyear.options[3].selected = true;
        if (tyear == -2) {
            ttyear.options[0].selected = true;
        }
        for (var i = 0; i < ttyear.length; i++) {
            if (ttyear.options[i].text == tyear) {
                ttyear.options[i].selected = true;
            }
        }
        getPsInput('tyear').value = document.getElementById("onload_tyear").innerHTML;
    }
    if (document.getElementById("onload_routeid")) {
        selectOptionWithValue(getPsInput('routeid'), document.getElementById("onload_routeid").innerHTML);
    }
    if (document.getElementById("onload_companyuser")) {
        function getSelected(companyuser) {
            var selected = new Array();
            var index = 0;
            for (var intLoop = 0; intLoop < opt.length; intLoop++) {
                if (companyuser[intLoop].selected) {
                    index = selected.length;
                    selected[index] = new Object;
                    selected[index].value = companyuser[intLoop].value;
                    selected[index].index = intLoop;
                }
            }
            return selected;
        }
        if (getPsInput('companyuser').length > 0)   addAny('companyuser');
        else insertOption(getPsInput('companyuser'), "Any", -2, 0, true);
        selectOptionWithValue(getPsInput('companyuser'), document.getElementById("onload_companyuser").innerHTML);

    }
    if (document.getElementById("onload_localoffice")) {
        insertOption(getPsInput('localoffice'), "Any", -2, 0, true);
        selectOptionWithValue(getPsInput('localoffice'), document.getElementById("onload_localoffice").innerHTML);
    }
    if (document.getElementById("onload_regionaloffice")) {
        //addAny('regionaloffice');
        selectOptionWithValue(getPsInput('regionaloffice'), document.getElementById("onload_regionaloffice").innerHTML);
    }
    if (document.getElementById('defaultems')) {
        var ems = document.getElementById('defaultems').innerHTML;
        //showEMS(ems);
    }
    if (document.getElementById('unload_caluser')) {
        var cal = document.getElementById('caluser');
        cal.parentNode.removeChild(cal);
    }
    if (document.getElementById('caluser')) {
        callBuyerCal(document.getElementById('caluser').innerHTML, document.getElementById('calinc').innerHTML, document.getElementById('calweek').innerHTML);
    }
    if (document.getElementById('scaluser')) {
        callSellerCal(document.getElementById('scaluser').innerHTML, document.getElementById('calinc').innerHTML, document.getElementById('calweek').innerHTML);
    }
    if (document.getElementById('vehicleS')) {
        initOthers();
        addNotSpecified('bodyType', 'bodyStyle', 'axleType', 'fuelType', 'transmissionType');
    }
    if (document.getElementById('onload_bodyType')) {
        selectBodyType('<xsl:value-of select="@bodyType"/>');
    }
    if (document.getElementById('onload_bodyStyle')) {
        selectBodyStyle(document.getElementById('onload_bodyStyle').value);
    }
    if (document.getElementById('onload_axleType')) {
        selectAxleType(document.getElementById('onload_axleType').value);
    }
    if (document.getElementById('onload_fuelType')) {
        selectFuelType(document.getElementById('onload_fuelType').value);
    }
    if (document.getElementById('onload_transmissionType')) {
        selectTransmissionType(document.getElementById('onload_transmissionType').value);
    }
    if (document.getElementById('onload_searchby')) {
        selectOptionWithValue(getPsInput('searchby'), document.getElementById("onload_searchby").innerHTML);
    }
    if (document.getElementById('onload_suppliertype')) {
        selectOptionWithValue(getPsInput('suppliertype'), document.getElementById("onload_suppliertype").innerHTML);
    }
    if (document.getElementById('onload_refresh')) {
        fastrefresh(document.getElementById('onload_action').innerHTML, document.getElementById('onload_interval').innerHTML);
    }
    if(document.getElementById('onload_norefresh')){
    	fdiv = undefined;
    }
    if (document.getElementById('onload_back')) {
        nullcall = true;
        callServer("'" + document.getElementById('onload_backurl').innerHTML + "'", document.getElementById('onload_backfun').innerHTML);
    }
    if (document.getElementById('bcontrolpanelrefresh')) {
        bcontrolpanelrefresh(document.getElementById('bcontrolpanelid').innerHTML, document.getElementById('bcontrolpanelrefresh').innerHTML);
    }
    if(document.getElementById('plexpandapanelrefresh')){
    	plexpandapanelrefresh(document.getElementById('plexpandapanelid').innerHTML, document.getElementById('plexpandapanelrefresh').innerHTML);
    }
    if(document.getElementById('subrocontrolpanelrefresh')){
    	subrocontrolpanelrefresh(document.getElementById('subrocontrolpanelid').innerHTML, document.getElementById('subrocontrolpanelrefresh').innerHTML);
    }
    if (document.getElementById('bcontrolpanelrefreshdone')) {
        window.clearInterval(srefresh);
    }
    if(document.getElementById('plexpandapanelrefreshdone')){
    	window.clearInterval(srefresh);
    }
    if(document.getElementById('subrocontrolpanelrefreshdone')){
    	window.clearInterval(srefresh);
    }
    if (document.getElementById('pageover')) {
        showPageOver();
    }
}
function bcontrolpanelrefresh(id, interval) {
    var randomcrapiwillpissupon = 'doAjaxAction3(\'bcontrolpanel\',' + id + ')';
    window.clearInterval(srefresh);
    srefresh = window.setInterval(randomcrapiwillpissupon, interval);
}
function plexpandapanelrefresh(id, interval){
	var randomcrapiwillpissupon = 'doAjaxAction3(\'pl_expandapanel\',' + id + ')';
	window.clearInterval(srefresh);
	srefresh = window.setInterval(randomcrapiwillpissupon, interval);
}
function subrocontrolpanelrefresh(id, interval){
	var randomcrapiwillpissupon = 'doAjaxAction3(\'subrocontrolpanel\',' + id + ')';
	window.clearInterval(srefresh);
	srefresh = window.setInterval(randomcrapiwillpissupon, interval);
}
function fastrefresh(action, interval) {
    var params = 'ajax&ajaxpages&action=' + action;
    fdiv = 'reportresults';
    var fun = 'callServerPost(\'/index.jsp\',\'' + params + '\',pageUpdate)';
    window.clearInterval(srefresh);
    srefresh = window.setInterval(fun, interval);
}
function addNotSpecified()
{
    for (i = 0; i < addNotSpecified.arguments.length; i++)
    {
        the_select = getPsInput(addNotSpecified.arguments[i]);
        insertOption(the_select, "Not Specified", -3, 0);
    }
}
//end onload functions
function callBuyerCal(userid, inc, week) {
    var url = '/corejsp/buyer/bpocalendar.jsp?id=' + userid + '&action=bpocalendar&weekoffset=' + week + '&incrementoffset=' + inc;
    callServer3(url, calendarupdate);
}
function callSellerCal(userid, inc, week) {
    var url = '/corejsp/buyer/bpocalendar.jsp?id=' + userid + '&action=spocalendar&weekoffset=' + week + '&incrementoffset=' + inc;
    callServer3(url, calendarupdate);
}
function doAjaxPopOpenTime(action, id, filter) {
    clicked = false;
    timeout = setTimeout("doAjaxPopOpen('" + action + "','" + id + "','" + filter + "')", 500);
}
function setClickedTrue() {
    clicked = true;
}
function doAjaxPopOpen(action, id, filter) {
    var url = '/index.jsp?ajax&action=' + action + '&id=' + id + '&filterid=' + filter;
    if (pid != id) {
        pid = id;
        openaction = action;
        dothishist = true;
        callServer2(url, popuptoWin);
    }
}
function popuptoWin() {
    if (xmlHttp2.readyState != 4) {
        disableLinks();
    }
    if (xmlHttp2.readyState == 4) {
        enableLinks();
        var response = xmlHttp2.responseText;
        var bodytag = document.getElementById('bodytag');
        var me = document.createElement('div');
        me.setAttribute('id', 'popup' + pid);
        me.innerHTML = response;
        me.style.visibility = 'hidden';
        me.style.border = '2px';
        bodytag.appendChild(me);
        if (pid == openelement && me.style.visibility == 'visible') {
            openelement = null;
        }
        if (openelement != null) {
            var op = document.getElementById('popup' + openelement);
            if (window.XMLHttpRequest && !IE7) { // Mozilla, Safari,...
                var parent = op.parentNode;
                parent.removeChild(op);
            } else if (window.ActiveXObject) {
                var parent = op.parentElement;
                parent.removeChild(op);
            }
        }
        if (pid != openelement && me.style.visibility == 'hidden') {
            openelement = pid;
            me.style.visibility = 'visible';
            me.style.width = '100%';
            me.style.position = 'relative';
            if (window.XMLHttpRequest && !IE7) { // Mozilla, Safari,...
                me.style.left = window.scrollX + 100;
                me.style.top = window.scrollY + 175;
                me.style.marginLeft = 0;
                bodytag.style.zIndex = -1;
                me.style.zIndex = 1;
            } else if (IE7) {
                me.style.left = document.body.scrollLeft + 100;
                me.style.top = document.body.scrollTop + 175;
            } else if (window.ActiveXObject) {
                me.style.left = document.body.scrollLeft + 100;
                me.style.top = document.body.scrollTop + 175;
            }
        } else if (me.style.visibility == 'visible') {
            me.style.visibility = 'hidden';
            me.style.position = 'relative';
        }
    }
}
function popup() {
    if (xmlHttp.readyState != 4) {
        disableLinks();
    }
    if (xmlHttp.readyState == 4) {
        disableSelects();
        var response = xmlHttp.responseText;
        var me = document.createElement('div');
        var pink = document.getElementById('MainDataDiv');
        var wat = document.getElementById('wat');
        var gray = document.getElementById('mainparent');
        var blue = document.getElementById('maintable');
        var yellow = document.getElementById('quotesparent');
        var green = document.getElementById('quotes');
        var td = document.getElementById('td_' + openaction + '_' + pid);
        me.setAttribute('id', 'popup' + pid);
        me.innerHTML = response;
        me.style.visibility = 'hidden';
        me.style.border = '2px';
        td.appendChild(me);
        var tab = document.getElementById('table_' + openaction + '_' + pid);
        if (pid == openelement && me.style.visibility == 'visible') {
            openelement = null;
        }
        if (openelement !== null) {
            var op = document.getElementById('popup' + openelement);
            var parent = op.parentElement;
            parent.removeChild(op);
        }
        if (pid != openelement && me.style.visibility == 'hidden') {
            openelement = pid;
            me.style.visibility = 'visible';
            me.style.width = '100%';
            me.style.position = 'relative';
            if (window.XMLHttpRequest && !IE7) { // Mozilla, Safari,...
                //popUpProperties(document.body);
                tab.style.backgroundColor = "#EDEDED";
                if (openaction == 'warranty'){
                	me.style.left = ((td.offsetLeft - me.style.length) - td.offsetWidth) - 350;
                }
                if (openaction == 'pl_warranty'){
                	me.style.left = ((td.offsetLeft - me.style.length) - td.offsetWidth) - 350;
                }
                if (openaction == 'quote') {
                    me.style.left = (((td.offsetLeft - me.style.length) - td.offsetWidth) - 400) - td.offsetWidth;
                    var totalheight = pink.offsetTop + wat.offsetTop + gray.offsetTop + blue.offsetTop + yellow.offsetTop + green.offsetTop + td.offsetTop;
                    var popupbottom = (totalheight + me.offsetHeight);
                    var pinkbottom = (pink.offsetTop + pink.offsetHeight);
                    var bluebottom = (pink.offsetTop + gray.offsetTop + blue.offsetTop + blue.offsetHeight);
                    if (popupbottom > pinkbottom) {
                        me.style.top = ((totalheight - td.offsetHeight) - tab.offsetHeight);
                    }
                }
                if (openaction == 'pl_quote') {
                    me.style.left = (((td.offsetLeft - me.style.length) - td.offsetWidth) - 400) - td.offsetWidth;
                    var totalheight = pink.offsetTop + wat.offsetTop + gray.offsetTop + blue.offsetTop + yellow.offsetTop + green.offsetTop + td.offsetTop;
                    var popupbottom = (totalheight + me.offsetHeight);
                    var pinkbottom = (pink.offsetTop + pink.offsetHeight);
                    var bluebottom = (pink.offsetTop + gray.offsetTop + blue.offsetTop + blue.offsetHeight);
                    if (popupbottom > pinkbottom) {
                        me.style.top = ((totalheight - td.offsetHeight) - tab.offsetHeight);
                    }
                }
            } else if (window.ActiveXObject) {
                var left = td.offsetLeft - me.offsetWidth;
                if (openaction == 'warranty') {
                    me.style.left = td.offsetLeft - me.offsetWidth;
                    var totalheight = pink.offsetTop + wat.offsetTop + gray.offsetTop + blue.offsetTop + yellow.offsetTop + green.offsetTop + td.offsetTop;
                    var popupbottom = (totalheight + me.offsetHeight);
                    var pinkbottom = (pink.offsetTop + pink.offsetHeight);
                    var bluebottom = (pink.offsetTop + gray.offsetTop + blue.offsetTop + blue.offsetHeight);
                    if (popupbottom > pinkbottom) {
                        me.style.top = ((totalheight - td.offsetHeight) - tab.offsetHeight);
                    }
                }
                if (openaction == 'pl_warranty') {
                    me.style.left = td.offsetLeft - me.offsetWidth;
                    var totalheight = pink.offsetTop + wat.offsetTop + gray.offsetTop + blue.offsetTop + yellow.offsetTop + green.offsetTop + td.offsetTop;
                    var popupbottom = (totalheight + me.offsetHeight);
                    var pinkbottom = (pink.offsetTop + pink.offsetHeight);
                    var bluebottom = (pink.offsetTop + gray.offsetTop + blue.offsetTop + blue.offsetHeight);
                    if (popupbottom > pinkbottom) {
                        me.style.top = ((totalheight - td.offsetHeight) - tab.offsetHeight);
                    }
                }
                if (openaction == 'quote') {
                    me.style.left = td.offsetLeft - me.offsetWidth;
                    var totalheight = pink.offsetTop + wat.offsetTop + gray.offsetTop + blue.offsetTop + yellow.offsetTop + green.offsetTop + td.offsetTop;
                    var popupbottom = (totalheight + me.offsetHeight);
                    var pinkbottom = (pink.offsetTop + pink.offsetHeight);
                    var bluebottom = (pink.offsetTop + gray.offsetTop + blue.offsetTop + blue.offsetHeight);
                    if (popupbottom > pinkbottom) {
                        me.style.top = ((totalheight - td.offsetHeight) - tab.offsetHeight);
                    }
                }
                if (openaction == 'pl_quote') {
                    me.style.left = td.offsetLeft - me.offsetWidth;
                    var totalheight = pink.offsetTop + wat.offsetTop + gray.offsetTop + blue.offsetTop + yellow.offsetTop + green.offsetTop + td.offsetTop;
                    var popupbottom = (totalheight + me.offsetHeight);
                    var pinkbottom = (pink.offsetTop + pink.offsetHeight);
                    var bluebottom = (pink.offsetTop + gray.offsetTop + blue.offsetTop + blue.offsetHeight);
                    if (popupbottom > pinkbottom) {
                        me.style.top = ((totalheight - td.offsetHeight) - tab.offsetHeight);
                    }
                }
            }
        } else if (me.style.visibility == 'visible') {
            me.style.visibility = 'hidden';
            me.style.position = 'relative';
        }
    }
}
function closePop(id) {
    try {
   		if (!clicked) {
           	clearTimeout(timeout);
           	var main = document.getElementById('bodytag');
           	main.removeChild(document.getElementById('popup' + id));
           	openelement = undefined;
           	pid = undefined;
       	}

    }
    catch(e3) {

    }
}
function closePopClicked(id) {
    try {
        /*if (!clicked){
            clearTimeout(timeout);
            var main = document.getElementById('bodytag');
            main.removeChild(document.getElementById('popup'+id));
            openelement=undefined;
            pid=undefined;
        }else{*/
        var main = document.getElementById('bodytag');
        main.removeChild(document.getElementById('popup' + id));
        openelement = undefined;
        pid = undefined;
        //}

    }
    catch(e3) {

    }
}
function closePopAnyway(id) {
    try {
        clearTimeout(timeout);
        var main = document.getElementById('bodytag');
        main.removeChild(document.getElementById('popup' + id));
        openelement = undefined;
        pid = undefined;
    }
    catch(e3) {
    }
}
function disableSelects() {
    var selects = document.getElementsByTagName('select');
    for (var i = 0; i < selects.length; i++) {
        selects[i].style.visibility = 'hidden';
    }
}
function setOptionsWithKeys(the_select, the_array, the_key_array)
{
    beg = 0;
    var calee = arguments.callee.caller;
    if (!the_select.options) {
        the_select = document.getElementById(the_select[0].id);
    }
    the_select.options.length = the_array.length + beg;
    for (loop = beg; loop < the_array.length + beg; loop++)
    {
        the_select.options[loop].text = the_array[loop - beg];
        the_select.options[loop].value = the_key_array[loop - beg];
    }
}
function getPsInput(input_name) {
    return eval('window.document.ps.' + input_name);
}
function insertOption(the_select, the_text, the_value, ind, additional)
{
    try {
        if (!the_select.options) {
            the_select = document.getElementById(the_select[0].id);
        }
        if (ind == -1)
        {
            ind = the_select.options.length;
        }
        the_select.options.length += 1;
        for (loop = the_select.options.length - 1; loop > ind; loop--)
        {
            the_select.options[loop].text = the_select.options[loop - 1].text;
            the_select.options[loop].value = the_select.options[loop - 1].value;
        }
        the_select.options[ind].text = the_text;
        the_select.options[ind].value = the_value;
        if (additional)
        {
            i = addOptionsTo.length;
            addOptionsTo[i] = the_select.name;
            addOptionsText[i] = the_text;
            addOptionsValue[i] = the_value;
            addOptionsAt[i] = ind;
            addOptionsTo.length++;
        }
    } catch(e) {
    }
}
function isOther(the_name) {
    the_selection = getPsInput(the_name);
    the_span = eval("window.document." + the_name + "S");
    if (!the_span)
        return 0;
    if (the_selection.value == "-1") {
        the_span.innerHTML = "<input name=" + the_name + "V type='text' size='20'/>";
        return 1;
    } else {
        the_span.innerHTML = "";
        return 0;
    }
}
function addAdditionalOptions(select_name)
{
    for (i = 0; i < addOptionsTo.length; i++)
    {
        if (select_name == addOptionsTo[i])
        {
            insertOption(getPsInput(select_name), addOptionsText[i], addOptionsValue[i], addOptionsAt[i]);
        }
    }
}
function addAny()
{
    for (i = 0; i < addAny.arguments.length; i++)
    {
        the_select = getPsInput(addAny.arguments[i]);
        if (!the_select.options) {
            the_select = document.getElementById(the_select[0].id);
        }
        if (!the_select.options[0] || the_select.options[0].value != -2)
        {
            insertOption(the_select, "Any", -2, 0, true);
        }
    }
}
function clearAdditionalOptions()
{
    addOptionsTo.length = 0;
}
function setOptionText(the_select, the_array)
{
    if (!the_select.options) {
        the_select = document.getElementById(the_select[0].id);
    }
    the_select.options.length = the_array.length;
    for (loop = 0; loop < the_array.length; loop++)
    {
        the_select.options[loop].text = the_array[loop];
    }
}
function addDefault()
{
    var title = addDefault.arguments[0];
    var value = addDefault.arguments[1];
    for (i = 2; i < addDefault.arguments.length; i++)
    {
        the_select = getPsInput(addDefault.arguments[i]);
        insertOption(the_select, title, value, 0);
    }
}
function roleChanged(select_name)
{
    var newrole = 0;
    if (getPsInput('setIArole' + select_name).checked) {
        newrole |= 1;
    } else {
        newrole &= 255 ^ 1;
    }
    if (getPsInput('setBodyShoprole' + select_name).checked) {
        newrole |= 2;
    } else {
        newrole &= 255 ^ 2;
    }
    if (getPsInput('setAdminrole' + select_name).checked) {
        newrole |= 4;
    } else {
        newrole &= 255 ^ 4;
    }
    if (getPsInput('setControllerrole' + select_name).checked) {
        newrole |= 16;
    } else {
        newrole &= 255 ^ 16;
    }
    getPsInput('roleset' + select_name).value = newrole;
}
function selectOptionWithValue(the_select, the_value)
{
    try {
        if (!the_select.options) {
            the_select = document.getElementById(the_select[0].id);
        }
        for (loop = 0; loop < the_select.options.length; loop++)
        {
            if (the_select.options[loop].value == the_value)
            {
                the_select.selectedIndex = loop;
                return;
            }
        }
        the_select.selectedIndex = 0;
    } catch(e) {
    }
}
function clearInput(input_name) {
    eval('window.document.ps.' + input_name).value = undefined;
}

var i
function prog()
{
    try {
        document.getElementById("d1").innerHTML = "";
        document.getElementById("d2").style.width = 0;
        i = 0;
        timedProg();
    } catch(e) {
    }
}

function timedProg()
{
    try {
        var time;
        if (i <= (500))
        {
            var j = 0;
            if (i > 40) {
                document.getElementById("d1").innerHTML = 'Working...';
            }
            if (document.getElementById("d2") != null) {
                document.getElementById("d2").style.width = i + "px";
            } else {
                j = 101;
                i = 501;
            }
            // simulates some lengthy processing

            while (j <= 100)
                j++;
            time = setTimeout("timedProg();", 10);
            i++;
        }
        if (i == 501 && xmlHttp.readyState != 4)i = 0;
    } catch(e) {
    }
}
var letcount = 0;
function timedProg2()
{
    var time;
    if (i <= (500))
    {
        var j = 0;
        if (i > 40) {
            //document.getElementById("d1").innerHTML=parseInt(i/5)+"%";
            var intext = document.getElementById("d1").innerTEXT;
            for (letcount; letcount < intext.length; letcount++) {
                intext = intext + letcount;
            }
        }
        if (document.getElementById("d2") != null) {
            document.getElementById("d2").style.width = i + "px";
        } else {
            j = 101;
            i = 501;
        }
        // simulates some lengthy processing

        while (j <= 100)
            j++;
        time = setTimeout("timedProg2();", 10);
        i++;
    }
    if (i == 501 && xmlHttp.readyState != 4)i = 0;
}
function quotepopup(company, address, phone, contact, email) {
    myWin = open("", "displayWindow", "toolbar=0,menubar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,width=400,height=400");
    myWin.document.open();
    myWin.document.write('<html>' + '<body>');
    myWin.document.write('<table>');
    myWin.document.write('<tr>' + '<td>Company:&#160;</td>' + '<td>' + company + '</td>' + '</tr>');
    myWin.document.write('<tr>' + '<td>Address:&#160;</td>' + '<td>' + address + '</td>' + '</tr>');
    myWin.document.write('<tr>' + '<td>Phone:&#160;</td>' + '<td>' + phone + '</td>' + '</tr>');
    myWin.document.write('<tr>' + '<td>Contact:&#160;</td>' + '<td>' + contact + '</td>' + '</tr>');
    myWin.document.write('<tr>' + '<td>Email:&#160;</td>' + '<td>' + email + '</td>' + '</tr>');
    myWin.document.write('</table>');
    myWin.document.write('</body>' + '</html>');
    myWin.focus();
    myWin.document.close();
}
function quotepopup2(company, street1, street2, city, state, zip, phone, contact, email){
	myWin = open("","displayWindow","toolbar=0,menubar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,width=400,height=400");
	myWin.document.open();
	myWin.document.write('<html>' + '<body>');
	myWin.document.write('<table>');
	myWin.document.write('<tr><td>Company:&#160;</td><td>'+company+'</td></tr>');
	myWin.document.write('<tr>');
	myWin.document.write('<td>');
	myWin.document.write('Address:&#160;');
	myWin.document.write('</td>');
	myWin.document.write('<td>');
	if(street1 != ""){
		myWin.document.write(street1);
	}else if(street2 != ""){
		myWin.document.write(street2);
	}else{
		myWin.document.write('&#160;')
	}
	myWin.document.write('</td>');
	myWin.document.write('</tr>');
	if(street1 != "" && street2 != ""){
		myWin.document.write('<tr>');
		myWin.document.write('<td>&#160;</td>');
		myWin.document.write('<td>'+street2+'</td>');
		myWin.document.write('</tr>');
	}
	myWin.document.write('<tr><td>&#160;</td><td>'+city+',&#160;'+state+'&#160;'+zip+'</td></tr>');
	myWin.document.write('<tr><td>Phone:&#160;</td><td>'+phone+'</td></tr>');
	myWin.document.write('<tr><td>Contact:&#160;</td><td>'+contact+'</td></tr>');
	myWin.document.write('<tr><td>Email:&#160;</td><td>'+email+'</td></tr>');
	myWin.document.write('</table></body></html>');
	myWin.focus();
	myWin.document.close();
}
var calid;
function newCal(anch, id) {
    var varname = new CalendarPopup();
    calid = id;
    varname.showNavigationDropdowns();
    var returnfunc = 'showDate';
    varname.setReturnFunction(returnfunc);
    varname.showCalendar(anch);
}

//added for bsetpodelivery.xsl and 
function newCalOneYear(anch, id) {
    var date_today = new Date();
    var date_tom = new Date(date_today.getTime()+24*60*60*1000); //add 1 day
    var date_yes = new Date(date_today.getTime()-24*60*60*1000); //sub 1 day
    var tmonth = date_tom.getMonth() + 1;
    var tday = date_tom.getDate();
    var tyear = date_tom.getFullYear();
    var ymonth = date_yes.getMonth() + 1;
    var yday = date_yes.getDate();
    var yyear = date_yes.getFullYear() - 1;
    var date_yest_str = ymonth + "/" + yday + "/" + date_yes.getFullYear();
    var date_future = tmonth + "/" + tday + "/" + tyear; //cals not allowed to pick dates in the future
    var date_year_ago = ymonth + "/" + yday + "/" + yyear; //most cals restricted to one year ago
    var yfyear = date_tom.getFullYear() + 1;
    var date_year_future = tmonth + "/" + tday + "/" + yfyear; //PO amended delivery date goes from today to 1 year from now
    var date_subro = "06/30/09"; //subro restricted to no earlier than 7/1/09 
    var varname = new CalendarPopup();
    
    calid = id;
    varname.showNavigationDropdowns();
    varname.addDisabledDates(null, date_yest_str);
    varname.addDisabledDates(date_year_future, null);
    var returnfunc = 'showDate';
    varname.setReturnFunction(returnfunc);
    varname.showCalendar(anch);
}
function showDate(y, m, d) {
    /*  NOTE - wasn't working in firefox... IE code worked in both
    if (IE) {
        document.getElementById(calid).value = m + '/' + d + '/' + y;
    } else {
        document.forms[0].eval(calid).value = m + '/' + d + '/' + y;
    }*/
    document.getElementById(calid).value = m + '/' + d + '/' + y;
    the_span = document.getElementById(calid);
    if (the_span != undefined && the_span != null) {
        var date_var = document.getElementById(calid).value;
        if (date_var.length > 0) {
            document.getElementById('span' + calid).innerHTML = date_var;
        }
    }
}
function checkall(prefix) {
    //this functions checks all the input checkboxes for the given prefix
    var inputs = document.getElementsByTagName('input');
    var i;
    for (i = 0; i < inputs.length; i++) {
        var st = inputs[i].name.indexOf(prefix);
        if (inputs[i].type == 'checkbox' && st != -1) {
            if (!inputs[i].checked)   {
                inputs[i].checked = true;
            }
        }
    }
}

function endcheckall()  {
    document.getElementById('selectall').checked = false;
}
function flipchecks(prefix) {
    //this function checkes unchecked boxes and uncheks checked boxes
    var inputs = document.getElementsByTagName('input');
    var i;
    for (i = 0; i < inputs.length; i++) {
        var st = inputs[i].name.indexOf(prefix);
        if (inputs[i].type == 'checkbox' && st != -1)   {
            if (inputs[i].checked)    {
                inputs[i].checked = false;
            }
            else if (!inputs[i].checked)   {
                inputs[i].checked = true;
            }
        }
    }
}
function uncheckall(prefix) {
    var inputs = document.getElementsByTagName('input');
    var i;
    for (i = 0; i < inputs.length; i++) {
        var st = inputs[i].name.indexOf(prefix);
        if (inputs[i].checked && st != -1)    {
            inputs[i].checked = false;
        }
    }
}
function userAdded(uid)
{
    the_checkbox = getPsInput('add' + uid);
    if (!the_checkbox)
        return;
    iarole = getPsInput('cfinduser_iarole' + uid);
    bsrole = getPsInput('cfinduser_bsrole' + uid);
    adminrole = getPsInput('cfinduser_adminrole' + uid);
    iarole.disabled = bsrole.disabled = adminrole.disabled = the_checkbox.checked ? undefined : 'true';
    iarole.enabled = bsrole.enabled = adminrole.enabled = the_checkbox.checked ? 'true' : undefined;
}
function rolesetChanged(uid) {
    var newrole = 0;
    if (getPsInput('cfinduser_iarole' + uid).checked)
        newrole |= 1;
    else
        newrole &= 255 ^ 1;
    if (getPsInput('cfinduser_bsrole' + uid).checked)
        newrole |= 2;
    else
        newrole &= 255 ^ 2;
    if (getPsInput('cfinduser_adminrole' + uid).checked)
        newrole |= 4;
    else
        newrole &= 255 ^ 4;
    getPsInput('setrole' + uid).value = newrole;
}

function changeSelect(id) {
    var re = document.getElementById(id);
    re.innerHTML = '';
    var name = id.substring(0, id.indexOf("_"));
    var newres = '<select name="' + name + '"><option value="-1">Select Year Offset</option><option value="1">1 year old</option>';
    newres = newres + '<option value="2">2 years old</option><option value="3">3 years old</option><option value="4">4 years old</option><option value="5">5 years old</option><option value="5">5 years old</option><option value="6">6 years old</option><option value="0">Exclude</option></select>';
    re.innerHTML = newres;

}
function confirmrules(id, value, ch) {
    var sel = document.getElementById(id);
    if (ch == 'cl' && !document.getElementById('same').checked) {
        document.getElementById("addoffset").disabled = false;
    } else {
        for (var i = 0; i < sel.options.length; i++) {
            if (sel.options[i].selected) {
                if (sel.options[i].value == 0) {
                    if (ch == "ch") {
                        if (document.getElementById("addoffset").disabled)document.getElementById("addoffset").disabled = false;
                    }
                    if (ch == 'cl')document.getElementById("addoffset").disabled = true;
                } else {
                    document.getElementById('same').checked = false;
                    if (document.getElementById("addoffset").disabled)document.getElementById("addoffset").disabled = false;
                    if (ch == ("cl")) {
                        //alert("Only recycled parts can be Same Year or Newer");
                    }
                }
            }
        }
    }
}

function toggleDiv(divid) {
    var d = document.getElementById(divid)
    var ch = true;
    if (d.style.visibility == '')d.style.visibility = 'visible';
    if (d.style.visibility != 'hidden' && ch) {
        d.style.visibility = 'hidden';
        d.position = 'absolute';
        d.width = "100%";
        ch = false;
    }
    if (d.style.visibility != 'visible' && ch) {
        d.style.visibility = 'visible';
        d.position = 'relative';
        ch = false;
    }
}
function MM_preloadImages() { //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i,j = d.MM_p.length,a = MM_preloadImages.arguments;
        for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) {
                d.MM_p[j] = new Image;
                d.MM_p[j++].src = a[i];
            }
    }
}
/* Begin rdcs*/
var clientrefresh = false;
var logint;
function rdcslog(url, divid) {
    var u;
    sdiv = divid;
    if (clientrefresh) {
        clientrefresh = false;
        u = url;
    } else {
        sfun = 'rdcslog(\'' + url + '\',\'' + divid + '\')';
        window.setTimeout(sfun, 30000);
        u = url + '&request';
        clientrefresh = true;
    }
    callServer(u, mainData);
}
function rdcssettings(url, divid) {
    var u;
    sdiv = divid;
    if (clientrefresh) {
        clientrefresh = false;
        u = url + '&retrieve';
    } else {
        sfun = 'rdcssettings(\'' + url + '\',\'' + divid + '\')';
        window.setTimeout(sfun, 30000);
        u = url + '&request';
        clientrefresh = true;
    }
    callServer(u, mainData);
}
var sminterval;
function slave() {
    sfun = 'slaveterm(\'/corejsp/rdc/termtester.jsp?getvt\',\'screenthree\')';
    window.setTimeout(sfun, 15000);
}
function slaveterm(url, divid, interval) {
    mdiv = divid;
    sfun = 'slaveterm(\'/corejsp/rdc/termtester.jsp?getvt\',\'screenthree\')';
    if (document.getElementById('interval')) {
        sminterval = document.getElementById('interval').value;
    }
    if (sminterval == undefined)sminterval = 0;
    callServer2(url, mainDataMgr2);
}
function monkeysend() {
    var url = '/corejsp/rdc/monkeysend.jsp?send=' + document.getElementById('monkeysendfield').value;
    mdiv = 'commandnotify';
    if (document.getElementById('monkeysendfield').value != '' && document.getElementById('monkeysendfield').value != undefined) {
        document.getElementById('intervalid').innerHTML = sminterval;
        window.setTimeout(sfun, sminterval);
        callServer(url, mainDataMgr);
    } else {
        document.getElementById('commandnotify').innerHTML = 'Monkey need banana...enter text or command';
    }
}
function monkeysendreturn() {
    var url = '/corejsp/rdc/monkeysend.jsp?cr&send=' + document.getElementById('monkeysendfield').value;
    mdiv = 'commandnotify';
    if (document.getElementById('monkeysendfield').value != '' && document.getElementById('monkeysendfield').value != undefined) {
        document.getElementById('intervalid').innerHTML = sminterval;
        window.setTimeout(sfun, sminterval);
        callServer(url, mainDataMgr);
    } else {
        document.getElementById('commandnotify').innerHTML = 'Monkey need banana...enter text or command';
    }
}
function sendFalseHIC(url, divid) {
    var u;
    sdiv = divid;
    if (clientrefresh) {
        clientrefresh = false;
        u = url + '&retrieve';
    } else {
        sfun = 'rdcssettings(\'' + url + '\',\'' + divid + '\')';
        window.setTimeout(sfun, 30000);
        u = url + '&hic=' + document.getElementById('hic').value + '&side=' + document.getElementById('side').value + '&request';
        clientrefresh = true;
    }
    callServer(u, mainData);
}
function rdcshic(url, divid) {
    mdiv = divid;
    callServer(url, mainDataMgr);
}
function switchBG(id) {
    var div = document.getElementById(id);
    if (div.style.backgroundColor == '#000000') {
        div.style.backgroundColor = 'red';
    } else if (div.style.backgroundColor == 'red') {
        div.style.backgroundColor = '#000000';
    }

}
var countdown;
var downdiv;
var downintid;
var countdownstmt;

function countDown(start, divid) {
    countdown = start;
    downdiv = divid;
    downintid = setInterval(dec, 1000);
}

function dec() {
    --countdown;
    if (countdown == 0) {
        clearInterval(downintid);
        document.getElementById(downdiv).innerHTML = 'Count down complete';
    } else {
        document.getElementById(downdiv).innerHTML = countdown;
    }
}
var openmenu = '';

function showEMS(id) {
    var me = document.getElementById(id);
    var img = document.getElementById('img' + id);
    openmenu = id;
    me.style.visibility = 'visible';
    me.style.width = '100%';
    me.style.position = 'relative';
    img.src = '/images/minussign.gif';
}
function submenu(menu, pos) {
    if (openmenu.length == 0)openmenu = document.getElementById('openmenu').value;
    var me = document.getElementById(menu);
    var p = document.getElementById(pos);
    var tab = document.getElementById('tab' + menu);
    var img = document.getElementById('img' + menu);
    if (menu == openmenu && me.style.visibility == 'visible') {
        openmenu = '';
    } else if (menu == openmenu && me.style.visibility == 'hidden') {
        openmenu = '';
    }
    if (openmenu != '') {
        var op = document.getElementById(openmenu);
        var opimg = document.getElementById('img' + openmenu);
        op.style.visibility = 'hidden';
        op.style.position = 'absolute';
        opimg.src = '/images/plussign.gif';
        me.style.position = 'absolute';
    }
    if (menu != openmenu && me.style.visibility == 'hidden') {
        openmenu = menu;
        me.style.visibility = 'visible';
        me.style.width = '100%';
        me.style.position = 'relative';
        img.src = '/images/minussign.gif';
    } else if (me.style.visibility == 'visible') {
        me.style.visibility = 'hidden';
        img.src = '/images/plussign.gif';
        me.style.position = 'absolute';
    }
}




/* End rdcs*/
function changeIt(id) {
    var it = document.getElementById(id);
    //popUpProperties(it);
    var par = it.parentNode;
    var val = it.value;
    if (val != undefined && val != '') {
        val = val.substring(0, val.lastIndexOf("\\") + 1);
    } else if (val == undefined) {
        val = '';
    }
    var neww = document.createElement('input');
    neww.setAttribute('type', 'text');
    neww.setAttribute('name', id);
    neww.setAttribute('id', id);
    neww.setAttribute('value', val);
    par.replaceChild(neww, it);
}

function changeThem() {
    changeIt('adp');
    changeIt('ccc');
    changeIt('compest');
    changeIt('mitchell');
    var update = document.createElement('input');
    update.setAttribute('type', 'hidden');
    update.setAttribute('name', 'update');
    update.setAttribute('value', 'yes');
    document.forms.ps.appendChild(update);
}
function toggle(e) {
    if (e.style.display == "none") {
        e.style.display = "";
    } else {
        e.style.display = "none";
    }
}

function toggleimg(imgs, e, e1) {
    if (imgs.src == e) imgs.src = e1;
    else
        imgs.src = e;
}

function switchCSS(id) {
    if (id == 'pn') {
        if(document.getElementById('subrogation') != null){
        	document.getElementById('subrogation').setAttribute('className', 'topbar');
        }
        if(document.getElementById('reporting') != null){
        	document.getElementById('reporting').setAttribute('className', 'topbar');
        }
        if(document.getElementById(id) != null){
        	document.getElementById(id).setAttribute('className', 'topbarselected');
        }
        if(document.getElementById('profile') != null){
        	document.getElementById('profile').setAttribute('className', 'topbar');
        }
    }
    if (id == 'profile') {
    	if(document.getElementById('subrogation') != null){
        	document.getElementById('subrogation').setAttribute('className', 'topbar');
        }
        if(document.getElementById('reporting') != null){
        	document.getElementById('reporting').setAttribute('className', 'topbar');
        }
        if(document.getElementById('pn') != null){
        	document.getElementById('pn').setAttribute('className', 'topbar');
        }
        if(document.getElementById(id) != null){
        	document.getElementById(id).setAttribute('className', 'topbarselected');
        }
    }
    if (id == 'reporting'){
    	if(document.getElementById('subrogation') != null){
        	document.getElementById('subrogation').setAttribute('className', 'topbar');
        }
    	if(document.getElementById(id) != null){
        	document.getElementById(id).setAttribute('className', 'topbarselected');
        }
        if(document.getElementById('pn') != null){
        	document.getElementById('pn').setAttribute('className', 'topbar');
        }
        if(document.getElementById('profile') != null){
        	document.getElementById('profile').setAttribute('className', 'topbar');
        }
    }
    if (id == 'subrogation'){
    	if(document.getElementById(id) != null){
        	document.getElementById(id).setAttribute('className', 'topbarselected');
        }
    	if(document.getElementById('reporting') != null){
        	document.getElementById('reporting').setAttribute('className', 'topbar');
        }
    	if(document.getElementById('pn') != null){
        	document.getElementById('pn').setAttribute('className', 'topbar');
        }
        if(document.getElementById('profile') != null){
        	document.getElementById('profile').setAttribute('className', 'topbar');
        }
    }
}

var tempX = 0;
var tempY = 0;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
//document.onmousemove = getMouseXY;
var floating;
var xoff;
var yoff;
var vx = 0;
var vy = 0;
var moving = false;
function moveit(id) {
    if (moving) {
        pin();
        moving = false;
    } else {
        move(id);
        moving = true;
    }
}
function move(id) {
    floating = document.getElementById(id);
    document.onmousemove = getMouseXY;

    //popUpProperties(floating.style);
}
function locateOffset() {
    if (xoff == undefined && yoff == undefined) {
        xoff = tempX - (floating.style.left == undefined || floating.style.left.length == 0 ? 0 : parseInt(floating.style.left));
        yoff = tempY - (floating.style.top == undefined || floating.style.top.length == 0 ? 0 : parseInt(floating.style.top));
    }
}
function getMouseXY(e) {
    if (IE) { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft
        tempY = event.clientY + document.body.scrollTop
    } else {  // grab the x-y pos.s if browser is NS

        tempX = e.pageX
        tempY = e.pageY
    }
    if (tempX < 0) {
        tempX = 0
    }
    if (tempY < 0) {
        tempY = 0
    }
    place();
    return true
}
function pin() {
    floating.style.position = 'relative';
    var offleft = floating.offsetWidth / 2;
    //offtop is the distance from top margin to the vertical half way point of the element
    var offtop = floating.offsetHeight / 2;
    var x = (tempX - xoff);
    var y = (tempY - yoff);
    floating.style.left = x;
    floating.style.top = y;
    floating = undefined;
    xoff = undefined;
    yoff = undefined;
    //document.onmousemove = "";
}
function place() {
    if (floating != undefined) {
        floating.style.position = 'relative';
        locateOffset();
        var x = (tempX - xoff);
        var y = (tempY - yoff);
        vx = xoff;
        vy = yoff;
        floating.style.left = x;
        floating.style.top = y;
    }
}
function positionI() {
    var height = IE ? document.body.clientHeight : window.innerHeight;
    var width = IE ? document.body.clientWidth : window.innerWidth;
    var chatdiv = document.getElementById('mainchatdiv');
    if (chatdiv != undefined) {
        var chatcenterx = (chatdiv.offsetWidth / 2);
        var chatcentery = (chatdiv.offsetHeight / 2);		
        chatdiv.style.left = ((width / 2) - chatcenterx);
        chatdiv.style.top = ((height / 2) - chatcentery);
    }
}
function detectWindow() {
    try {
        var height = IE ? document.body.clientHeight : window.innerHeight;
        var width = IE ? document.body.clientWidth : window.innerWidth;
        document.getElementById('bodytable').setAttribute('width', width);
        document.getElementById('bodytable').setAttribute('height', height);
        document.getElementById('bodyleft').setAttribute('height', height);
        document.getElementById('righttable').setAttribute('height', height);
        document.getElementById('righttabletd').setAttribute('height', height);
        document.getElementById('itptd').setAttribute('height', height - 75);
        document.getElementById('itptd').setAttribute('width', width - 100);
        positionI();
    } catch(e) {
    }
}
function setDiv(div) {
    sdiv = div;
}

function doQuoteRefresh(id, type) {
    setDiv(id);
    doAjaxAction3('rfqquoterefresh', id);
    if (type == 0) {
        //type zero returns for control panel
        setTimeout('setDiv(' + id + ');doAjaxAction3("rfqquoterefreshdisplay",' + id + ')', 120000);
    }
    else if (type == 1) {
        //type 1 returns for expand a panel
        setTimeout('setDiv(' + id + ');doAjaxAction3("rfqquoterefreshdisplayexpand",' + id + ')', 120000);
    }
}

function doClaimRefresh(id) {
    setDiv(id);
    doAjaxAction3('claimquoterefresh', id);
    setTimeout('setDiv(' + id + ');doAjaxAction3("claimquoterefreshdisplay",' + id + ')', 120000);
}

function confirmDelete(action, message) {
    if (window.confirm(message)) {
        append('delete', '0');
        readFormActionPost(action);
    }
}
function aqlocations(aqtype, div, selectname) {
    dothishist = true;
    var action = 'aqlocations';
    sdiv = div;
    var url = '/index.jsp?ajax=1&select=1&action=' + action + '&aqtype=' + aqtype + '&selectname=' + selectname;
    callServer(url, mainData);
}
function changeTiers(query, div) {
    dothishist = true;
    sdiv = div;
    var url = '/index.jsp?' + query;
    callServer(url, mainData);
}
function uncheckOthers(id) {
    var good = document.getElementById(id);
    var rfqid = id.substring(0, id.indexOf("_"));
    var form = document.ps.elements;
    //alert("form:: " + form);
    for (var i = 0; i < form.length; i++) {
        if (form[i].type == 'checkbox') {
            if (form[i].checked) {
                if (form[i].id.substring(0, form[i].id.indexOf("_")) == rfqid) {
                    if (form[i].id != good.id) {
                        form[i].checked = false;
                    }
                }
            }
        }
    }
}

function uncheckOthers2(id) {
	var good = document.getElementById(id);
	var rfqid = id.substring(0, id.indexOf("_"));
    var inputs = document.getElementsByTagName('input');
    for (var i = 0; i < inputs.length; i++) {
    	if(inputs[i].type == 'checkbox'){
    		if (inputs[i].checked){
    			if (inputs[i].id.substring(0, inputs[i].id.indexOf("_")) == rfqid) {
    				if (inputs[i].id != good.id){
    					inputs[i].checked = false;
    				}
    			}
    		}
    	}
    }
}

function uncheckOthers3(id,n){
	var good = document.getElementById(id);
	var type = id.substring(0, id.indexOf("_"));
	var prerfq = id.substring(id.indexOf("_") + 1);
	var rfqid = prerfq.substring(0, prerfq.indexOf("_"));
	var form = document.ps.elements;
	for(var i = 0; i < form.length; i++){
		if(form[i].type == 'checkbox'){
			if(form[i].checked){
				if(form[i].id.substring(0, id.indexOf("_")) == type){
					var cbrfqid = form[i].id.substring(form[i].id.indexOf("_") + 1);
					var rfqid2 = cbrfqid.substring(0, cbrfqid.indexOf("_"));
					if(rfqid == rfqid2){
						if(form[i].id != good.id){
							form[i].checked = false;
						}
					}
				}
			}
		}
	}
}


function makeinvisblevisible(id, val) {
    //alert("ID " + id);
    var obj = document.getElementById(id);
    //alert("Visible? " + obj.style.visibility);
    //alert('Value ' + val);
    if (val != 'Other' && obj.style.visibility == 'visible') {
        //alert('here');
        obj.style.visibility = 'hidden';
    }
    else if (val == 'Other') {
        //alert('there999');
        obj.style.visibility = 'visible';
    }
    //alert("Visible? " + obj.style.visibility);
}

function makevisible(id) {
    //alert('ID ' + id);
    var obj = document.getElementById(id);
    //alert("Visible? " + obj.style.visibility);
    if (obj.style.visibility == 'hidden') {
        obj.style.visibility = 'visible';
    }
}

function ajaxclearinput(id) {
    document.getElementById(id).value = "";
}

function changevisibility(id1, id2, id3) {
    var obj1 = document.getElementById(id1);
    if (obj1.style.visibility == 'visible') {
        //alert('should be hidden now');
        obj1.style.visibility = 'hidden';
        obj1.value = "";
    }
    else {
        //alert('should be visible now');
        obj1.style.visibility = 'visible';
    }

    var obj2 = document.getElementById(id2);
    if (obj2.style.visibility == 'visible') {
        obj2.style.visibility = 'hidden';
        obj2.value = "";
    }
    else {
        obj2.style.visibility = 'visible';
    }
    var obj3 = document.getElementById(id3);
    if (obj3.style.visibility == 'visible') {
        obj3.style.visibility = 'hidden';
        obj3.value = "";
    }
    else {
        obj3.style.visibility = 'visible';
    }
}


function changenestedvisibility() {
    var form = document.ps.elements;
    for (var i = 0; i < form.length; i++) {
        if (form[i].name.substring(0, 4) == 'hide') {
            if (form[i].visibility == 'hidden') {
                form[i].visibility = 'visible';
            }
            else {
                form[i].visibilty = 'hidden';
            }
        }
    }
}
/*function sendFalseHIC(yard, divid){
    var url='/index.jsp?action=getresponses&yard='+yard+'&request=&hic='+document.getElementById('hic').value+'&side='+document.getElementById('side').value;
    mdiv = divid;
     callServer(url,mainDataMgr);
     var url2 = '/index.jsp?action=getresponses&retrieve=&yard='+yard;
        sfun = 'rdcshic(\''+url2+'\',\''+divid+'\')';
        window.setTimeout(sfun,30000);
}*/
// Page Over
function showPageOver(){
    var pageOver = document.getElementById("pageOverContent");
    var pageOverBackground = document.getElementById("pageOverBackground");
    var resultsdiv = document.getElementById("resultsdiv");
    for(var i = 0; i < resultsdiv.getElementsByTagName("a").length; i++){
       if(pageOver != null){
         if(pageOver.getElementsByTagName("a")[i] != resultsdiv.getElementsByTagName("a")[i]){
             disableLink(resultsdiv.getElementsByTagName("a")[i]);
         }
       }
    }
    if(pageOverBackground != null){
	    if(navigator.appName != "Microsoft Internet Explorer"){
	        pageOverBackground.style.background = "silver";
	    }
	    pageOverBackground.style.visibility = "visible";
	    pageOver.style.visibility = "visible";
    }
}

function hidePageOver(){
    var pageOverBackground = document.getElementById("pageOverBackground");
    var pageOver = document.getElementById("pageOverContent");
    enableLinks();
    pageOverBackground.style.visibility = "hidden";
    pageOver.style.visibility = "hidden";
}

function showHide(mode){ 
	if(mode=="up"){			
		document.getElementById('EMS').style.display = 'none';	
		document.getElementById('EMS1').style.display='block';
		document.getElementById('imgEMS').src='/images/upsign.gif';
		document.getElementById('aEMS').onclick = function(){
			showHide('down');
		}
	}
	else if(mode=="down"){	
		document.getElementById('EMS').style.display = 'block';	
		document.getElementById('EMS1').style.display ='none';
		document.getElementById('imgEMS').src='/images/downsign.gif';
		document.getElementById('aEMS').onclick = function(){
			showHide('up');
		}
	}
}




function show(id) {
	if (id ==1 ) {
		document.getElementById('display_div').style.display = 'block';
	}
	else {
		document.getElementById('display_div').style.display = 'none';
	}
}


function Show_Stuff(Click_Menu)
// Function that will swap the display/no display for all content within span tags
{
if (Click_Menu.style.display == "none")
{
Click_Menu.style.display = "";
}
else
{
Click_Menu.style.display = "none";
}
}


 
var generator;
var a;
var b;
var c;
var d;



 function editQuicklink(ouid)
 {   
	var ouid =ouid;	
	var url ='corejsp/reporter/reportcreation.jsp?action=editquicklink&ouid='+ouid;		
	callServer2(url, mainData);	
 }
 
 function performance_reviewviewreport()
 {
	var default_user=document.getElementById('default_user').value;	
	var myobj=document.getElementsByTagName('select');
	var select_val= new Array();		
	var a=0;
	var url;
	for(var i = 0; i < myobj.length; i++)
	{
		if(myobj[i].value != -1)
		select_val[a]=myobj[i].value;
		a++;
	}			
	 var x_select_val =select_val[select_val.length-1];	
	if( x_select_val != null )
	{
	 url ='corejsp/reporter/performance_reviewviewreport.jsp?action=performance_reviewviewreport&x_select_val='+x_select_val;	
	}
	else{
		url ='corejsp/reporter/performance_reviewviewreport.jsp?action=performance_reviewviewreport&x_select_val='+default_user;	
	}	
	
	callServer2(url, mainData2);	
 }
 
 function dirtypop_view_report()
 {		
	var default_user=document.getElementById('default_user').value;	
	var myobj=document.getElementsByTagName('select');
	var select_val= new Array();		
	var a=0;	
	var url;
	for(var i = 0; i < myobj.length; i++)
	{
		if(myobj[i].value != -1)
		select_val[a]=myobj[i].value;
		a++;
	}		
	
	 var x_select_val =select_val[select_val.length-1];	
	if( x_select_val != null)
	{
	 url ='corejsp/reporter/current_performance_view_report.jsp?action=current_performance_view_report&x_select_val='+x_select_val;	
	}
	else{
	 url ='corejsp/reporter/current_performance_view_report.jsp?action=current_performance_view_report&x_select_val='+default_user;	
	}		
	callServer2(url, mainData2);	
 }
 

 function performance_GoBack(action, id)
 {
	var action=action;	
	var x_select_val=id;	
	var url ='corejsp/reporter/current_performance_view_report.jsp?action='+action+'&x_select_val='+x_select_val;
	callServer2(url, mainData2);	
 }
function reportadd_quicklink_GoBack(action, id)
{
var action=action;	
	var add_ouid=id;	
	var url ='corejsp/reporter/reportaddquickvalue.jsp?action='+action+'&add_ouid='+add_ouid;	
	callServer2(url, mainData2);	
}

function current_performance_view_report_GoBack(action, id)
{
var action=action;	
	var x_select_val=id;	
	var url ='corejsp/reporter/current_performance_view_report.jsp?action='+action+'&x_select_val='+x_select_val;	
	callServer2(url, mainData2);	
}


 
  function performancereview_quicklink_GoBack(action, id)
 {
	var action=action;	
	var add_ouid=id;	
	var url ='corejsp/reporter/performancereview_quicklink.jsp?action='+action+'&add_ouid='+add_ouid;	
	callServer2(url, mainData2);	
 }
 
 
function dirtypop()
{   
 select_box=1; 
 var myobj=document.getElementsByTagName('select'); 
 var select_val= new Array();
 var a=0;
 var flag=false; 

 for(var i = 0; i < myobj.length; i++)
 {
  if(myobj[i].value != -1)
  {
	  select_val[a]=myobj[i].value;
	  a++;
  }
 } 
  if(select_val!="")
  {
	  var url ='corejsp/reporter/reportcreation.jsp?action=addlink&select_val='+select_val.join(',');   
	   generator=window.open('','linkwindow','height=200,width=400');   
	   generator.document.write('<html><head><title>Add Quick Link</title>'); 
	   generator.document.write('</head><body align="center">'); 
	   generator.document.write('<tr><td><b>Title Of Quick link \n <input type="text" id="myText" name="myText"  /></b>\n</td></tr>'); 
	   generator.document.write('<tr><td><input  id ="b1" type="button" value="Save Quick Link"/><br /></td></tr>');   
	   generator.document.getElementById('b1').onclick=function()
	  {  
		var txtVal=generator.document.getElementById("myText").value;
	  if(txtVal !="")
		{
			putData(url);
		}
		else
		{
			return txtVal;
		}
	  
	  } 
   generator.document.write('</body></html>');
   generator.document.close();  
   }
}
	

function dirtypop_current_performance()
{	
	 select_box=1; 
		 var myobj=document.getElementsByTagName('select'); 
		 var select_val= new Array();
		 var a=0;
		 var flag=false; 
		 for(var i = 0; i < myobj.length; i++)
		 {
			  if(myobj[i].value != -1)
			  { 
				  select_val[a]=myobj[i].value;
				  a++;
			  }
		 }  
		  if(select_val!="")
		  {
			  var url ='corejsp/reporter/current_performance_view_report.jsp?action=current_performance_addlink&select_val='+select_val.join(',');		 
			   generator=window.open('','linkwindow','height=200,width=400');   
			   generator.document.write('<html><head><title>Add Quick Link</title>'); 
			   generator.document.write('</head><body align="center">'); 
			   generator.document.write('<tr><td><b>Title Of Quick link \n <input type="text" id="myText" name="myText"  /></b>\n</td></tr>'); 
			   generator.document.write('<tr><td><input  id ="b1" type="button" value="Save Quick Link"/><br /></td></tr>');   
			   generator.document.getElementById('b1').onclick=function()
			  {  
				  var txtVal=generator.document.getElementById("myText").value;
				  if(txtVal !="")
				  {
					putData(url);
				  }
				  else
				  {
					return txtVal;
				  }				  
			  } 
			   generator.document.write('</body></html>');
			   generator.document.close();  
		   }
}

function performancereview_quicklink()
	{   
		 select_box=1; 
		 var myobj=document.getElementsByTagName('select'); 
		 var select_val= new Array();
		 var a=0;
		 var flag=false; 
		 for(var i = 0; i < myobj.length; i++)
		 {
			  if(myobj[i].value != -1)
			  { 
				  select_val[a]=myobj[i].value;
				  a++;
			  }
		 }  
		  if(select_val!="")
		  {
			  var url ='corejsp/reporter/performancereview_quicklink.jsp?action=addlink1&select_val='+select_val.join(',');				  
			   generator=window.open('','linkwindow','height=200,width=400');   
			   generator.document.write('<html><head><title>Add Quick Link</title>'); 
			   generator.document.write('</head><body align="center">'); 
			   generator.document.write('<tr><td><b>Title Of Quick link \n <input type="text" id="myText" name="myText"  /></b>\n</td></tr>'); 
			   generator.document.write('<tr><td><input  id ="b1" type="button" value="Save Quick Link"/><br /></td></tr>');   
			   generator.document.getElementById('b1').onclick=function()
			  {  
				  var txtVal=generator.document.getElementById("myText").value;
				  if(txtVal !="")
				  {
					putData(url);
				  }
				  else
				  {
					return txtVal;
				  }				  
			  } 
			   generator.document.write('</body></html>');
			   generator.document.close();  
		   }
	}

function dirtypop1()
{   
 select_box=1; 
 var myobj=document.getElementsByTagName('select'); 
 var select_val= new Array();
 var a=0;
 var flag=false;	 	
	 for(var i = 0; i < myobj.length; i++)
	 {
	  if(myobj[i].value != -1)
	  {	 
		  select_val[a]=myobj[i].value;
		  a++;
	  }
	 } 
  if(select_val!="")
  {
	   var url ='corejsp/reporter/performancereview.jsp?action=add_link&select_val='+select_val.join(',');	
	  
	   generator=window.open('','linkwindow','height=200,width=400');   
	   generator.document.write('<html><head><title>Add Quick Link</title>'); 
	   generator.document.write('</head><body align="center">'); 
	   generator.document.write('<tr><td><b>Title Of Quick link \n <input type="text" id="myText" name="myText"  /></b>\n</td></tr>'); 
	   generator.document.write('<tr><td><input  id ="b1" type="button" value="Save Quick Link"/><br /></td></tr>');   
	   generator.document.getElementById('b1').onclick=function()
	  {  
		var txtVal=generator.document.getElementById("myText").value;
		  if(txtVal !="")
		  {
			putData(url);
		  }
		  else
		  {
			return txtVal;
		  }
		  
	  } 
	   generator.document.write('</body></html>');
	   generator.document.close();  
   }
}

function putData(url){
	
	var data = generator.document.getElementById('myText').value;
	var url=url +'&data='+data;	
	doAjaxURL(url);
	//callServer2(url, mainDataMgr);
	generator.close();	
}


function performancereview_checkValueChange(val)
{
 var value = val;
 var url ='corejsp/reporter/performancereview_quicklink.jsp?action=performancereview_quicklink&add_ouid='+value;  
 callServer2(url, mainData2);  
  
}

function emsUp(txt){
    document.getElementById("estimateEMS").value=txt;
}

function Display_EMS1()
{
	document.getElementById('EMS1').style.display='block';
	document.getElementById('EMS').style.display='none';
}

function checkColorChange(){	 
	var chk = document.getElementById('check_id');
	var checkboxes = chk.getElementsByTagName("input");
	var arr=new Array(checkboxes.length); 
	arr=["#00FFFF","#CCCC66","#FF8040","#CCFFFF","#CC6666","#CCFF99","#CCCC99","#996699","#666600","#663333","#33FF66","#99CC99","#000066","#C47451","#F660AB","#7D2252","#616D7E","#6D7B8D","#1589FF","#7D0541","#893BFF","#F778A1","#52F3FF","#736AFF","#617C58","#667C26","#8BB381","#87F717","#FBB917","#F87431","#7E2217","#F75D59","#E8ADAA","#817339","#FFF8C6","#7F5A58","#F62217","#C35817","#E66C2C",];

	for (var i = 0; i < checkboxes.length; i++) {
		if (checkboxes[i].checked == true) {
			var color = checkboxes[i].value;			
			document.getElementById(color).style.backgroundColor = arr[i];			
		}
		else if(checkboxes[i].checked == false) {
			var color = checkboxes[i].value;			
			document.getElementById(color).style.backgroundColor = "#ffffff";			
		}		
	}
}

function check()
	{						
		document.getElementById('EMS').style.display='none';
		document.getElementById('EMS1').style.display='block';
	}

	
function checkValueChange(val)
{
	var value = val;	
	var url ='corejsp/reporter/reportaddquickvalue.jsp?action=addQuickLink&add_ouid='+value;	
	callServer2(url, mainData2);		
		
}

function add_Check()
{	
	document.getElementById('EMS').style.display='block';
	document.getElementById('EMS1').style.display='none';	
}

function fnCheckOne(me)
{
	me.checked=true;
	var chkary=document.getElementsByTagName('input');	
	for(i=0;i<chkary.length;i++)
	{
		if(chkary[i].type=='checkbox')
		{
				if(chkary[i].id!=me.id)
				chkary[i].checked=false;			
		}
	
	}

}


function returnQuickLink()
{
select_box=1;
doAjaxAction('currentperformance_behavior', 0)

}


function pr_returnQuickLink()
{
	select_box=1;
	doAjaxAction('performancereview', 0)

}

var BrowserDetect = {
	init: function() {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i = 0; i < data.length; i++) {
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1) {
					return data[i].identity;
				}
			}
			else if (dataProp) {
				return data[i].identity;
			}
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
	              {
	            	  string: navigator.userAgent,
	            	  subString: "Chrome",
	            	  identity: "Chrome"
	              },
	              {
	            	string: navigator.userAgent,
	            	subString: "OmniWeb",
	            	versionSearch: "OmniWeb/",
	            	identity: "OmniWeb"
	              },
	              {
	            	  string: navigator.vendor,
	            	  subString: "Apple",
	            	  identity: "Safari",
	            	  versionSearch: "Version"
	              },
	              {
	            	  prop: window.opera,
	            	  identity: "Opera"
	              },
	              {
	            	  string: navigator.vendor,
	            	  subString: "iCab",
	            	  identity: "iCab"
	              },
	              {
	            	  string: navigator.vendor,
	            	  subString: "KDE",
	            	  identity: "Konqueror"
	              },
	              {
	            	  string: navigator.userAgent,
	            	  subString: "Firefox",
	            	  identity: "Firefox"
	              },
	              {
	            	  string: navigator.vendor,
	            	  subSTring: "Camino",
	            	  identity: "Camino"
	              },
	              {		//for newer Netscapes (6+)
	            	  string: navigator.userAgent,
	            	  subString: "Netscape",
	            	  identity: "Netscape"
	              },
	              {
	            	  string: navigator.userAgent,
	            	  subString: "MSIE",
	            	  identity: "Explorer",
	            	  versionSearch: "MSIE"
	              },
	              {
	            	  string: navigator.userAgent,
	            	  subString: "Gecko",
	            	  identity: "Mozilla",
	            	  versionSearch: "rv"
	              },
	              {		//for older Netscapes (4-)
	            	  string: navigator.userAgent,
	            	  subString: "Mozilla",
	            	  identity: "Netscape",
	            	  versionSearch: "Mozilla"
	              }
	              ],
	dataOS : [
	          {
	        	  string: navigator.platform,
	        	  subString: "Win",
	        	  identity: "Windows"
	          },
	          {
	        	  string: navigator.platform,
	        	  subString: "Mac",
	        	  identity: "Mac"
	          },
	          {
	        	  string: navigator.userAgent,
	        	  subString: "iPhone",
	        	  identity: "iPhone/iPod"
	          },
	          {
	        	  string: navigator.platform,
	        	  subString: "Linux",
	        	  identity: "Linux"
	          }
	          ]
};
