function addOnloadEvent(fnc){
    if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else 
      window.onload = fnc;
  }
}

function gethistory()
{
return "";
}
function get_query_string()
{
try{
var q_string="";
var query = window.location.search.substring(1);
query=unescape(query);
var vars = query.split("&");
for (var i=0;i<vars.length;i++)
{
q_string=q_string+vars[i]+",";
}
//alert(q_string);
if(q_string==",")
{
q_string="";
}
else
{
q_string=",Query String Starts= ,"+q_string+"Query String Ends= ";
}
return q_string;
}catch(e)
{
return "";
}
}
function getextras(userextras)
{
try
{
var extras;
if(document.title.length)
{
extras=escape("Page Title="+document.title);
}
else
{
extras=escape("Page Title=None");
}
extras=extras+",ScreenHeight="+(screen.height)+",ScreenWidth="+(screen.width);
q_string=get_query_string();
extras=extras+q_string;
if(userextras!="")
{
extras=extras+","+userextras;
}
extras=escape(extras);

//alert(window.location.search);
return extras;
}catch(e)
{
return "";
}
}
function getProvider(siteid,secure)
{
url="http://www.instahelp.biz/newinstahelpdb";
secure_url="https://instahelp.biz/newinstahelpdb";
url_lhg="http://www.livehelpgenie.com/geniehome";
secure_url_lhg="https://www.livehelpgenie.com/geniehome";
if(siteid!="instahelp")
	{
	switch (secure)
	{
	case true:
	return secure_url_lhg;
	case false:
     return url_lhg ;
	}
	}
else
	{
	switch(secure)
		{
	case true:
	return secure_url;
	case false:
    return url ;
		}
	}
}
function WriteDiv(siteid)
{
//siteid=siteid.replace('.',"__");
//siteid=siteid.replace('@',"__");
document.write("<div id='livehelp_script_ctr'></div>");
document.write("<div class='livehelp' id='livehelp_icon_ctr_"+siteid.toLowerCase()+"'></div>");
}

function getscript(siteid,location,send_history,referrer,userextras)
{
WriteDiv(siteid);
//addOnloadEvent(function(){loadIcon(siteid,location,send_history,referrer,userextras)});
loadIcon(siteid,location,send_history,referrer,userextras)
}
function getsecurescript(siteid,location,send_history,referrer,userextras)
{
WriteDiv(siteid);
//addOnloadEvent(function(){loadSecureIcon(siteid,location,send_history,referrer,userextras)});
loadSecureIcon(siteid,location,send_history,referrer,userextras);
}
function tracksecurevisitor(siteid,location,send_history,referrer,userextras)
{
addOnloadEvent(function(){loadSecureTracker(siteid,location,send_history,referrer,userextras)});

}
function trackvisitor(siteid,location,send_history,referrer,userextras)
{
addOnloadEvent(function(){loadTracker(siteid,location,send_history,referrer,userextras)});
}


function loadIcon(siteid,location,send_history,referrer,userextras)
{
try{
//alert("hello");
//alert(userextras);
if(!userextras)
{
userextras="";
}
location=escape(location);
referrer=escape(referrer);
url=getProvider(siteid,false);
src =url+'/getoperatorstatus.php3?siteid='+siteid+'&location=';
src=src+location;
src=src+"&extras="+getextras(userextras)+"&docrefer="+referrer+"&visitor_history="+send_history;
//alert(src);
var obj=document.createElement('script');
obj.setAttribute('src', src); 
obj.setAttribute('language', 'JavaScript');
obj.type = 'text/javascript';
var head = document.getElementsByTagName('head').item(0);
head.appendChild(obj);
}catch(e)
{
}
}


function loadSecureIcon(siteid,location,send_history,referrer,userextras)
{
try{
//location=window.location.href;
//alert(location);
if(!userextras)
{
userextras="";
}
location=escape(location);
referrer=escape(referrer);
url=getProvider(siteid,true);
src =url+'/getoperatorstatus.php3?secure=1&siteid='+siteid+'&location=';
src=src+location;
src=src+"&extras="+getextras(userextras)+"&docrefer="+referrer+"&visitor_history="+send_history;
//alert(src);
var obj=document.createElement('script');
obj.setAttribute('src', src); 
obj.setAttribute('language', 'JavaScript');
obj.type = 'text/javascript';
var head = document.getElementsByTagName('head').item(0);
head.appendChild(obj);
}catch(e)
{
}
}


function loadSecureTracker(siteid,location,send_history,referrer,userextras)
{
try{
if(!userextras)
{
userextras="";
}
location=escape(location);
referrer=escape(referrer);
url=getProvider(siteid,true);
src =url+'/trackvisitor.php3?secure=1&siteid='+siteid+'&location=';
src=src+location;
src=src+"&extras="+getextras(userextras)+"&docrefer="+referrer+"&visitor_history="+send_history;
//alert(src);
var obj=document.createElement('script');
obj.setAttribute('src', src); 
obj.setAttribute('language', 'JavaScript');
obj.type = 'text/javascript';
var head = document.getElementsByTagName('head').item(0);
head.appendChild(obj);
}catch(e)
{
}
}


function loadTracker(siteid,location,send_history,referrer,userextras)
{
try{
if(!userextras)
{
userextras="";
}
location=escape(location);
referrer=escape(referrer);
url=getProvider(siteid,false);
src =url+'/trackvisitor.php3?siteid='+siteid+'&location=';
src=src+location;
src=src+"&extras="+getextras(userextras)+"&docrefer="+referrer+"&visitor_history="+send_history;
//alert(src);
var obj=document.createElement('script');
obj.setAttribute('src', src); 
obj.setAttribute('language', 'JavaScript');
obj.type = 'text/javascript';
var head = document.getElementsByTagName('head').item(0);
head.appendChild(obj);
}catch(e)
{
}
}//end of function
function show_Icon(htm,id)
{
var auit=document.getElementsByTagName('div');
  for(var i=0; i < auit.length; i++)
   {
    if(auit[i].id==('livehelp_icon_ctr_'+id))
	{
     auit[i].innerHTML=htm;
    }

  }
}

