var oXmlHttp
var pobj = '';
var pobjx = 0;
var pobjy = 0;
var divName = '';
var topy = 0;
var topx = 0;
var adj_top = 0;
var adj_bot = 0;
var left = 0;
var right = 0;
var divName = '';
var divName2 = '';
var divName3 = '';
var divName4 = '';
var ObjRestore = new Array;

//  drag drop val
var adj_dragobj = 0;
var adj_dropobj = 0;
var adj_dropcol = 0;
var adj_last = 0;
var adj_tmp = '';
var Div_glreport = new Array;

function findPos(obj) {
	var curleft = curtop = curbot = curright = 0;
	var tmpleft = document.getElementById('test_obj').offsetLeft;
	var tmptop = document.getElementById('test_obj').offsetTop;
	
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	//curbot = curtop + obj.offsetHeight;
	//curright = curleft + obj.offsetWidth;
	topy = curtop ;
  	topx = curleft + tmpleft ;
	adj_top = curtop;
	adj_bot = curbot;
	left = curleft;
	right = curright;
}
function showPmenu(e,dName){
pobjx = e.offsetLeft;
pobjy = e.offsetTop;
findPos(e);
document.getElementById(dName).style.position = 'absolute';
document.getElementById(dName).style.left =  topx  ;
document.getElementById(dName).style.top =  topy  ;
//document.getElementById(dName).style.display='block';
//document.getElementById(dName).style.zIndex = 10;
//document.getElementById(dName).style.height = '100 px';
document.getElementById(dName).style.width = '150 px';
document.getElementById(dName).style.overflow = 'auto';
document.getElementById(dName).style.visibility = 'visible';
}
function showtaskpopup(e,dName){
pobjx = e.offsetLeft;
pobjy = e.offsetTop;
findPos(e);
document.getElementById(dName).style.position = 'absolute';
document.getElementById(dName).style.left =  topx + 10 ;
document.getElementById(dName).style.top =  topy - 150 ;
//document.getElementById(dName).style.display='block';
//document.getElementById(dName).style.zIndex = 10;
//document.getElementById(dName).style.height = '200 px';
document.getElementById(dName).style.width = '300 px';
document.getElementById(dName).style.overflow = 'auto';
document.getElementById(dName).style.visibility = 'visible';
}
function showSuggest(e,dName,link)
{

var url= link + e.value;
pobj = e;
divName = dName;
pobjx = e.offsetLeft;
pobjy = e.offsetTop;
findPos(e);

divName = dName;
oXmlHttp=GetHttpObject()
oXmlHttp.open("GET", url , true)
oXmlHttp.onreadystatechange = getSuggest

oXmlHttp.send(null)

}
function showParents(e,dName,ptable,link)
{
var tmp = document.getElementById(ptable).options[document.getElementById(ptable).selectedIndex].value;
var url= link + e.value + '&ptable=' + tmp;
pobj = e;
divName = dName;
pobjx = e.offsetLeft;
pobjy = e.offsetTop;
findPos(e);

divName = dName;
oXmlHttp=GetHttpObject()
oXmlHttp.open("GET", url , true)
oXmlHttp.onreadystatechange = getSuggest

oXmlHttp.send(null)

}

function hideSelect() {
var tmptop = 0;
var tmpbot = 0;
var tmplt = 0;
var tmprt = 0;
var hide = 0;
var tmpstr = '';
var poptop = 0;
var popbot = 0;
var poplt = 0;
var poprt = 0;
var tmpht = 0;
var tmpwt = 0;
var tmptype = '';
var tmppos = 0;
//findPos(document.getElementbyId(divName));
 poptop = adj_top + 20;
 popbot = adj_top + 100;
 poplt = left + 10;
 poprt = left + 300;
 if (document.all) {
    for (formIdx=0; formIdx<document.forms.length; formIdx++) {
	var theForm = document.forms[formIdx];
	for (elementIdx=0; elementIdx<theForm.elements.length; elementIdx++) {
	   //window.status += theForm[elementIdx].type;
	   
	   if(theForm[elementIdx].type == 'select-one' || theForm[elementIdx].type == 'select-multiple') {
		hide = 1;
		findPos(theForm[elementIdx]);
		tmpht = theForm[elementIdx].offsetHeight;
		tmpwt = theForm[elementIdx].offsetWidth;
		tmptop = adj_top;
		tmpbot = adj_top + tmpht;
		tmplt = left;
		tmprt = left + tmpwt;
		
		
		if ( poplt > tmprt ) {
			hide = 0;
		}
		if ( poprt < tmplt ) {
			hide = 0;
		}
		if ( poptop > tmpbot) {
			hide = 0;
		}
		if ( popbot < tmptop ) {
			hide = 0;
		}
		//tmpstr = tmptop + ',' + tmpbot + ',' + tmplt + ',' + tmprt + '|' + poptop + ','+ popbot +',' + poplt + ',' + poprt;
		//document.test.entid.value = hide;
		if (hide == 1){
		ObjRestore.push(elementIdx);
		theForm[elementIdx].style.visibility = "hidden";
		}
	   }
	}
   }
 }
}

