﻿//************************************************************
var tr;
var tdhead;
var tdimg;
var newscode;
var nowback;
var http = gethttp();
var params;
var url;
//************************************************************
function gethttp()
{
	var xmlhttp;
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
		catch(c)
		{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(c)
		{
			if (typeof XMLHttpRequest != 'undefiend')
			{
			xmlhttp = new XMLHttpRequest();
			}
		}
		}
return xmlhttp;		
}
//************************************************************
function answer()
{
if (http.readyState == 4)
	{
		$r = http.responseText;
		if ($r != "no")
			{
				alert("ركورد مورد نظر حذف شد"+$r); $r = parseInt($r);
				$thistable = document.getElementById($r).parentNode;
				$thisrow = document.getElementById($r);
				$thistable.removeChild($thisrow);
			}
		else
			alert("اشكال در حذف");
	}
}
//************************************************************
function del(type,code)
{
http.open("GET","del.php?type="+type+"&code="+code,true);
http.onreadystatechange = answer;
http.send(null);
}
//************************************************************
function answerdellink()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		if (r != "no")
			{
				thistable = document.getElementById(r).parentNode;
				thisrow = document.getElementById(r);
				thistable.removeChild(thisrow);
			}
		else
			alert("اشكال در حذف");
	}
}
//************************************************************
function dellink(number)
{
http.open("GET","dellink.php?number="+number,true);
http.onreadystatechange = answerdellink;
http.send(null);
}
//************************************************************
function answerdellinksection()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		if (r != "no")
			{	
			window.location=("links_management.php");
			}
		else
			alert("اشكال در حذف");
	}
}
//************************************************************
function dellinksection(number)
{
http.open("GET","delete_links_sections.php?number="+number,true);
http.onreadystatechange = answerdellinksection;
http.send(null);
}
//=======================NEWS==================================
//*************************************************************
function showfullnews(group)
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showfullnews.php?group="+group,true);
http.onreadystatechange = answershowfullnews;
http.send(null);

}
//*************************************************************
function answershowfullnews()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById("main_div").innerHTML=r;
		document.getElementById('wait_div').style.visibility="hidden";
		
	}
}
//*************************************************************
function sendnews(code)
{
newscode = code;
document.getElementById('head_'+code).innerHTML="";
document.getElementById('head_'+code).innerHTML = "<br /><img src='images/site/wait.gif' >";
http.open("GET","fronted/shownews.php?code="+code,true);
http.onreadystatechange = answershownews;
http.send(null);	
}
//************************************************************
function answershownews()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		
	
		document.getElementById('head_'+newscode).innerHTML="";
		document.getElementById('head_'+newscode).innerHTML=r;
		
