// Cookie Functions

function setcookie(c_name,c_value,c_expire, c_path, c_domain, c_secure) {
	// c_expire unit is seconds
	
	//need to check to see if a cookie exists with the same name since it will not automatically overwrite it. 
	
	cookie_value = c_name+"="+escape(c_value) ;
	
	if (c_expire == null) {
		cookie_value += "" ;
	}
	else {
		c_expire = c_expire / (60 * 60 * 24) ;
		var exdate=new Date() ;
		exdate.setDate(exdate.getDate()+c_expire) ;
		cookie_value += "; expires="+exdate.toGMTString() ;
	}
	
	if (c_path != null) {
		cookie_value += "; path="+escape(c_path) ;
	}
	
	if (c_domain != null) {
		cookie_value += "; domain="+escape(c_domain) ;
	}
	
	if (c_secure != null && c_secure != false && c_secure != 'false') {
		cookie_value += "; secure" ;
	}
		
	document.cookie = cookie_value ;
}

function getcookie(c_name) {
	if (document.cookie.length>0) {
		c_start = document.cookie.indexOf(c_name + "=") ;
		
		if (c_start != -1) { 
			c_start = c_start + c_name.length+1 ; 
			c_end = document.cookie.indexOf(";",c_start) ;
			
			if (c_end == -1) {
				c_end = document.cookie.length ;
			}
			
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	
	return null;
}

// String Functions

function replaceAll(find, replace, string) {
	while (string.search(find) >= 0) {
		string = string.replace(find, replace);
	}
	
	return string;
}

// Ajax Functions

var xmlHttp ;

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
return xmlHttp;
}

/*
function exampleAjax(value) {
	if (value != "") {
		xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null) {
			alert ("Your browser does not support AJAX!");
			return;
		} 
				
		var url="ajax_script_name.php";
		url=url+"?sid="+Math.random();
		url=url+"?ajax=true";
		
		url=url+"&value="+value;
		
		xmlHttp.onreadystatechange=exampleAjaxStateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function exampleAjaxStateChanged() {
	if (xmlHttp.readyState == 4) {
		var return_html = xmlHttp.responseText;
		aler(return_html);
	}
}
*/