function unhideSelect_new(){
	for(i=0; i<= ObjRestore.length; i++) {
               id = ObjRestore[i];
               if(id) {

                    clipped = document.getElementById(id);

                    clipped.style.visibility = 'visible';

                }

        }


}

function unhideSelect() {
if (document.all) {
for (formIdx=0; formIdx<document.forms.length; formIdx++) {
var theForm = document.forms[formIdx];
for(elementIdx=0; elementIdx<theForm.elements.length; elementIdx++) {
if(theForm[elementIdx].type == "select-one" || theForm[elementIdx].type == "select-multiple") {
theForm[elementIdx].style.visibility = "visible";
}
}
}
}
}

function getSuggest()
{

if (oXmlHttp.readyState==4 || oXmlHttp.readyState=="complete")
{

document.getElementById(divName).innerHTML=oXmlHttp.responseText;
document.getElementById(divName).style.position = 'absolute';
document.getElementById(divName).style.left =  topx + 10 ;
document.getElementById(divName).style.top =  topy + 20 ;
document.getElementById(divName).style.display='block';
document.getElementById(divName).style.zIndex = 1;
document.getElementById(divName).style.height = '100px';
document.getElementById(divName).style.width = '300px';
document.getElementById(divName).style.overflow = 'auto';
document.getElementById(divName).style.visibility = 'visible';
document.getElementById(divName).style.background = '#ffffff';
document.getElementById(divName).style.border = '1px solid black';
hideSelect();


}
}

//  drag drop here
var tXmlHttp ;
var tXmlHttp2;

function reset_position(){
var url2= 'tmpajax/move_function.cfm?last=' + adj_last + '&drag=' + adj_dragobj + '&drop=' + adj_dropobj + '&col=' + adj_dropcol;
//var url2= 'tmpajax/move_function.cfm?' + adj_tmp;

tXmlHttp = GetHttpObject();

tXmlHttp.open("GET", url2 , true);
//alert(url2);
tXmlHttp.onreadystatechange = function(){
if (tXmlHttp.readyState == 4) {
		//alert('done');
	}
}
tXmlHttp.send(null)
adj_dragobj = '';
//document.testform.testval.value= url2;
}

function func_done(){
if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{
//var tmpresp = tXmlHttp.responseText;
//alert(tmpresp);
//document.getElementById('testdiv').innerHTML=tXmlHttp.responseText;
//document.getElementById('testdiv').style.position = 'absolute';

//document.getElementById('testdiv').style.height = '100px';
//document.getElementById('testdiv').style.width = '300px';
//document.getElementById('testdiv').style.overflow = 'auto';
//document.getElementById('testdiv').style.visibility = '';
//document.getElementById('testdiv').style.display = 'none';



}

}

//  update long & lat of ent here  http://www.myadjutant.com/beta/

function setlatlng(lat,lng,compid){
var url3= 'tmpajax/update_ent.cfm?entid=' + compid + '&lng=' + lng + '&lat=' + lat ;

//alert(url3);
tXmlHttp = GetHttpObject()
tXmlHttp.open("GET", url3 , true)
tXmlHttp.onreadystatechange = function(){
if (tXmlHttp.readyState == 4) {
		//alert('done');
	}

}
//alert('done');
tXmlHttp.send(null);

}

function setlatlng_csz(lat,lng,ltype,lname){
var url3= 'tmpajax/save_location.cfm?ltype=' + ltype + '&lname=' + lname + '&lng=' + lng + '&lat=' + lat ;

//alert(url3);
tXmlHttp = GetHttpObject()
tXmlHttp.open("GET", url3 , true)
tXmlHttp.onreadystatechange = function(){
if (tXmlHttp.readyState == 4) {
		//alert('done');
	}

}
//alert('done');
tXmlHttp.send(null);

}

//  complete task

function completetask(tid){
var urltask= 'tmpajax/complete_task.cfm?tid=' + tid  ;

//alert(urltask);
tXmlHttp = GetHttpObject()
tXmlHttp.open("GET", urltask , true)
tXmlHttp.onreadystatechange = function(){
if (tXmlHttp.readyState == 4) {
		alert('Task completed !');
	}

}
//alert('done');
tXmlHttp.send(null);

}
// Doc Vault List
function get_DocList(t,p1,p2,dName,r){
var url_doc = 'tmpajax/get_doc.cfm?type=' + t + '&p1=' + p1 + '&p2=' + p2;
divName = dName;
tXmlHttp = GetHttpObject();
//alert('call');
tXmlHttp.open("GET", url_doc , true)
tXmlHttp.onreadystatechange = showDocList

tXmlHttp.send(null);
}
function showDocList()
{

if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{

document.getElementById(divName).innerHTML=tXmlHttp.responseText;
//document.getElementById(divName).style.position = 'absolute';
//document.getElementById(divName).style.left =  topx + 10 ;
//document.getElementById(divName).style.top =  topy - 100 ;
document.getElementById(divName).style.display='block';
document.getElementById(divName).style.zIndex = 10;
document.getElementById(divName).style.height = '200px';
document.getElementById(divName).style.width = '500px';
document.getElementById(divName).style.overflow = 'auto';
document.getElementById(divName).style.visibility = 'visible';
//hideSelect();



}
}


