function hello(){
alert('Hello World');
}
function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

var xmlHttp
//common ajax call
function ajax(url){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateResponse
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function stateResponse() { 
	if (xmlHttp.readyState==4){ 
		if(xmlHttp.responseText != ''){
		document.getElementById('listings').innerHTML=xmlHttp.responseText;
		}
	}
}
//end common ajax call

//TREE
function ajax_fetch(url,elem){
	document.getElementById(elem).style.visibility="visible";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	
	url="fetch_item.php?id="+url+"&sid="+Math.random();

	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function stateChanged() { 
	if (xmlHttp.readyState==4){ 
		document.getElementById('listings').innerHTML=xmlHttp.responseText;
	}
}


function rateProduct(rate,id){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	url="rate_item.php?id="+id+"&rate="+rate+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedRating
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChangedRating() { 
	if (xmlHttp.readyState==4){ 
		document.getElementById('rating').innerHTML=xmlHttp.responseText;
	}
}
function add_comments(id){
	var comm = document.frm.comments.value;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	url="comment_item.php?id="+id+"&comm="+comm+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedComment
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}
function stateChangedComment() { 
	if (xmlHttp.readyState==4){ 
//	alert(xmlHttp.responseText);
		document.getElementById('member_comments').innerHTML=xmlHttp.responseText;
	}
}

//EMAIL VALIDATOR 
function chk_email(action,elem1,elem2,elem3){
	document.getElementById('message').innerHTML= '';
	var email1 = document.frm.elements[elem1].value;
	var email2 = document.frm.elements[elem2].value;
	var screen_name = document.frm.elements[elem3].value;
	if(email1 == email2 && email1 != ''){action='same';}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	url="mailer.php?do="+action+"&email1="+email1+"&email2="+email2+"&screen_name="+screen_name+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChangedEmail
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}
function stateChangedEmail() { 
	if (xmlHttp.readyState==4){ 
		var elem = document.getElementById('message');
		var msg = xmlHttp.responseText;
		elem.innerHTML += msg;
		if(elem.innerHTML != ''){
			document.frm.submit_button.disabled = true;
		} else {
			document.frm.submit_button.disabled = false;
		}
	}
}
//END EMAIL


//functions for saving selected product price and bresk overrides
function ajax_save(url){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	url=url+"&sid="+Math.random();
//	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

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;
}