document.getElementById('head_'+newscode).innerHTML += "<br /><table align='right' bgcolor='#ffffff'><tr><td colspan='2' align='right'><img onclick='backnews("+newscode+");' src='images/site/back_news.png' /></td></tr><tr><td colspan='2' width='300px' height='17px' style='background-image:url(images/site/usercalltop.png); background-position:center; background-repeat:no-repeat'></td></tr><tr><td width='7px' height='250px' style='background-image:url(images/site/usercallright.png); background-position:center; background-repeat:no-repeat'></td><td width='300px' style='vertical-align:top' align='right'><table align='right'><tr><td align='right' style='vertical-align:top' colspan='2'><img src='images/site/usercallpic.png' /></td></tr><tr><td height='20px;'></td></tr><tr><td align='left' dir='rtl' style='color:#003399; font-size:11px;'><lable style='color:#003399; font-size:11px;'>نام و نام خانوادگي :</lable></td><td align='right'><input type='text' style='color:#225ACD; font-size:11px;' id='name"+newscode+"' dir='rtl' size='25' default=''></td></tr><tr><td align='left' dir='rtl' style='color:#003399; font-size:11px;'><lable style='color:#003399; font-size:11px;'>پست الكترونيك :</lable></td><td align='right'><input type='text' default='' id='email"+newscode+"' style='color:#225ACD; font-size:11px;' dir='ltr' size='25'></td></tr><tr><td align='left' style='color:#003399; font-size:11px;'><lable style='color:#003399; font-size:11px;'>*نظر شما :</lable></td></tr><tr><td style='vertical-align:top;' align='left' colspan='2'><textarea style='color:#0000CC; font-family:Tahoma; font-size:11px' cols='39' rows='8' id='text"+newscode+"'></textarea></td></tr><tr><td colspan='2' id='usercallerror' style='color:#ff0000; font-size:11px;'></td></tr><tr><td colspan='2' align='center'><input type='button' value='&nbsp;&nbsp;ارسال&nbsp;&nbsp;' onclick='javascript:sendusercall_news("+newscode+");'><img src='images/site/send_usercall.gif' id='usercallimg"+newscode+"' style='visibility:hidden;' /></td></tr><tr><td colspan='2'><ul><li style='color:#003366; font-size:11px;' align='right'>نوشتن نام و پست الكترونيك اختياري مي باشد</li></ul></td></tr><tr><td colspan='2' style='color:#29761D; font-size:11px;' align='right' id='usercallnote"+newscode+"'></td></tr></table></td></tr><tr><td colspan='2' width='300px' height='17px' style='background-image:url(images/site/usercalldown.png); background-position:center; background-repeat:no-repeat'></td></tr></table>";		


	}
}
//***********************************************************
function sendusercall_news(code)
{
	newscode = code;
document.getElementById('usercallimg'+newscode).style.visibility = 'visible';
document.getElementById('usercallnote'+newscode).innerHTML = 'در حال ارسال نظر...';

$code = code;
$name = document.getElementById('name'+newscode).value;
$email = document.getElementById('email'+newscode).value;
$text = document.getElementById('text'+newscode).value;

if(($text != '&nbsp;') && ($text != ''))
{
	
params = "code="+$code+"&name="+$name+"&email="+$email+"&text="+$text;
url = "fronted/sendusercall_news.php";
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = answersendusercall_news;
http.send(params);
}
else
{
	alert('لطفا نظر خود را وارد كنيد');
document.getElementById('usercallimg'+newscode).style.visibility = 'hidden';
document.getElementById('usercallnote'+newscode).innerHTML = '';
}
}
//***********************************************************
function answersendusercall_news()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		if(r == 'ok')
		{
document.getElementById('usercallimg'+newscode).style.visibility = 'hidden';
document.getElementById('usercallnote'+newscode).innerHTML = 'نظر شما با موفقيت ارسال شد';	
document.getElementById('email'+newscode).value = '';
document.getElementById('name'+newscode).value = '';
document.getElementById('text'+newscode).value = '';
		}
		else if(r == 'no')
		{
document.getElementById('usercallimg'+newscode).style.visibility = 'hidden';
document.getElementById('usercallnote'+newscode).innerHTML = 'متاسفانه هم اكنون امكان ارسال نظر شما ميسر نيست';			
		}
		else
		{
document.getElementById('usercallnote'+newscode).innerHTML = r;			
		}

	}
}

//***********************************************************
function backnews(code)
{
	newscode = code;
document.getElementById('head_'+code).innerHTML="";
document.getElementById('head_'+code).innerHTML = "<br /><img src='images/site/wait.gif' >";
http.open("GET","fronted/backnews.php?code="+newscode,true);
http.onreadystatechange = answerbacknews;
http.send(null);
}
//***********************************************************
function answerbacknews()
{

if (http.readyState == 4)
	{
		r = http.responseText;
//document.getElementById('head_'+newscode).innerHTML = "";
document.getElementById('head_'+newscode).innerHTML = r;

	}
}
//*************************************************************
function showarticle(code)
{
newscode = code;

document.getElementById("main_div").innerHTML = "";
document.getElementById("wait_div").style.visibility = "visible";

http.open("GET","fronted/showarticle.php?code="+code,true);
http.onreadystatechange = answershowarticle;
http.send(null);
}
//************************************************************
function answershowarticle()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_div").style.visibility = "hidden";		
		document.getElementById("main_div").innerHTML = r;
	}
}
//****************************************************************
function showconversation(code)
{
newscode = code;

document.getElementById("main_div").innerHTML = "";
document.getElementById("wait_div").style.visibility = "visible";

http.open("GET","fronted/showconversation.php?code="+code,true);
http.onreadystatechange = answershowconversation;
http.send(null);
}
//************************************************************
function answershowconversation()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_div").style.visibility = "hidden";		
		document.getElementById("main_div").innerHTML = r;
	}
}
//****************************************************************
function showtalks(code)
{
newscode = code;

document.getElementById("main_div").innerHTML = "";
document.getElementById("wait_div").style.visibility = "visible";

http.open("GET","fronted/showsays.php?code="+code,true);
http.onreadystatechange = answershowconversation;
http.send(null);
}
//************************************************************
function answershowtalks()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_div").style.visibility = "hidden";		
		document.getElementById("main_div").innerHTML = r;
	}
}
//****************************************************************
function showhistory(code)
{
newscode = code;

document.getElementById("main_div").innerHTML = "";
document.getElementById("wait_div").style.visibility = "visible";

http.open("GET","fronted/showhistory.php?code="+code,true);
http.onreadystatechange = answershowhistory;
http.send(null);
}
//************************************************************
function answershowhistory()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_div").style.visibility = "hidden";		
		document.getElementById("main_div").innerHTML = r;
	}
}
//****************************************************************
function showselectednews(code)
{
newscode = code;

document.getElementById("main_div").innerHTML = "";
document.getElementById("wait_div").style.visibility = "visible";

http.open("GET","fronted/showselectednews.php?code="+code,true);
http.onreadystatechange = answershowselectednews;
http.send(null);
}
//************************************************************
function answershowselectednews()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_div").style.visibility = "hidden";		
		document.getElementById("main_div").innerHTML = r;
	}
}