// send page to a friend
function sendPage(u,n,ye,e,divName){
var url4 = 'tmpajax/send_page.cfm?u=' + u + '&to=' + e + '&from=' + ye+ '&n=' + n;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url4 , true)
tXmlHttp.onreadystatechange = showMessage
alert('Your email was sent.');
tXmlHttp.send(null);
}
function showMessage()
{

if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{

document.getElementById(divName).innerHTML=tXmlHttp.responseText;
//document.getElementById(divName).style.position = 'absolute';
//document.getElementById(divName).style.left =  topx + 10 ;
//document.getElementById(divName).style.top =  topy + 20 ;
//document.getElementById(divName).style.display='block';
//document.getElementById(divName).style.zIndex = 10;
//document.getElementById(divName).style.height = '100px';
///document.getElementById(divName).style.width = '300px';
//document.getElementById(divName).style.overflow = 'auto';
//document.getElementById(divName).style.visibility = 'visible';
//hideSelect();



}
}

// load phase
function load_phase(fname,pname,dName){
divName = dName;
var tmpid = document.getElementById(fname).options[document.getElementById(fname).selectedIndex].value;
//alert(tmpid);
var url = 'tmpajax/get_phase.cfm?msnid=' + tmpid + '&pname=' + pname  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showPhase

tXmlHttp.send(null);

}
function showPhase()
{

if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{

document.getElementById(divName).innerHTML=tXmlHttp.responseText;

}
}

// load article
function load_articles(bname,aname,dName,type){
divName = dName;
var tmpid = document.getElementById(bname).options[document.getElementById(bname).selectedIndex].value;
//alert(tmpid);
var url = 'tmpajax/get_articles.cfm?bid=' + tmpid + '&aname=' + aname + '&type=' + type  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showArticles

tXmlHttp.send(null);

}
function showArticles()
{

if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{

document.getElementById(divName).innerHTML=tXmlHttp.responseText;

}
}

// load function
function loadFunction(fid,funcName){


//alert(tmpid);
var url = 'tmpajax/get_function.cfm?fid=' + fid   ;
var tmpHttp = GetHttpObject();
tmpHttp.open("GET", url , true);
tmpHttp.onreadystatechange = showFunction(funcName,tmpHttp);

tmpHttp.send(null);

}
function showFunction(funcName,tmpHttp)
{

if (tmpHttp.readyState==4 || tmpHttp.readyState=="complete")
{

document.getElementById(funcName).innerHTML=tmpHttp.responseText;

}
}

// load glreport
function load_GLReport(gldiv,glid){

Div_glreport.push(gldiv);
var tmppos = Div_glreport.length;
//alert(tmpid);
var url = 'tmpajax/get_glreport.cfm?glid=' + glid   ;
var tmpHttp = GetHttpObject();
tmpHttp.open("GET", url , true);
tmpHttp.onreadystatechange = showGLReport(tmppos);

tmpHttp.send(null);

}
function showGLReport(pos)
{
var funcName = Div_glreport[pos];
if (tmpHttp.readyState==4 || tmpHttp.readyState=="complete")
{

document.getElementById(funcName).innerHTML=tmpHttp.responseText;

}
}

// load contact phone
function load_cont_phone(cid,pname,fname,dName,change){
divName = dName;
var tmpid = document.getElementById(pname).options[document.getElementById(pname).selectedIndex].value;
//alert(tmpid);
var url = 'tmpajax/get_cont_phone.cfm?cid=' + cid + '&pcode=' + tmpid + '&fname=' + fname + '&change=' + change  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showPhone

tXmlHttp.send(null);

}
function showPhone()
{

if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{

document.getElementById(divName).innerHTML=tXmlHttp.responseText;

}
}

// load task resource
function load_task_resource(custid,sname,lzone,dName){
divName = dName;
var scode = document.getElementById(sname).options[document.getElementById(sname).selectedIndex].value;

var url = 'tmpajax/get_task_resource.cfm?custid=' + custid + '&scode=' + scode + '&lzone=' + lzone   ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}



// load udd
function load_udd(xx,qname,oname,dName){
divName = dName;

var qid = document.getElementById(qname).options[document.getElementById(qname).selectedIndex].value;
var oid = document.getElementById(oname).options[document.getElementById(oname).selectedIndex].value;

var url = 'tmpajax/get_udd.cfm?qid=' + qid + '&oid=' + oid + '&xx=' + xx   ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showudd

tXmlHttp.send(null);

}
function showudd()
{

if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{

document.getElementById(divName).innerHTML=tXmlHttp.responseText;

}
}

