function popup (url, name, width, height)
{
  fenster = window.open(url, name, "width="+width+",height="+height+",resizable=yes,scrollbars=yes,left=10,top=0");
  /* fenster.focus(); */
  if (parseInt(navigator.appVersion) >= 4) { fenster.window.focus(); }
}

function loading_image()
{
	img = '<img src="static/img/loading2.gif" alt="Loading" heigh="19" width="220" />';
	document.getElementById('myspan').innerHTML = img;            
}

function preloadimg()
{
	pic1= new Image(); 
	pic1.src="static/img/loading2.gif";	
}

function getNewXMLRequestObject()
{
	var xmlHttpReqObj;
  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttpReqObj=new XMLHttpRequest();
  }
  catch (e)
  {
    // Internet Explorer
    try
    {
      xmlHttpReqObj=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      try
      {
        xmlHttpReqObj=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
        //alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  
  return xmlHttpReqObj;
}

function ajaxFunction(divId, page)
{
  xmlHttpReqObj = getNewXMLRequestObject();
  xmlHttpReqObj.onreadystatechange=function()
  {
    if(xmlHttpReqObj.readyState==4)
    {
      if(xmlHttpReqObj.status  == 200)
      { 
        document.getElementById(divId).innerHTML=xmlHttpReqObj.responseText;
      }
      else
      { 
        alert(xhr.status);
      }
    }
  }
  xmlHttpReqObj.open("GET",page,true);
  xmlHttpReqObj.send(null);
}

// Sending to POST
function makePOSTRequest(url, parameters)
{
  xmlHttpReqObj = getNewXMLRequestObject();
  
  xmlHttpReqObj.onreadystatechange=function()
  {
    if(xmlHttpReqObj.readyState==4)
    {
      if(xmlHttpReqObj.status  == 200)
      {
        document.getElementById('newCommentBox').innerHTML=xmlHttpReqObj.responseText;
	    }
      else
      { 
        //alert(xhr.status);
	    }
    }
  }
    
  xmlHttpReqObj.open('POST', url, true);
  xmlHttpReqObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=iso-8859-1");
  xmlHttpReqObj.setRequestHeader("Content-length", parameters.length);
  xmlHttpReqObj.setRequestHeader("Connection", "close");
  xmlHttpReqObj.send(parameters);
}

function alertContents() {
  if (http_request.readyState == 4) {
  	//alert(http_request.responseText);
  	result = http_request.responseText;
  	document.getElementById('myspan').innerHTML = result;  
  	var ob = document.getElementsByTagName("script");
  	for(var i=0; i<ob.length-1; i++)
    {
  		if(ob[i+1].text!=null) eval(ob[i+1].text);
  	}
  }
}

function getCommentVars(targetUrl, action)
{
  var checkVal = 3;
  for (i=1; i <= 5; i++)
  {
    if (document.getElementById("comm_rating" + i).checked == true)
    {
      checkVal = i;
    }
  }
  
  var poststr = "comm_UserName=" + encodeURI( document.getElementById("comm_UserName").value ) +
		"&comm_UserEmail=" + encodeURI( document.getElementById("comm_UserEmail").value ) +
		"&comm_Message=" + encodeURI( document.getElementById("comm_Message").value ) +
		"&comm_Entry=" + encodeURI( document.getElementById("comm_Entry").value ) +
		"&comm_Captcha=" + encodeURI( document.getElementById("comm_Captcha").value ) +
		"&comm_rating=" + checkVal +
		"&action=" + action ;
  
  makePOSTRequest(targetUrl, poststr);
}

/* Smooth Back to Top */
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0)
        window.setTimeout("backToTop()", 25);
}

/* Decoding Functions */
var base64s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
function decode(encStr)
{ var bits; var decOut = ''; var i = 0;
 for(; i<encStr.length; i += 4)
 {
  bits = (base64s.indexOf(encStr.charAt(i))    & 0xff) <<18 |
         (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 |
         (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 |
          base64s.indexOf(encStr.charAt(i +3)) & 0xff;
  decOut += String.fromCharCode((bits & 0xff0000) >>16, (bits & 0xff00) >>8, bits & 0xff);
 }
 if(encStr.charCodeAt(i -2) == 61)
 {
  return(decOut.substring(0, decOut.length -2));
 }
 else if(encStr.charCodeAt(i -1) == 61)
 {
  return(decOut.substring(0, decOut.length -1));
 }
 else {return(decOut)};
}

/* break out of frames */
if (parent.frames.length > 0)
{
   parent.location.href = self.document.location
}