function changeiframe(iframe,url){
	window.frames[iframe].location.href=url;
}

function ask(message, url)
{
	if(confirm(message) )
	{
		parent.location.href = url;
	}
}

var ids=new Array('');

function switchid(id){	
	hideallids(id);
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}
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);
}

//ajax("index.php", "q="+quote+"&flash=true&user_id=<?php echo $user_id; ?>","say") ;//alert(quote)