// youtube_search
function youtube(dName,sname){
divName = dName;
var url5 = 'tmpajax/youtube_search.cfm?d=' + dName + '&s=' + sname;
//alert(divName);
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url5 , true)
tXmlHttp.onreadystatechange = showYoutube
//alert('done');
tXmlHttp.send(null);
}
function showYoutube()
{
//alert('inside');
if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{

var tmporg = tXmlHttp.responseText;
var tmptitle = '';
var tmpimg = '';
var tmpfrom = '';
var tmpurl = '';
var tmpruntime = '';
var tmpview = '';
var tmpstar = 0;
var tmpfrom = '';
var tmp = new Array();
tmp = tmporg.split('|');

tmptitle = tmp[0];
tmpimg   = tmp[1];
tmpurl   = tmp[2];
tmpruntime   = tmp[3];
tmpview   = tmp[4];
tmpstar   = tmp[5];
tmpfrom  = tmp[6];
tmpmore	 = tmp[7];

//alert(tmpstar);
document.getElementById('Uimage').src= tmpimg;
document.getElementById('Utitle').innerHTML = '<b>' + tmptitle + '</b>';
document.getElementById('Uurl').href = tmpurl;
document.getElementById('Uruntime').innerHTML = tmpruntime ;
document.getElementById('Uview').innerHTML = tmpview ;
document.getElementById('Ustar').innerHTML = tmpstar ;
document.getElementById('Ufrom').innerHTML = tmpfrom ;
document.getElementById('Umore').href = tmpmore;

//document.getElementById(divName).innerHTML=tXmlHttp.responseText;
//document.getElementById(divName).style.position = 'absolute';
//document.getElementById(divName).style.left =  topx + 10 ;
//document.getElementById(divName).style.top =  topy + 20 ;
//document.getElementById(divName).style.display='block';
//document.getElementById(divName).style.zIndex = 10;
//document.getElementById(divName).style.height = '100px';
///document.getElementById(divName).style.width = '300px';
//document.getElementById(divName).style.overflow = 'auto';
//document.getElementById(divName).style.visibility = 'visible';
//hideSelect();



}
}

// Poll 
function poll_vote(pid,ans,dName){
divName = dName;
var ansid = 0;
for (var i=0; i < ans.length; i++)
   {
   if (ans[i].checked)
      {
       ansid = ans[i].value;
      }
   }
if (ansid == 0){
  alert('Please select an answer!');
}
else{

var url5 = 'tmpajax/poll_vote.cfm?d=' + dName + '&pid=' + pid + '&aid=' + ansid;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url5 , true)
tXmlHttp.onreadystatechange = showPollResult
//alert('done');
tXmlHttp.send(null);
}
}
function showPollResult()
{
//alert('inside');
if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{
//alert(divName);
document.getElementById(divName).innerHTML=tXmlHttp.responseText;
//alert('after');
//document.getElementById(divName).style.position = 'absolute';
//document.getElementById(divName).style.left =  topx + 10 ;
//document.getElementById(divName).style.top =  topy + 20 ;
//document.getElementById(divName).style.display='block';
//document.getElementById(divName).style.zIndex = 10;
//document.getElementById(divName).style.height = '100px';
///document.getElementById(divName).style.width = '300px';
//document.getElementById(divName).style.overflow = 'auto';
//document.getElementById(divName).style.visibility = 'visible';
//hideSelect();



}
}
// Time Period
function get_dates(t1,t2,t3,dName){
divName = dName;



var url5 = 'tmpajax/get_dates.cfm?t1=' + t1 + '&t2=' + t2 + '&t3=' + t3 + '&div=' + dName ;
//alert(url5);
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url5 , true)
tXmlHttp.onreadystatechange = showDates
//alert('done');
tXmlHttp.send(null);

}
function showDates()
{
//alert('inside');
if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{
//alert(divName);
document.getElementById(divName).innerHTML=tXmlHttp.responseText;

}
}

//add record in multiple list on function setup page

function addRecord(field,newid,tname,tfield,rid,rname,dName,tmpform,tmpname){
divName = dName;

var tmpvalue = field.value;

field.value = tmpvalue + '/' + newid;

var url = 'tmpajax/get_mlist.cfm?field=' + field + '&tname=' + tname + '&ids=' + field.value + '&tfield=' + tfield + '&rname=' + rname + '&rid=' + rid + '&dname=' + dName + '&tmpform=' + tmpform + '&tmpname=' + tmpname ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
//alert('done');

tXmlHttp.send(null);

}
function delRecord(field,delid,tname,tfield,rid,rname,dName,tmpform,tmpname){
divName = dName;

var tmpvalue = field.value;
var delstr = '~' + delid + '~';

tmpvalue = tmpvalue.replace('/',"~,~");
while (tmpvalue.indexOf('/') > 0){
  tmpvalue = tmpvalue.replace('/',"~,~");
}

tmpvalue = '~' + tmpvalue + '~';
//alert(tmpvalue);
//alert(delstr);
tmpvalue = tmpvalue.replace(delstr,'');
while(tmpvalue.indexOf(delstr) > 0){
  tmpvalue = tmpvalue.replace(delstr,'');
}
tmpvalue = tmpvalue.replace(/~,~/g,"/");
tmpvalue = tmpvalue.replace(/~/g,'');
tmpvalue = tmpvalue.replace(/,/g,'');
field.value = tmpvalue;
//alert(tmpvalue);
var url = 'tmpajax/get_mlist.cfm?field=' + field + '&tname=' + tname + '&ids=' + field.value + '&tfield=' + tfield + '&rname=' + rname + '&rid=' + rid + '&dname=' + dName + '&tmpform=' + tmpform + '&tmpname=' + tmpname ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
//alert('done');
tXmlHttp.send(null);

}