//*************************************************************
function showfullbooks()
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showfullbooks.php",true);
http.onreadystatechange = answershowfullbooks;
http.send(null);

}
//*************************************************************
function answershowfullbooks()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;
		
		
	}
}
//*************************************************************

function sendbook(code)
{
newscode = code;
document.getElementById("main_div").innerHTML="";
document.getElementById('wait_div').style.visibility="visible";
http.open("GET","fronted/showbook.php?code="+code,true);
http.onreadystatechange = answersendbook;
http.send(null);	
}
//************************************************************
function answersendbook()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		
		document.getElementById("main_div").innerHTML="";
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML = r;

	}
}
//*************************************************************
function shohada(kind)
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showshohada.php?kind="+kind,true);
http.onreadystatechange = answershohada;
http.send(null);

}
//*************************************************************
function answershohada()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;
		
		
	}
}
//*************************************************************

function shahid(code)
{
newscode = code;
document.getElementById("main_div").innerHTML="";
document.getElementById('wait_div').style.visibility="visible";
http.open("GET","fronted/showshahid.php?code="+code,true);
http.onreadystatechange = answershahid;
http.send(null);	
}
//************************************************************
function answershahid()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		
		document.getElementById("main_div").innerHTML="";
		document.getElementById('wait_div').style.visibility="hidden";		
		document.getElementById("main_div").innerHTML = r;

	}
}
//****************************************************************
function showfullgallery()
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showsfullgallery.php",true);
http.onreadystatechange = answershowsfullgallery;
http.send(null);

}
//*************************************************************
function answershowsfullgallery()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;
		
		
	}
}
//*************************************************************
function sendgallery(code)
{
newscode = code;	
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showsgallery.php?code="+code,true);
http.onreadystatechange = answersendgallery;
http.send(null);

}
//*************************************************************
function answersendgallery()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//************************************************************
function showpic(group,name)
{
	window.open("images/gallery/"+group+"/"+group+"_"+name+".jpg");
}
//*************************************************************
function openwin(address)
{
	window.open("http://"+address);
}
//*************************************************************
function showaboutmalayer(code)
{
newscode = code;	
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showaboutmalayer.php?code="+code,true);
http.onreadystatechange = answeraboutmalayer;
http.send(null);

}
//*************************************************************
function answeraboutmalayer()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//*************************************************************
function showeplace(group,num)
{

document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showeplace.php?group="+group+"&num="+num,true);
http.onreadystatechange = answershoweplace;
http.send(null);

}
//*************************************************************
function answershoweplace()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//*************************************************************
function showpplace(group,num)
{

document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showpplace.php?group="+group+"&num="+num,true);
http.onreadystatechange = answershoweplace;
http.send(null);

}
//*************************************************************
function answershowpplace()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//***************************************************************
function archive_n(ty,year,month)
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/archive_n.php?years="+year+"&months="+month+"&type="+ty,true);
http.onreadystatechange = answerarchive_n;
http.send(null);

}
//*************************************************************
function answerarchive_n()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//***************************************************************
function archive_a(year,month)
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/archive_a.php?years="+year+"&months="+month,true);
http.onreadystatechange = answerarchive_a;
http.send(null);

}
//*************************************************************
function answerarchive_a()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//*************************************************************
function show_arch_article(code)
{
newscode = code;

document.getElementById("arch_a_text").innerHTML = "";
document.getElementById("wait_arch").style.visibility = "visible";

http.open("GET","fronted/show_arch_article.php?code="+code,true);
http.onreadystatechange = answershow_arch_article;
http.send(null);
}
//************************************************************
function answershow_arch_article()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_arch").style.visibility = "hidden";		
		document.getElementById("arch_a_text").innerHTML = r;
	}
}
//***************************************************************
function archive_c(year,month)
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/archive_c.php?years="+year+"&months="+month,true);
http.onreadystatechange = answerarchive_c;
http.send(null);

}
//*************************************************************
function answerarchive_c()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//*************************************************************
function show_arch_con(code)
{
newscode = code;

document.getElementById("arch_c_text").innerHTML = "";
document.getElementById("wait_arch").style.visibility = "visible";

http.open("GET","fronted/show_arch_con.php?code="+code,true);
http.onreadystatechange = answershow_arch_con;
http.send(null);
}
//************************************************************
function answershow_arch_con()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_arch").style.visibility = "hidden";		
		document.getElementById("arch_c_text").innerHTML = r;
	}
}
//***************************************************************
function archive_t(year,month)
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/archive_t.php?years="+year+"&months="+month,true);
http.onreadystatechange = answerarchive_t;
http.send(null);

}
//*************************************************************
function answerarchive_t()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//*************************************************************
function show_arch_t(code)
{
newscode = code;

document.getElementById("arch_t_text").innerHTML = "";
document.getElementById("wait_arch").style.visibility = "visible";

http.open("GET","fronted/show_arch_t.php?code="+code,true);
http.onreadystatechange = answershow_arch_t;
http.send(null);
}
//************************************************************
function answershow_arch_t()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_arch").style.visibility = "hidden";		
		document.getElementById("arch_t_text").innerHTML = r;
	}
}
//***************************************************************
function archive_h(year,month)
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/archive_h.php?years="+year+"&months="+month,true);
http.onreadystatechange = answerarchive_h;
http.send(null);

}
//*************************************************************
function answerarchive_h()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;

	}
}
//*************************************************************
function show_arch_h(code)
{
newscode = code;

document.getElementById("arch_h_text").innerHTML = "";
document.getElementById("wait_arch").style.visibility = "visible";

http.open("GET","fronted/show_arch_h.php?code="+code,true);
http.onreadystatechange = answershow_arch_h;
http.send(null);
}
//************************************************************
function answershow_arch_h()
{
if (http.readyState == 4)
	{
		r = http.responseText;
document.getElementById("wait_arch").style.visibility = "hidden";		
		document.getElementById("arch_h_text").innerHTML = r;
	}
}
//*************************************************************
function showpopulars()
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/showpopulars.php",true);
http.onreadystatechange = answershowpopulars;
http.send(null);

}
//*************************************************************
function answershowpopulars()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;
		
		
	}
}
//*************************************************************

