// JavaScript Document
function getSize(url) {
 var myWidth = 0, myHeight = 0;
 if(typeof(window.innerWidth) == 'number') {
  //Non-IE
  myWidth = window.innerWidth;
  myHeight = window.innerHeight;
 }else if(document.documentElement &&
  (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
  //IE 6+ in 'standards compliant mode'
  myWidth = document.documentElement.clientWidth;
  myHeight = document.documentElement.clientHeight;
 } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
  //IE 4 compatible
  myWidth = document.body.clientWidth;
  myHeight = document.body.clientHeight;
 }
 openWidth = myWidth-50;
 openHeight = myHeight-110;
 var randomnumber=Math.floor(Math.random()*101);
 return coolTip('<iframe frameborder=0 src='+url+' height='+openHeight+' width='+openWidth+'>',CLOSECLICK,CENTERPOPUP,STICKY,CAPTION,url,HEIGHT,openHeight,WIDTH,openWidth,PUID,'site',KEEPCTD);
}
function getSizeURL(url) {
 var myWidth = 0, myHeight = 0;
 if(typeof(window.innerWidth) == 'number') {
  //Non-IE
  myWidth = window.innerWidth;
  myHeight = window.innerHeight;
 }else if(document.documentElement &&
  (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
  //IE 6+ in 'standards compliant mode'
  myWidth = document.documentElement.clientWidth;
  myHeight = document.documentElement.clientHeight;
 } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
  //IE 4 compatible
  myWidth = document.body.clientWidth;
  myHeight = document.body.clientHeight;
 }
 openWidth = myWidth-30;
 openHeight = myHeight-110;
 var randomnumber=Math.floor(Math.random()*101);
 return coolTip('<iframe frameborder=0 src='+url+' height='+openHeight+' width='+openWidth+'>',CLOSECLICK,CENTERPOPUP,CENTEROFFSET,0,20,STICKY,CAPTION,url,HEIGHT,openHeight,WIDTH,openWidth,PUID,randomnumber,KEEPCTD);
}
function opencooltip(url,wdth,hght,cptn,lid) {
 var myWidth = 0, myHeight = 0;
 if(typeof(window.innerWidth) == 'number') {
  //Non-IE
  myWidth = window.innerWidth;
  myHeight = window.innerHeight;
 }else if(document.documentElement &&
  (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
  //IE 6+ in 'standards compliant mode'
  myWidth = document.documentElement.clientWidth;
  myHeight = document.documentElement.clientHeight;
 } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
  //IE 4 compatible
  myWidth = document.body.clientWidth;
  myHeight = document.body.clientHeight;
 }
 
 if (myHeight < hght) {
 	openHeight = myHeight-50;
 } else {
 	openHeight = hght;
 }
 
 if (myWidth < wdth) {
 	openWidth = myWidth-30;
 } else {
 	openWidth = wdth;
 }
 
 if (lid == 'AddSite' || lid == 'Friends' || lid == 'Widgets') {
 	openHeight = myHeight-110;
 }
 if (lid == 'Widgets') {
 	openWidth = myWidth-50;
 }
 
 return coolTip('<iframe frameborder=0 src='+url+' height='+openHeight+' width='+openWidth+'>',CLOSECLICK,CENTERPOPUP,STICKY,CAPTION,cptn,HEIGHT,openHeight,WIDTH,openWidth,PUID,lid,KEEPCTD);
}
var xmlHttp
var xmlHttp2
function loadcontent(page,start,end,llist){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('hptop')
    element.innerHTML = '<img src=http://sthrt.com/images/ajaxload.gif height=32 width=32 border=0 align=absmiddle />'

	var url="http://sthrt.com/ajax_homepage.php?page="+page+"&start="+start+"&end="+end+"&llist="+llist
	xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = stateChanged
	xmlHttp.send(null)
}
function loadhomepage(page,start,end){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('hptop')
    element.innerHTML = '<img src=http://sthrt.com/images/ajaxload.gif height=32 width=32 border=0 align=absmiddle />'

	var url="http://sthrt.com/ajax_homepage.php?page="+page+"&start="+start+"&end="+end+"&lid="+document.hpchange.hpid.value
	xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = stateChanged
	xmlHttp.send(null)
}
function loadpubliccontent(page,uid,lid){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('hptop')
    element.innerHTML = '<img src=http://sthrt.com/images/ajaxload.gif height=32 width=32 border=0 align=absmiddle />'

	var url="http://sthrt.com/ajax_publichomepage.php?page="+page+"&uid="+uid+"&lid="+lid
	xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = stateChanged
	xmlHttp.send(null)
}
function loadfriend(fid,start,end){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('hptop')
	if (fid == '') { fid = document.friendchange.fid.value }
    element.innerHTML = '<img src=http://sthrt.com/images/ajaxload.gif height=32 width=32 border=0 align=absmiddle />'

	var url="http://sthrt.com/ajax_homepage.php?page=myfriend&fid="+fid+"&start="+start+"&end="+end
	xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = stateChanged
	xmlHttp.send(null)
}
function searchcontent(keywords,start,end,track){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('hptop')
    element.innerHTML = '<img src=http://sthrt.com/images/ajaxload.gif height=32 width=32 border=0 align=absmiddle />'

	var url="http://sthrt.com/ajax_homepage.php?page=search&start="+start+"&end="+end+"&keywords="+keywords+"&track="+track
	xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = stateChanged
	xmlHttp.send(null)
}
function getcoolsites(){ 
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('coolsites')
    element.innerHTML = '<img src=http://sthrt.com/images/ajaxload.gif height=32 width=32 border=0 align=absmiddle />'

	var url="http://sthrt.com/ajax_coolsites.php";
	xmlHttp2.open("GET",url,true)
    xmlHttp2.onreadystatechange = stateChangedCS
	xmlHttp2.send(null)
}
function getpubliccoolsites(){ 
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('publiccoolsites')
    element.innerHTML = '<img src=http://sthrt.com/images/ajaxload.gif height=32 width=32 border=0 align=absmiddle />'

	var url="http://sthrt.com/ajax_publiccoolsites.php";
	xmlHttp2.open("GET",url,true)
    xmlHttp2.onreadystatechange = stateChangedCSP
	xmlHttp2.send(null)
}
function messagecontent(page,start,end,showmessageid){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('messagemain')
    element.innerHTML = '<img src=http://sthrt.com/images/ajaxload.gif height=32 width=32 border=0 align=absmiddle />'

	var url="http://sthrt.com/ajax_messages.php?page="+page+"&start="+start+"&end="+end+"&messageid="+showmessageid
	xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = stateChangedM
	xmlHttp.send(null)
}
function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById('hptop').innerHTML = xmlHttp.responseText;
	}
}
function stateChangedCS() { 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete") { 
		document.getElementById('coolsites').innerHTML = xmlHttp2.responseText;
	}
}
function stateChangedCSP() { 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete") { 
		document.getElementById('publiccoolsites').innerHTML = xmlHttp2.responseText;
	}
}
function stateChangedM() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById('messagemain').innerHTML = xmlHttp.responseText;
	}
}
function messagecount(){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}

	var url="http://sthrt.com/ajax_messages.php?page=messagecount"
	xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = stateChangedC
	xmlHttp.send(null)
}
function stateChangedC() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById('messagecount').innerHTML = xmlHttp.responseText;
	}
}
function invitecount(){ 
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}

	var url="http://sthrt.com/ajax_messages.php?page=invitecount"
	xmlHttp2.open("GET",url,true)
    xmlHttp2.onreadystatechange = stateChangedI
	xmlHttp2.send(null)
}
function stateChangedI() { 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete") { 
		document.getElementById('invitecount').innerHTML = xmlHttp2.responseText;
	}
}
function recordclick(siteid,type){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var url="http://sthrt.com/ajax_validate.php?record=click&siteid="+siteid+"&type="+type
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function recordcoolclick(siteid,type){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var url="http://sthrt.com/ajax_validate.php?record=coolclick&siteid="+siteid+"&type="+type
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function recordopen(siteid,type){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var url="http://sthrt.com/ajax_validate.php?record=open&siteid="+siteid+"&type="+type
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function recordsearch(engine,type,openlink){ 
	if (openlink != 'no') {
		var skeywords = document.getElementById(engine).value
		var keywords = skeywords.replace(/ /, "+")
		var url="http://sthrt.com/ajax_validate.php?record=search&keywords="+keywords+"&engine="+engine+"&type="+type
	} else {
		var url="http://sthrt.com/ajax_validate.php?record=search&keywords=&engine="+engine+"&type="+type
	}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
	if (openlink != 'no') {
		if (type == 'layer') {
			if (engine == 'google') { getSize('http://www.google.com/search?q='+keywords) }
			if (engine == 'yahoo') { getSize('http://search.yahoo.com/search?p='+keywords) }
			if (engine == 'msn') { getSize('http://search.msn.com/results.aspx?q='+keywords) }
		} else if (type == 'tab') {
			if (engine == 'google') { window.open('http://www.google.com/search?q='+keywords, '_tab') }
			if (engine == 'yahoo') { window.open('http://search.yahoo.com/search?p='+keywords, '_tab') }
			if (engine == 'msn') { window.open('http://search.msn.com/results.aspx?q='+keywords, '_tab') }
		} else if (type == 'same') {
			if (engine == 'google') { window.open('http://www.google.com/search?q='+keywords, '_self') }
			if (engine == 'yahoo') { window.open('http://search.yahoo.com/search?p='+keywords, '_self') }
			if (engine == 'msn') { window.open('http://search.msn.com/results.aspx?q='+keywords, '_self') }
		} else if (type == 'new') {
			if (engine == 'google') { window.open('http://www.google.com/search?q='+keywords, '_blank') }
			if (engine == 'yahoo') { window.open('http://search.yahoo.com/search?p='+keywords, '_blank') }
			if (engine == 'msn') { window.open('http://search.msn.com/results.aspx?q='+keywords, '_blank') }
		}
	}
	getcoolsites();
	document.getElementById(engine).value = '';
}
function recordurl(){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	
	var remstring = "";
	var myOldString = document.getElementById('url').value;
	var myNewString = myOldString.replace("http://", remstring);
	myOldString = myNewString;
	myNewString = myOldString.replace("https://", remstring);
	var burl="http://sthrt.com/ajax_validate.php?record=url&browseurl="+myNewString
	xmlHttp.open("GET",burl,true)
	xmlHttp.onreadystatechange = stateChangedBURL
	xmlHttp.send(null)

	var browseurl = document.getElementById('url').value;
	window.open(browseurl, '_blank');
	document.getElementById('url').value = 'http://www.';
}
function stateChangedBURL() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		loadcontent('','','');
	}
}
function deletesite(utsid){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}

	var url="http://sthrt.com/ajax_validate.php?action=remove&utsid="+utsid
	xmlHttp.open("GET",url,true)
    xmlHttp.onreadystatechange = stateChangedDelete
	xmlHttp.send(null)
}
function stateChangedDelete() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		loadcontent('','','');
	}
}
function makepublicusersite(uid){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}

	if (document.getElementById('public').checked == true) {
		var url="http://sthrt.com/ajax_validate.php?action=makepublicusersite&uid="+uid+"&checked=true"
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange = stateChangedmakepublicusersite
		xmlHttp.send(null)
	} else {
		var url="http://sthrt.com/ajax_validate.php?action=makepublicusersite&uid="+uid+"&checked=false"
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange = stateChangedmakepublicusersite
		xmlHttp.send(null)
	}
}
function stateChangedmakepublicusersite() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById('publicurl').innerHTML = xmlHttp.responseText;
	}
}
var plid;
function makepublichomepage(lid){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	plid = lid
	if (document.getElementById('public'+lid).checked == true) {
		var url="http://sthrt.com/ajax_validate.php?action=makepublichomepage&lid="+lid+"&checked=true"
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange = stateChangedmakepublichomepage
		xmlHttp.send(null)
	} else {
		var url="http://sthrt.com/ajax_validate.php?action=makepublichomepage&lid="+lid+"&checked=false"
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange = stateChangedmakepublichomepage
		xmlHttp.send(null)
	}
}
function stateChangedmakepublichomepage() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById('publichp'+plid).innerHTML = xmlHttp.responseText;
	}
}
function sndRequest(vote,id_num,id_user) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var element = document.getElementById('unit_long'+id_num);
    element.innerHTML = '<div style="height: 20px;"><font color="#999999">Loading...</font></div>';
	
    xmlHttp.open("GET", 'http://sthrt.com/ajax_ratings.php?j='+vote+'&q='+id_num+'&t='+id_user,true);
    xmlHttp.onreadystatechange = handleResponse;
    xmlHttp.send(null);
}
function handleResponse() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
        var response = xmlHttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText(update[0], update[1]);
        }
	}
}
function progresshomepage(){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var url="http://sthrt.com/ajax_progress.php?progressid=0"
	xmlHttp.open("GET",url,true)
	//xmlHttp.onreadystatechange = stateChangedURL
	xmlHttp.send(null)
}
function progresslegend(){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request")
	 return
	}
	var url="http://sthrt.com/ajax_progress.php?progressid=4"
	xmlHttp.open("GET",url,true)
	//xmlHttp.onreadystatechange = stateChangedURL
	xmlHttp.send(null)
}
function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"

    if (DOM) {
        var viewer = document.getElementById(div2show)
        viewer.innerHTML=text
    }
    else if(IE) {
        document.all[div2show].innerHTML=text
    }
}
function GetXmlHttpObject() {
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}