function addRecord_new(field,newid,tname,tfield,rid,rname,dName,tmpform,tmpname){
divName = dName;

var tmpvalue = field.value;

field.value = tmpvalue + '/' + newid;

var url = '../tmpajax/get_mlist_new.cfm?field=' + field + '&tname=' + tname + '&ids=' + field.value + '&tfield=' + tfield + '&rname=' + rname + '&rid=' + rid + '&dname=' + dName + '&tmpform=' + tmpform + '&tmpname=' + tmpname ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
//alert('done');

tXmlHttp.send(null);

}
function delRecord_new(field,delid,tname,tfield,rid,rname,dName,tmpform,tmpname){
divName = dName;

var tmpvalue = field.value;
var delstr = '~' + delid + '~';

tmpvalue = tmpvalue.replace('/',"~,~");
while (tmpvalue.indexOf('/') > 0){
  tmpvalue = tmpvalue.replace('/',"~,~");
}

tmpvalue = '~' + tmpvalue + '~';
//alert(tmpvalue);
//alert(delstr);
tmpvalue = tmpvalue.replace(delstr,'');
while(tmpvalue.indexOf(delstr) > 0){
  tmpvalue = tmpvalue.replace(delstr,'');
}
tmpvalue = tmpvalue.replace(/~,~/g,"/");
tmpvalue = tmpvalue.replace(/~/g,'');
tmpvalue = tmpvalue.replace(/,/g,'');
field.value = tmpvalue;
//alert(tmpvalue);
var url = '../tmpajax/get_mlist_new.cfm?field=' + field + '&tname=' + tname + '&ids=' + field.value + '&tfield=' + tfield + '&rname=' + rname + '&rid=' + rid + '&dname=' + dName + '&tmpform=' + tmpform + '&tmpname=' + tmpname ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
//alert('done');
tXmlHttp.send(null);

}
function showResults()
{
//alert('inside');
if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete")
{
//alert(divName);
//alert(tXmlHttp.responseText);
document.getElementById(divName).innerHTML=tXmlHttp.responseText;

}
}
function showResults2()
{
//alert('inside');
if (tXmlHttp2.readyState==4 || tXmlHttp2.readyState=="complete")
{
//alert(divName);
//alert(tXmlHttp.responseText);
document.getElementById(divName2).innerHTML=tXmlHttp2.responseText;

}
}
function showResults3()
{
//alert('inside');
if (tXmlHttp3.readyState==4 || tXmlHttp3.readyState=="complete")
{
//alert(divName);
//alert(tXmlHttp.responseText);
document.getElementById(divName3).innerHTML=tXmlHttp3.responseText;

}
}
function showResults4()
{
//alert('inside');
if (tXmlHttp4.readyState==4 || tXmlHttp4.readyState=="complete")
{
//alert(divName);
//alert(tXmlHttp.responseText);
document.getElementById(divName4).innerHTML=tXmlHttp4.responseText;

}
}
// load task pcomp
function load_pcomp(tdName,fName,tmpName,tid,cName){
divName = tdName;

var fval = document.getElementById(fName).value;


var url = 'tmpajax/get_loadpcomp.cfm?fval=' + fval + '&tmpName=' + tmpName + '&tdName=' + tdName + '&fName=' + fName + '&cName=' + cName + '&tid=' + tid  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}
// unload task pcomp
function unload_pcomp(tdName,fName,tmpName,tid,cName){
divName = tdName;

var fval = document.getElementById(tmpName).value;
document.getElementById(fName).value = fval;
var cval = document.getElementById(cName).value;
document.getElementById(cName).value = cval + ',' + tid;
//alert(document.getElementById(cName).value);
var url = 'tmpajax/get_unloadfield.cfm?fval=' + fval    ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}

// unload task field
function unload_field(tdName,fName,tmpName,tid,cName){
divName = tdName;

var fval = document.getElementById(fName).value;
//document.getElementById(fName).value = fval;
//var cval = document.getElementById(cName).value;
//document.getElementById(cName).value = cval + ',' + tid;
//alert(document.getElementById(cName).value);
var url = 'tmpajax/get_unloadfield.cfm?fval=' + fval    ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}

