bV  = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"

try{var dialogcontainer = document.getElementById('dialogcontainer');}
catch(e) {}
function switchBlock(id){document.getElementById(id).style.display="block";}
function switchNone(id){document.getElementById(id).style.display="none";}
function init(){}
function theme(i){
	document.getElementById('theme').style.backgroundImage="url(../lib/themes/theme"+i+".jpg)";
}
function submitForm(form){
	sMsg="";
	switch(form){
		case "linksubmit":
			var slink=document.getElementById('link');
			if(slink.value=="" || slink.value=="Submit link"){alert("Please enter a website.");slink.select();return false;}
			sSubmit="&link="+slink.value;
			sMsg="Your link is submitted for reviewing.\n\nThank's for the tip!";
			// clear form
			slink.value='';
		break;
		case "newsletter":
			var newsletter=document.getElementById('newsletter');
			if(newsletter.value=="" || newsletter.value=="E-mail for newsletter"){alert("Please enter your e-mail address.");newsletter.select();return false;}
			sSubmit="&newsletter="+newsletter.value;
			sMsg="Thank you for submitting for the newsletter.\nWe will never use your e-mail address for other purposes than an occasional update from this site.";
			// clear form
			newsletter.value='';
		break;
	}
	if(sSubmit != "") xmlHTTPRequest('submit.php', 'POST', "form=" + form + sSubmit);
	if(sMsg != "") alert(sMsg);
}
/* dialog functions */
function dialog(dlg,a){
	document.getElementById('dialogcontainer').innerHTML = "<div class=\"dialog-container\" style=\"width:135px;\"><font style=\"font-size:23px;font-weight:bold;color:#000000;z-index:2;position:absolute;\">Loading...</font><font style=\"position:relative;left:2px;top:2px;font-size:23px;font-weight:bold;color:#ffffff;z-index:1;\">Loading...</font></div>";
	document.getElementById('dialogcontainer').style.visibility = "visible";
	setTimeout("render_dialog('"+dlg+"','"+a+"')",1);
}
function render_dialog(dlg,a){
	switch(dlg)	{
		case "checkpuzzle":var header = "Check puzzle";var page=loc+"lib/dialogs/sudoku.php?action=check&answer="+a;var width=120;break;
	}
	var dialogInnerHTML = "";
	dialogInnerHTML += "<div class=\"dialog-container\" style=\"width:"+(width + 18)+"px;\">";
	dialogInnerHTML += "<div class=\"\dialog-header-shadow\">" + header + "</div><div class=\"\dialog-header\">" + header + "</div>";
	dialogInnerHTML += "<span class=\"d-close\"><a href=\"javascript:void(0);\" onclick=\"document.getElementById('dialogcontainer').style.visibility = 'hidden';\" onmouseover=\"document.getElementById('dclose').src='"+loc+"lib/images/dialog/btn_close_hi.gif'\" onmouseout=\"document.getElementById('dclose').src='"+loc+"lib/images/dialog/btn_close.gif'\"><img id=\"dclose\" title=\"Close window\" src=\""+loc+"lib/images/dialog/btn_close.gif\" border=\"0\" /></a></span>";
	dialogInnerHTML += xmlHTTPRequest(page, "GET", null);
	dialogInnerHTML += "</div>";

	document.getElementById('dialogcontainer').innerHTML = dialogInnerHTML;
}
function dateAdd(intval, numb, base){
	/*intval is YYYY, M, D, H, N, S as in VBscript; numb is amount +/-; base is javascript date object*/
	switch(intval){
		case "M":
			base.setMonth(base.getMonth() + numb);
			break;
		case "YYYY":
			base.setFullYear(base.getFullYear() + numb);
			break;
		case "D":
			base.setDate(base.getDate() + numb);
			break;
		case "H":
			base.setHours(base.getHours() + numb);
			break;
		case "N":
			base.setMinutes(base.getMinutes() + numb);
			break;
		case "S":
			base.setSeconds(base.getSeconds() + numb);
			break;
		default:
	}
	return base
}
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}
function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
function correctPNG()
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + 
img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" 
+ imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
window.attachEvent("onload", correctPNG);

/* XMLHTTP functions 0.2 */
function xmlHTTPRequest(url, method, data) {
  if (!method) method = "GET";
  if (!data) data = null;
  req = xmlHTTPRequestObject();

  if (req) {
   req.open (method, url, false);
   if(method=="POST") req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
   req.send (data);
   return req.responseText;
  }
  return false;
}
function xmlHTTPAsyncRequest(url, method, data, callbackr) {
  if (!method) method = "GET";
  if (!data) data = null;
  req = xmlHTTPRequestObject();
  if (req) {
   eval ('req.onreadystatechange = ' + callbackr + ';');
 req.open (method, url, true);
 req.send (data);
 return req
  }
}
function xmlHTTPRequestObject() {
 var obj = false;
 var objectIDs = new Array(
  "Microsoft.XMLHTTP",
  "Msxml2.XMLHTTP",
  "MSXML2.XMLHTTP.3.0",
  "MSXML2.XMLHTTP.4.0"
 );
 var success = false;

 for (i=0; !success && i < objectIDs.length; i++) {
  try {
   obj = new ActiveXObject(objectIDs[i]);
   success = true;
  } catch (e) { obj = false; }
 }

 if (!obj)
  obj = new XMLHttpRequest();

 return obj;
}
function isXMLHTTPRequestSupported() {
 return xmlHTTPRequestObject != null;
}