function sendpopular(code)
{
newscode = code;
document.getElementById("main_div").innerHTML="";
document.getElementById('wait_div').style.visibility="visible";
http.open("GET","fronted/showpopular.php?code="+code,true);
http.onreadystatechange = answersendpopular;
http.send(null);	
}
//************************************************************
function answersendpopular()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		
		document.getElementById("main_div").innerHTML="";
		document.getElementById('wait_div').style.visibility="hidden";		
		document.getElementById("main_div").innerHTML = r;

	}
}
//*************************************************************
function aboutus()
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/aboutus.php",true);
http.onreadystatechange = answeraboutus;
http.send(null);

}
//*************************************************************
function answeraboutus()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;
		
		
	}
}
//*************************************************************
function contactus()
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/contactus.php",true);
http.onreadystatechange = answercontactus;
http.send(null);

}
//*************************************************************
function answercontactus()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;
		
		
	}
}
//*************************************************************

function sendcontacts()
{

document.getElementById('name_error').style.visibility="hidden";
document.getElementById('message_error').style.visibility="hidden";
document.getElementById('contact_thanks').style.visibility="hidden";
document.getElementById('contact_wait').style.visibility="visible";
$name = document.getElementById('name').value;
$email = document.getElementById('email').value;
$message = document.getElementById('message').value;	
$date = document.getElementById('date').value;	
$ip = document.getElementById('ip').value;	
document.getElementById('name').value = "";
document.getElementById('email').value = "";	
document.getElementById('message').value = "";
url="fronted/savecontacts.php";
params = "name="+$name+"&email="+$email+"&message="+$message+"&date="+$date+"&ip="+$ip;
http.open("POST", url, true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = answersendcontacts;
http.send(params);	 

}
//************************************************************
function answersendcontacts()
{

if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('contact_wait').style.visibility="hidden";	
		if(r == 'ok')
{document.getElementById('contact_thanks').style.visibility="visible";}
		else if(r == 'name')
{document.getElementById('name_error').style.visibility="visible";}
		else if(r == 'message')
{document.getElementById('message_error').style.visibility="visible";}					
		else if(r == '')
{document.getElementById('contact_wait').style.visibility="hidden";}			
	}

	document.getElementById('contact_wait').style.visibility="hidden";
	document.getElementById('contact_thanks').style.visibility="visible";
}
//*************************************************************
function sitesearch()
{
document.getElementById("main_div").innerHTML = "";	
document.getElementById("wait_div").style.visibility = "visible";
http.open("GET","fronted/sitesearch.php",true);
http.onreadystatechange = answersitesearch;
http.send(null);

}
//*************************************************************
function answersitesearch()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		document.getElementById('wait_div').style.visibility="hidden";
		document.getElementById("main_div").innerHTML=r;
		
		
	}
}
//**************************************************************
var search_type = 'titles';
var search_sort = 'begin';
function gosearch()
{
	
	document.getElementById('text_error').innerHTML = '';				
	document.getElementById('date_error').innerHTML = '';	
	
	$text =  encodeURI(document.getElementById('usertext').value);
	$tables = document.getElementById('tables').value;
	$begin_day = document.getElementById('begin_day').value;
	$begin_month = document.getElementById('begin_month').value;
	$begin_year = document.getElementById('begin_year').value;	
	$end_day = document.getElementById('end_day').value;
	$end_month = document.getElementById('end_month').value;
	$end_year = document.getElementById('end_year').value;	
	
		if(($text == "")||($text == " "))
		{
	document.getElementById('text_error').innerHTML = 'عبارت مورد جستجو خاليست';	
		}
		else 
		if($begin_year > $end_year)
		{
		document.getElementById('date_error').innerHTML = 'تاريخ آغاز از پايان بزرگتر است';	
		}
		else
		if(($begin_year == $end_year) && ($begin_month > $end_month))
		{
		document.getElementById('date_error').innerHTML = 'تاريخ آغاز از پايان بزرگتر است';			
		}
		else
		if(($begin_year == $end_year) && ($begin_month == $end_month)&&($begin_day > $end_day))
		{
		document.getElementById('date_error').innerHTML = 'تاريخ آغاز از پايان بزرگتر است';			
		}
		else
		{
document.getElementById("search_wait").style.visibility = 'visible';
	document.getElementById('text_error').innerHTML = '';				
	document.getElementById('date_error').innerHTML = '';	
http.open("GET","fronted/gosearch.php?type="+search_type+"&ssort="+search_sort+"&tables="+$tables+"&begin_day="+$begin_day+"&begin_month="+$begin_month+"&begin_year="+$begin_year+"&end_day="+$end_day+"&end_month="+$end_month+"&end_year="+$end_year+"&text="+$text,true);
http.onreadystatechange = answergosearch;
http.send(null);
		}
}
//*************************************************************
function answergosearch()
{
if (http.readyState == 4)
	{
		r = http.responseText;
		if(r == 'text_error')
		{
document.getElementById("search_wait").style.visibility = 'hidden';				
	document.getElementById('text_error').innerHTML = 'استفاده از كاراكترهاي $ ، < ، > ، = ، & امكانپذير نمي باشد';			
		}
		else
		{
document.getElementById("search_wait").style.visibility = 'hidden';			
		document.getElementById('main_div').innerHTML="";
		document.getElementById("main_div").innerHTML = r;
		}
		
	}
}
//****************************************************************
function showsearchnews(code)
{
	newscode = code;
document.getElementById("arch_show_"+code+"_img").style.visibility = "visible";

http.open("GET","fronted/showsearchnews.php?code="+code,true);
http.onreadystatechange = answershowsearchnews;
http.send(null);
}
//************************************************************
function answershowsearchnews()
{

if (http.readyState == 4)
	{
document.getElementById("arch_show_"+newscode+"_img").style.visibility = "hidden";		
		r = http.responseText;
		document.getElementById("arch_show_"+newscode).innerHTML = r;
		document.getElementById("arch_show_"+newscode).innerHTML += "<img src='images/site/back_news.png' onclick='javascript:close_search_news("+newscode+");' />";		
	}
}
//************************************************************
function close_search_news(thiscode)
{
	document.getElementById("arch_show_"+thiscode).innerHTML = "";
}
//****************************************************************
function showsearcharts(code)
{
	newscode = code;
document.getElementById("arch_show_"+code+"_img").style.visibility = "visible";

http.open("GET","fronted/showsearcharts.php?code="+code,true);
http.onreadystatechange = answershowsearcharts;
http.send(null);
}
//************************************************************
function answershowsearcharts()
{

if (http.readyState == 4)
	{
document.getElementById("arch_show_"+newscode+"_img").style.visibility = "hidden";		
		r = http.responseText;
		document.getElementById("arch_show_"+newscode).innerHTML = r;
		document.getElementById("arch_show_"+newscode).innerHTML += "<img src='images/site/back_news.png' onclick='javascript:close_search_arts("+newscode+");' />";		
	}
}
//************************************************************
function close_search_arts(thiscode)
{
	document.getElementById("arch_show_"+thiscode).innerHTML = "";
}
//****************************************************************
function showsearchcon(code)
{
	newscode = code;
document.getElementById("arch_show_"+code+"_img").style.visibility = "visible";

http.open("GET","fronted/showsearchcon.php?code="+code,true);
http.onreadystatechange = answershowsearchcon;
http.send(null);
}
//************************************************************
function answershowsearchcon()
{

if (http.readyState == 4)
	{
document.getElementById("arch_show_"+newscode+"_img").style.visibility = "hidden";		
		r = http.responseText;
		document.getElementById("arch_show_"+newscode).innerHTML = r;
		document.getElementById("arch_show_"+newscode).innerHTML += "<img src='images/site/back_news.png' onclick='javascript:close_search_con("+newscode+");' />";		
	}
}
//************************************************************
function close_search_con(thiscode)
{
	document.getElementById("arch_show_"+thiscode).innerHTML = "";
}
//****************************************************************
function showsearchtalk(code)
{
	newscode = code;
document.getElementById("arch_show_"+code+"_img").style.visibility = "visible";

http.open("GET","fronted/showsearchtalk.php?code="+code,true);
http.onreadystatechange = answershowsearchtalk;
http.send(null);
}
//************************************************************
function answershowsearchtalk()
{

if (http.readyState == 4)
	{
document.getElementById("arch_show_"+newscode+"_img").style.visibility = "hidden";		
		r = http.responseText;
		document.getElementById("arch_show_"+newscode).innerHTML = r;
		document.getElementById("arch_show_"+newscode).innerHTML += "<img src='images/site/back_news.png' onclick='javascript:close_search_talk("+newscode+");' />";		
	}
}
//************************************************************
function close_search_talk(thiscode)
{
	document.getElementById("arch_show_"+thiscode).innerHTML = "";
}
//****************************************************************
function showsearchhis(code)
{
	newscode = code;
document.getElementById("arch_show_"+code+"_img").style.visibility = "visible";

http.open("GET","fronted/showsearchhis.php?code="+code,true);
http.onreadystatechange = answershowsearchhis;
http.send(null);
}
//************************************************************
function answershowsearchhis()
{

if (http.readyState == 4)
	{
document.getElementById("arch_show_"+newscode+"_img").style.visibility = "hidden";		
		r = http.responseText;
		document.getElementById("arch_show_"+newscode).innerHTML = r;
		document.getElementById("arch_show_"+newscode).innerHTML += "<img src='images/site/back_news.png' onclick='javascript:close_search_his("+newscode+");' />";		
	}
}
//************************************************************
function close_search_his(thiscode)
{
	document.getElementById("arch_show_"+thiscode).innerHTML = "";
}
//***************************************************
function savenazar($answer)
{
document.getElementById("divnazar").innerHTML = '';	
document.getElementById('nazarpic').style.visibility = 'visible';
http.open("GET","sendusernazar.php?answer="+$answer,true);
http.onreadystatechange = answersavenazar;
http.send(null);
}
//************************************************************
function answersavenazar()
{

if (http.readyState == 4)
	{
document.getElementById('nazarpic').style.visibility = 'hidden';	
		r = http.responseText;
		if(r == 'ok')
	document.getElementById("divnazar").innerHTML = 'با تشكر از شما';
		else
			if(r == "cannot")
			{
document.getElementById("divnazar").innerHTML = 'ارسال نظر مجدد امكانپذير نمي باشد';				
			}
			
		
	}
}