// create carton
function create_carton(rName,dName,sokeynoh,loctid,cloct,cname,ctype,clength,cwidth,cheight){
divName = dName;

if (cname.length == 0){
   document.getElementById(rName).innerHTML = 'Error : Please provide carton name.';
   document.getElementById(rName).style.backgroundColor = '#ffff33';
}else{
	document.getElementById(rName).innerHTML = '';
	document.getElementById(rName).style.backgroundColor = '#ffffff';
	var url = 'tmpajax/get_createcartons.cfm?keynoh=' + sokeynoh + '&loctid=' + loctid + '&cloct=' + cloct + '&cname=' + cname + '&ctype=' + ctype + '&clength=' + clength + '&cwidth=' + cwidth + '&cheight=' + cheight + '&rName=' + rName ;
	tXmlHttp = GetHttpObject();
	tXmlHttp.open("GET", url , true)
	tXmlHttp.onreadystatechange = showResults

	tXmlHttp.send(null);
}
}
// load cartons
function load_cartons(dName,sokeynoh,loctid){
divName = dName;


var url = 'tmpajax/get_loadcartons.cfm?keynoh=' + sokeynoh + '&loctid=' + loctid;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true) 
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}

// add projopp alt options 
function addProjoppOption(oid,dName,option,price,type){
divName = dName;
var opt = option.value;
var p = price.value;
var url = 'tmpajax/add_projopp_option.cfm?oid=' + oid + '&type=' + type + '&price=' + p + '&option=' + opt;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
option.value = '';
price.value = '';
tXmlHttp.send(null);

}

// add projopp competitor
function addProjoppCompetitor(oid,dName,entid,company,mprice,profit,notes,stax){
divName = dName;
var eid = entid.value;
var comp = company.value;
var mp = mprice.value;
//var lp = lprice.value;
var nt = notes.value;
var pf = profit.value;

var url = 'tmpajax/add_projopp_competitor.cfm?oid=' + oid + '&entid=' + eid + '&mprice=' + mp  + '&profit=' + pf + '&notes=' + nt + '&stax=' + stax ;
//alert(url);
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);
  var elOptNew = document.createElement('option');
  elOptNew.text = comp;
  elOptNew.value = eid;
  entid.value = 0;
  company.value = '';
  mprice.value = '';
  //lprice.value = '';
  notes.value = '';
  profit.value= '';
  var elSel = document.getElementById('whowon');

  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }


}

// add projopp  bidder
function addbidder(dName,oid,oppno,bid,bname){
divName = dName;
var tmpid = bid.value;

var url = 'tmpajax/add_projopp_bidder.cfm?oid=' + oid + '&oppno=' + oppno + '&bid=' + tmpid;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
bname.value = '';
bid.value = 0;
tXmlHttp.send(null);

}

// update projopp  comp notes
function Update_ProjoppCompNotes(nid,n){
//divName = dName;
var notes = n.value;

var url = 'tmpajax/update_projopp_compnotes.cfm?nid=' + nid + '&notes=' + notes;
//alert(url);
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}

// Save projopp winning bidder
function ProjOpp_winbidder(oid,eid,e){
var flag = 0;
  if (e.checked){
 	flag = 1;
  }
var url = 'tmpajax/save_projopp_winbidder.cfm?oid=' + oid +  '&eid=' + eid + '&flag=' + flag;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}

// Save projopp winning bidder
function ProjOpp_winbiddernew(oid,eid,e){
var flag = 0;
  if (e==1){
 	flag = 1;
  }
var url = 'tmpajax/save_projopp_winbidder.cfm?oid=' + oid +  '&eid=' + eid + '&flag=' + flag;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}

// Save projopp your quote
function ProjOpp_YourQuote(oid,ans){
var url = 'tmpajax/save_projopp_yourquote.cfm?oid=' + oid +  '&ans=' + ans;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}
// update projopp Decision Maker
function ProjOpp_UpdateDM(oid,contid){
//divName = dName;


var url = 'tmpajax/get_projopp_DM.cfm?contid=' + contid + '&oid=' + oid ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}
// update projopp Acctmgr
function ProjOpp_UpdateAcctmgr(oid,contid){
//divName = dName;


var url = 'tmpajax/get_projopp_Acctmgr.cfm?contid=' + contid + '&oid=' + oid ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}
// update projopp Salesmgr
function ProjOpp_UpdateSalesmgr(oid,contid){
//divName = dName;


var url = 'tmpajax/get_projopp_Salesmgr.cfm?contid=' + contid + '&oid=' + oid ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}
// update projopp Salesengr
function ProjOpp_UpdateSalesengr(oid,contid){
//divName = dName;


var url = 'tmpajax/get_projopp_Salesengr.cfm?contid=' + contid + '&oid=' + oid ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}
// update projopp SP
function ProjOpp_UpdateSP(oid,contid){
//divName = dName;


var url = 'tmpajax/get_projopp_SP.cfm?contid=' + contid + '&oid=' + oid ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}
// update projopp  ProjOpp_Contact
function ProjOpp_UpdateCont(oid,contid){
//divName = dName;

var url = 'tmpajax/get_projopp_cont.cfm?contid=' + contid + '&oid=' + oid ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}

// get projopp  ProjOpp_Contact Phone
function ProjOpp_GetContPhone(contid,dName){
divName = dName;
var url = 'tmpajax/get_projopp_contphone.cfm?contid=' + contid ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
tXmlHttp.send(null);



}
// get projopp  ProjOpp_Contact Email
function ProjOpp_GetContEmail(contid,dName){
divName2 = dName;
var url2 = 'tmpajax/get_projopp_contemail.cfm?contid=' + contid ;
tXmlHttp2 = GetHttpObject();
tXmlHttp2.open("GET", url2 , true)
tXmlHttp2.onreadystatechange = showResults2

tXmlHttp2.send(null);

}

