
  

function opacity(id, opacStart, opacEnd, millisec) {
    if (document.getElementById(id)) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 


function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}



function trim (str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}

  
function overlay() {

        var size = getPageSize();
        var width = size[2];
        var height = size[3];
        var pageheight = size[1];
        var pagewidth = size[0];
        var scrollArray = getPageScroll();
        var scrollNum = scrollArray[1];
        
        var overlay = document.getElementById('overlay');
        overlay.style.display = 'block';
        opacity('overlay',0,89,100);
        overlay.style.top = 0;
        overlay.style.left= 0;
        overlay.style.height = pageheight +'px';
        overlay.style.width = (pagewidth - 15) + 'px';

}

function unpop() {
setTimeout("opacity('overlay',89,0,300);",500);
opacity('helpdiv',100,0,800);
setTimeout("document.getElementById('helpdiv').style.display='none'; document.getElementById('overlay').style.display='none';",1200); 

}

function framepop(e,url,h,w,speed,bgvar,nounpop) {

        var size = getPageSize();
        var width = size[2];
        var height = size[3];
        var pageheight = size[1];
        var pagewidth = size[0];
        var scrollArray = getPageScroll();
        var scrollNum = scrollArray[1];

        var popdiv = document.getElementById('popdiv');
        var popwidth = popdiv.style.width.replace('px','');
        var popheight = popdiv.style.height.replace('px','');
        
        if (h != "") {
        	popheight = h;
        	popdiv.style.height=h;
        }
        if (w != "") {
        	popwidth = w;
        	popdiv.style.width = w;
        
        }
        
        if (bgvar != "") popdiv.style.backgroundColor = bgvar;
        else document.getElementById('popdiv').style.backgroundColor = '#d5d5d5';
        
        if (url != "") document.getElementById('popiframe').src=url;

        popdiv.style.display='';
        
        if (speed == "normal" || speed == "") var delay = 800;
        if (speed == "fast") var delay = 400;
        if (speed == "instant") var delay = 0;
        
        opacity('popdiv',0,100,delay);
        popdiv.style.position='absolute';
        popdiv.style.left = (width - popwidth) / 2;
        popdiv.style.top = scrollNum + ((height  - popheight) / 2);

        if (speed == "normal" || speed == "") var delay = 500;
        if (speed == "fast") var delay = 200;
        if (speed == "instant") var delay = 0;
        
        var overlay = document.getElementById('overlay');
        if (nounpop == 'true') overlay.onclick = '';
        overlay.style.display = 'block';
        opacity('overlay',0,89,delay);
        overlay.style.top = 0;
        overlay.style.left= 0;
        overlay.style.height = pageheight +'px';
        overlay.style.width = (pagewidth - 15) + 'px';


}


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}


function opacity(id, opacStart, opacEnd, millisec) {
    if (document.getElementById(id)) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 
function submitbar(newsid) {
	var subbar = document.getElementById('submitbar' + newsid);
	if (subbar.style.display=='none') subbar.style.display='block';
	else subbar.style.display='none';

}

