function changeiframe(iframe,url){
	window.frames[iframe].location.href=url;
}

function ask(message, url)
{
	if(confirm(message) )
	{
		parent.location.href = url;
	}
}


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
function GET(varible) {
	var url = document.location + '';
	q=url.split('?');
	if (q[1]) {
	var pairs = q[1].split('&');
	for (i=0;i<pairs.length;i++) {
	var keyval = pairs[i].split('=');
	if (keyval[0] == varible) {
	var squareid = keyval[1];
	}	}	}	
	return squareid;
}
// this function gets the cookie, if it exists
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 ) );
}
	// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function isset(test){
	if(test+"" == "undefined"){
		return false;
	}else{
		return true;
	}
}
function AttachScript(src)
{
	var script = document.createElement("SCRIPT");
	script.type = "text/javascript";
	document.getElementsByTagName("body")[0].appendChild(script);
	script.src = src;
}
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
function writit(text,id)
{
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = '<P CLASS="testclass">' + text + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}
function appendit(text,id)
{
	if (document.getElementById)
	{
		x = document.getElementById(id);
		//x.innerHTML = '';
		x.innerHTML = x.innerHTML+text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML =  x.innerHTML+text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		//text2 = '<P CLASS="testclass">' + text + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

var http_request = false;
function ajax(url, parameters,callback) {
    http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
       	// set type accordingly to anticipated content type
          //http_request.overrideMimeType('text/xml');
          http_request.overrideMimeType('text/html');
       }
    } else if (window.ActiveXObject) { // IE
       try {
          http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          try {
             http_request = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (e) {}
       }
    }
    if (!http_request) {
       //alert('Cannot create XMLHTTP instance');
       return false;
    }
    
    http_request.onreadystatechange = function alertContents() {
		if (http_request.readyState == 4) {
		        if (http_request.status == 200) {
		           //alert(http_request.responseText);
		           result = http_request.responseText;
		           eval(callback+"(result)");
		          // say(result)//document.getElementById('myspan').innerHTML = result;            
		        } else {
		           //alert('There was a problem with the request.');
		        }
		     }
		};
    http_request.open('POST', url, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
}

function pageWidth() {
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 
function pageHeight() {
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
} 
function posLeft() {
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}
function posTop() {
return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}
function posRight() {return posLeft()+pageWidth();} 
function posBottom() {return posTop()+pageHeight();}
    
	
	
function moveDiv(id,x,y){
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.position = "absolute";
		document.getElementById(id).style.top = y;
		document.getElementById(id).style.left = x;
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.position = "absolute";
			document.id.top = y;
			document.id.left = x;				
		}
		else { // IE 4
			document.all.id.style.position = "absolute";
			document.all.id.style.top = y;
			document.all.id.style.left = x;				
		}
	}	
}

function centerCoords(width,height){
	coords = Array();
	coords["x"]=(pageWidth()/2)+posLeft()-(width/2);
	coords["y"]=(pageHeight()/2)+posTop()-(height/2);
	return coords;
}
function resizeElement (id,width,height) {

	var i = document.getElementById(id);
	i.style.height = height + 'px';
	i.style.width = width + 'px';
}

function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	var xy;
	xy["x"] = tempX;
	xy["y"] = tempY;
	
	//document.Show.MouseX.value = tempX;
	//document.Show.MouseY.value = tempY;
	return xy;
}

function goBrowser(url){
	showdiv("outbounddiv");
	changeiframe("outboundframe",url);
	scroll(0,0);
	//coords = centerCoords(800,500);
	//moveDiv("outbounddiv",posLeft(),posTop());
}
function closeBrowser(){
	changeiframe("outboundframe","about:blank");
	hidediv("outbounddiv");
}