// add projopp  ProjOpp_ContactInfo
function ProjOpp_ContactInfo(oid,dName,contid){
divName = dName;


var url = 'tmpajax/get_projopp_cont.cfm?contid=' + contid + '&oid=' + oid ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}
// add projopp  ProjOpp_ContactPhone
function ProjOpp_ContactPhone(dName,contid,pcode){
divName = dName;


var url = 'tmpajax/get_projopp_phone.cfm?contid=' + contid + '&pcode=' + pcode;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}
// phase lookup
function phaseLookup(dName,phid,msnid){
divName2 = dName;


var url = 'tmpajax/get_phase.cfm?phid=' + phid + '&msnid=' + msnid;
tXmlHttp2 = GetHttpObject();
tXmlHttp2.open("GET", url , true)
tXmlHttp2.onreadystatechange = showResults2

tXmlHttp2.send(null);

}

// County lookup
function ProjOpp_CountyLookup(dName,city,state,zip){
divName = dName;
var url = 'tmpajax/get_projopp_county.cfm?city=' + city + '&state=' + state + '&zip=' + zip ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}
// update label
function UpdateLabel(d1Name,d2Name,valName,lblName){
//divName = tdName;

var fval = document.getElementById(valName).value;


var url = 'tmpajax/updateLabel.cfm?lblname=' + lblName + '&valName=' + fval ;
//alert(url);
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 
tXmlHttp.send(null);
document.getElementById(d1Name).innerHTML = fval;
document.getElementById(d2Name).style.display="none";
document.getElementById(d1Name).style.display="block";
}

// check duplicate ENT
function CheckDuplicateENT(tdName,comp,addr,phone){
divName = tdName;

var url = 'tmpajax/check_entduplicate.cfm?dName=' + tdName +'&comp=' + comp + '&address=' + addr + '&phone=' + phone  ;
//alert(url);
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showWarnings
tXmlHttp.send(null);

}

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

function showWarnings()
{
//alert('inside');
if (tXmlHttp.readyState==4 || tXmlHttp.readyState=="complete"){
var tmp = tXmlHttp.responseText.trim();

if (tmp.length > 0)
alert(tXmlHttp.responseText);


//hideSelect();



}
}
// customer ecr: add more files
function addMoreFiles(tdName,fName,fcount){
divName = tdName;
var file_array = new Array();
var fval = parseInt(fcount.value) + 1;
var tmp = '';
   file_array[0] = '';


for (var xx=1; xx < fval; xx++){
     tmp = 'file_' + xx; 
      
     file_array[xx] = document.getElementById(tmp).value;
    
    
}

var url = 'tmpajax/addMoreFiles.cfm?fName=' + fName + '&fcount=' + fval  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
fcount.value = fval;


tXmlHttp.send(null);

}
// load std tasks based on dept
function Task_LoadStdTasks(dept,tdName,alt){
divName = tdName;



var url = 'tmpajax/get_stdtasks.cfm?dept=' + dept + '&altprobcode=' + alt;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}

// load std task info based on stdtask
function Task_LoadStdTaskInfo(stask,tdName,alt){
divName = tdName;



var url = 'tmpajax/get_stdtaskinfo.cfm?stdtask=' + stask + '&altprobcode=' + alt;
//alert(url);

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}
// load std task Workcategory based on stdtask
function Task_LoadStdTask_Workcat(stask,tdName){
divName2 = tdName;



var url = 'tmpajax/get_stdtask_wcat.cfm?stdtask=' + stask ;
//alert(url);

tXmlHttp2 = GetHttpObject();
tXmlHttp2.open("GET", url , true)
tXmlHttp2.onreadystatechange = showResults2

tXmlHttp2.send(null);

}

// load std task Workcategory based on stdtask
function Task_LoadStdTask_Priority(stask,tdName){
divName3 = tdName;


var url = 'tmpajax/get_stdtask_priority.cfm?stdtask=' + stask ;
//alert(url);

tXmlHttp3 = GetHttpObject();
tXmlHttp3.open("GET", url , true)
tXmlHttp3.onreadystatechange = showResults3

tXmlHttp3.send(null);

}

// load std task duedate based on stdtask
function Task_LoadStdTask_Duedate(stask,tdName){
divName4 = tdName;


var url = 'tmpajax/get_stdtask_duedate.cfm?stdtask=' + stask ;
//alert(url);

tXmlHttp4 = GetHttpObject();
tXmlHttp4.open("GET", url , true)
tXmlHttp4.onreadystatechange = showResults4

tXmlHttp4.send(null);

}

