// JavaScript Document

function run_dropdowncontent(){
dropdowncontent.init("contentlink", "left-down", 300, "click")
}

function show_user_comment(){
	window.open("view_user_idea.php?requester_id="+requester_id);
}
var xmlhttp_6;
function delete_favorites(site_id)
{
	xmlhttp_6=GetXmlHttpObject();
	if (xmlhttp_6==null)
	{
	alert ("Browser does not support HTTP Request");
	return;
	}
	var url="delete_user_favorites.php";
	url=url+"?site_id="+site_id;
	xmlhttp_6.onreadystatechange=function() {
	if (xmlhttp_6.readyState==4) {
	stateChanged_6();
	}
	};
	xmlhttp_6.open("GET",url,true);
	xmlhttp_6.send(null);
}
function stateChanged_6() 
{
document.getElementById('user_favorites').innerHTML =xmlhttp_6.responseText; 
}

var xmlhttp_5;
function add_favorites(site_id)
{
	xmlhttp_5=GetXmlHttpObject();
	if (xmlhttp_5==null)
	{
	alert ("Browser does not support HTTP Request");
	return;
	}
	var url="add_user_favorites.php";
	url=url+"?site_id="+site_id;
	xmlhttp_5.onreadystatechange=function() {
	if (xmlhttp_5.readyState==4) {
	stateChanged_5();
	}
	};
	xmlhttp_5.open("GET",url,true);
	xmlhttp_5.send(null);
}
function stateChanged_5() 
{
document.getElementById('user_favorites').innerHTML =xmlhttp_5.responseText; 
}

var xmlhttp_4;
function user_score(user_code,site_id)
{
	var form 		= document.score_user;			
	var radio		= form.score;
	var radioLength = radio.length;
	var check 		= 0;
	
	for(var i = 0; i < radioLength; i++) {
		if(radio[i].checked) {
			var score_user=i+1;
			check = 1;		
		}
	}		
	if (check == 0) {
		alert('انتخابی انجام نشده است ، دوباره امتحان کنید');
		return false;
	}
	xmlhttp_4=GetXmlHttpObject();
	if (xmlhttp_4==null)
	{
	alert ("Browser does not support HTTP Request");
	return;
	}
	var url="send_user_score.php";
	url=url+"?score_user="+score_user;
	url=url+"&user_code="+user_code;
	url=url+"&site_id="+site_id;
	xmlhttp_4.onreadystatechange=function() {
	if (xmlhttp_4.readyState==4) {
	stateChanged_4();
	}
	};
	xmlhttp_4.open("GET",url,true);
	xmlhttp_4.send(null);
}
function stateChanged_4() 
{
document.getElementById('user_score').innerHTML =xmlhttp_4.responseText; 
}

var xmlhttp_3;
function show_details_site(site_id)
{
xmlhttp_3=GetXmlHttpObject();
if (xmlhttp_3==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="show_details_site.php";
url=url+"?site_id="+site_id;
xmlhttp_3.onreadystatechange=function() {
if (xmlhttp_3.readyState==4) {
stateChanged_3();
}
};
xmlhttp_3.open("GET",url,true);
xmlhttp_3.send(null);
}
function stateChanged_3() 
{
document.getElementById('show_sites').innerHTML =xmlhttp_3.responseText; 
}

var xmlhttp_2;
function register_sub(sub_id)
{
xmlhttp_2=GetXmlHttpObject();
if (xmlhttp_2==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="register_sub.php";
url=url+"?sub_id="+sub_id;
xmlhttp_2.onreadystatechange=function() {
if (xmlhttp_2.readyState==4) {
stateChanged_2();
}
};
xmlhttp_2.open("GET",url,true);
xmlhttp_2.send(null);
}
function stateChanged_2() 
{
document.getElementById('show_sites').innerHTML =xmlhttp_2.responseText; 
}

var xmlhttp_1;
function register_site(sub_id)
{
xmlhttp_1=GetXmlHttpObject();
if (xmlhttp_1==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="register_site.php";
url=url+"?sub_id="+sub_id;
xmlhttp_1.onreadystatechange=function() {
if (xmlhttp_1.readyState==4) {
stateChanged_1();
}
};
xmlhttp_1.open("GET",url,true);
xmlhttp_1.send(null);
}
function stateChanged_1() 
{
    document.getElementById('show_sites').innerHTML =xmlhttp_1.responseText; 
}
/////////////////////////////////////////////////////////
var xmlhttp_;
function show_sites(sub_id)
{
	xmlhttp_=GetXmlHttpObject();
	
	if (xmlhttp_==null)
	  {
	  alert ("Browser does not support HTTP Request");
	  return;
	  }
	so_clearInnerHTML(document.getElementById('show_sites'));
	var url="include/prodList.php";
	url=url+"?c="+sub_id;
	xmlhttp_.onreadystatechange=function() {
	 if(xmlhttp_.readyState==1){
		document.getElementById('wait').innerHTML = " لطفاً کمی منتظر بمانید";
	 }
	 if(xmlhttp_.readyState==2){
		document.getElementById('wait').innerHTML = " لطفاً کمی منتظر بمانید";
	 }
	 if(xmlhttp_.readyState==3){
		document.getElementById('wait').innerHTML = "لطفاً کمی منتظر بمانید";
	 }
	if (xmlhttp_.readyState==4) {
		document.getElementById('loading').style.visibility="hidden";
	  stateChanged_();
	}else{
			document.getElementById('loading').style.visibility="";
	 }
	};
	xmlhttp_.open("GET",url,true);
	xmlhttp_.send(null);
}
function stateChanged_() 
{
    document.getElementById('show_sites').innerHTML =xmlhttp_.responseText; 
}

var xmlhttp;
function select_site_sub(sub_id)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="select_site_sub.php";
url=url+"?sub_id="+sub_id;
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
  stateChanged();
}
};
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged() 
{
    document.getElementById('select_site_sub').innerHTML =xmlhttp.responseText; 
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function so_clearInnerHTML(obj) {
	// so long as obj has children, remove them
	while(obj.firstChild) obj.removeChild(obj.firstChild);
}