// load task status
function load_taskstatus(tdName,fName,fvName,tmpName,tid,cName){
divName = tdName;

var fval = document.getElementById(fName).value;


var url = 'tmpajax/get_loadstatus.cfm?fval=' + fval + '&tmpName=' + tmpName + '&tdName=' + tdName + '&fName=' + fName  + '&fvName=' + fvName + '&cName=' + cName + '&tid=' + tid  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}
// update task assign res
function Update_TaskAssignRes(sid,empid){
//divName = tdName;

//var fval = document.getElementById(fName).value;


var url = 'tmpajax/update_taskassignres.cfm?sid=' + sid + '&empid=' + empid  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}
function delAssign(tName,sid){
divName = tName;
//alert(divName);
//var fval = document.getElementById(fName).value;


var url = 'tmpajax/delete_taskassign.cfm?sid=' + sid   ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}
// update task assign schdate
function Update_TaskAssignSdate(sid,sdate,stime){
//divName = tdName;

//var fval = document.getElementById(fName).value;


var url = 'tmpajax/update_taskassignsdate.cfm?sid=' + sid + '&sdate=' + sdate + '&stime=' + stime ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}

// update task assign schdate
function Update_TaskAssignDuration(sid,du){
//divName = tdName;

//var fval = document.getElementById(fName).value;


var url = 'tmpajax/update_taskassignduration.cfm?sid=' + sid + '&d=' + du;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange 

tXmlHttp.send(null);

}

// update task assign schdate
function Add_TaskAssignment(tdName,tid,empid,sdate,stime,duration,ddate,dtime){
divName4 = tdName;

//var fval = document.getElementById(fName).value;


var url = 'tmpajax/add_taskassign.cfm?tid=' + tid + '&empid=' + empid + '&sdate=' + sdate + '&stime=' + stime + '&duration=' + duration + '&ddate=' + ddate + '&dtime=' + dtime;

tXmlHttp4 = GetHttpObject();
tXmlHttp4.open("GET", url , true)
tXmlHttp4.onreadystatechange = showResults4
//alert(document.getElementById(tdName).innerHTML.text);
tXmlHttp4.send(null);

}
// add task alert
function Add_TaskAlert(tdName,tid,contid){
divName = tdName;

//var fval = document.getElementById(fName).value;


var url = 'tmpajax/add_taskalert.cfm?tid=' + tid + '&cid=' + contid ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
//alert(document.getElementById(tdName).innerHTML.text);
tXmlHttp.send(null);

}
// delete task alert
function Delete_TaskAlert(tdName,tid,aid){
divName = tdName;

//var fval = document.getElementById(fName).value;


var url = 'tmpajax/delete_taskalert.cfm?tid=' + tid + '&aid=' + aid ;

tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
//alert(document.getElementById(tdName).innerHTML.text);
tXmlHttp.send(null);

}
// update task alert
function Update_TaskAlert(tdName,tid,aid,acode,amethod,tname,toffset){
divName = tdName;

//var fval = document.getElementById(fName).value;


var url = 'tmpajax/update_taskalert.cfm?tid=' + tid + '&aid=' + aid + '&acode=' + acode + '&amethod=' + amethod + '&tname=' + tname + '&toffset=' + toffset;
//alert(url);
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults
//alert(document.getElementById(tdName).innerHTML.text);
tXmlHttp.send(null);

}


// load rows
function LoadRows(tdName,id){
divName = tdName;

var url = 'tmpajax/get_rows.cfm?pid=' + id  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}

// load columns
function LoadColumns(tdName,id){
divName = tdName;
//alert(divName);
var url = 'tmpajax/get_columns.cfm?rid=' + id  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}

// load functions
function LoadFunctions(tdName,id){
divName = tdName;

var url = 'tmpajax/get_functions.cfm?cid=' + id  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}

// load Album
function LoadAlbumPhotos(tdName,pid,aid){
divName = tdName;

var url = 'tmpajax/get_photos.cfm?aid=' + aid + '&pid=' + pid  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}

// load Album
function LoadFolderFiles(tdName,pid,aid){
divName = tdName;

var url = 'tmpajax/get_folderfiles.cfm?fid=' + aid + '&pid=' + pid  ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}


// unload task status
function unload_taskstatus(tdName,fName,fvNametmpName,tid,cName){
divName = tdName;

var fval = document.getElementById(tmpName).options[document.getElementById(tmpName).selectedIndex].value;
var fvval = document.getElementById(tmpName).options[document.getElementById(tmpName).selectedIndex].name;
document.getElementById(fName).value = fval;
document.getElementById(fvName).value = fvval;
var cval = document.getElementById(cName).value;
document.getElementById(cName).value = cval + ',' + tid;
//alert(document.getElementById(cName).value);
var url = 'tmpajax/get_unloadstatus.cfm?fval=' + fvval    ;
tXmlHttp = GetHttpObject();
tXmlHttp.open("GET", url , true)
tXmlHttp.onreadystatechange = showResults

tXmlHttp.send(null);

}


function GetHttpObject()
{
try
{

var oRequester = new XMLHttpRequest();
	//oRequester.onload=handler
	//oRequester.onerror=handler
	return oRequester
}
catch (error)
{
try
{

var oRequester = new ActiveXObject("Microsoft.XMLHTTP");
//oRequester.onreadystatechange=handler
return oRequester
}
catch (error)
{

return false;
}
}
}


