isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;

function hideMe(){
  if (isIE||isNN) document.getElementById("theLayer").style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function makeObject(){
var x;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
x = new ActiveXObject("Microsoft.XMLHTTP");
}else{
x = new XMLHttpRequest();
}
return x;
}

var request = makeObject();

function aj_content(subject,search,news_num)
{

var str1 = "";
for(var i=0;i<search.length;++i)
if (search.charAt(i)== "+")
str1 += "!PLUS!";
else
str1 += search.charAt(i);

request.open('post', 'news/news_aj.php');
request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
request.onreadystatechange = parseInfo;
request.send('subject=' + subject + '&search=' + str1 + '&news_num='+news_num);
}

function parseInfo(){
if(request.readyState == 1){
document.getElementById('aj_content').innerHTML = '<div  style="font:bold 11px Tahoma; color: #CC3300; margin:50px 150px 0 0;"><img src="loading.gif" border="0" align="middle">&nbsp;&nbsp;&#1604;&#1591;&#1601;&#1575; &#1589;&#1576;&#1585; &#1705;&#1606;&#1610;&#1583; ...</div>';

}
if(request.readyState == 4){

var answer = request.responseText;

document.getElementById('aj_content').innerHTML = answer;
}
}


function download(id)
{
request.open('post', 'download/down.php');
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.onreadystatechange = parseDown;
request.send('id=' + id);
}

function parseDown(){
if(request.readyState == 4){

var answer = request.responseText;

document.getElementById('dl_num').innerHTML = answer;
}
}

function comment_aj(post_id,name,mail,web,comment,mail_show)
{
request.open('post', 'comment.php');
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.onreadystatechange = parseComment;
request.send('post_id=' + post_id + '&name=' + name + '&mail=' + mail + '&web=' + web + '&comment=' + comment +'&mail_show=' + mail_show);
}

function parseComment(){
if(request.readyState == 4){

var answer = request.responseText;

document.getElementById('comment').innerHTML = answer;
}
}


function double_filename(str)
{
request.open('post', 'double_filename.php');
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.onreadystatechange = parseFilename;
request.send('str=' + str);
}

function parseFilename(){
if(request.readyState == 4){
var answer = request.responseText;
document.getElementById('double_file_div').innerHTML = answer;
}
}

function gcard(s_name,s_mail,r_mail,message,notify,image_id,folder_name,form_action)
{
request.open('post', 'gr_send.php');
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.onreadystatechange = parse_gcard;
request.send('s_name=' + s_name + '&s_mail=' + s_mail + '&r_mail=' + r_mail + '&message=' + message + '&notify=' + notify + '&image_id=' + image_id + '&folder_name=' + folder_name + '&form_action=' + form_action);
}

function parse_gcard(){

if(request.readyState == 1){
document.getElementById('gcard').innerHTML = '<div  style="background-color:#f0f0f0; font:bold 11px Tahoma; position:absolute; color: #CC3300; left:400px;top:700px;"><img src="loading.gif" border="0" align="middle">&nbsp;&nbsp;&#1583;&#1585;&#1581;&#1575;&#1604; &#1575;&#1585;&#1587;&#1575;&#1604;.&nbsp;&nbsp;&#1604;&#1591;&#1601;&#1575; &#1589;&#1576;&#1585; &#1705;&#1606;&#1610;&#1583; ...</div>';
}

if(request.readyState == 4){
var answer = request.responseText;
var str = "<div onClick=\"hideMe();return false\" id=\"theLayer\" style=\"border:1px solid #666; position:absolute;width:100%;height:auto;left:50px;top:800px; z-index:1; background-color:#f0f0f0\" dir=\"rtl\">";
str += "<a href=\"#\" onClick=\"hideMe();return false\">&nbsp;<b>x &#1576;&#1587;&#1578;&#1606; &#1575;&#1610;&#1606; &#1662;&#1606;&#1580;&#1585;&#1607;</b></a><br>";
str += answer + "</div>";
document.getElementById('gcard').innerHTML = str;
}
}

function preview_big_card(pic_path)
{
request.open('post', 'gr_thumb.php');
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.onreadystatechange = function()
{
var myImage = new Image();
myImage.src = pic_path;
var img_w = myImage.width;
var img_h = myImage.height;

img_w = Math.ceil(Math.abs((screen.width-img_w)/2));
img_h = Math.ceil(Math.abs((screen.height-img_h)/2-100));

if(request.readyState == 1){
document.getElementById('gcard').innerHTML = '<div dir="rtl"  style="background-color:#f0f0f0; font:bold 11px Tahoma; position:absolute; color: #CC3300; left:400px;top:300px;"><img src="loading.gif" border="0" align="middle">&nbsp;&nbsp;.&nbsp;&nbsp;&#1604;&#1591;&#1601;&#1575;&#1705;&#1605;&#1740; &#1589;&#1576;&#1585; &#1705;&#1606;&#1610;&#1583; ...</div>';
}

if(request.readyState == 4){
var answer = request.responseText;
var str = "<div onClick=\"hideMe();return false\" id=\"theLayer\" style=\"border:1px solid #666; position:absolute;width:auto;height:auto;left:"+img_w+"px;top:"+img_h+"px; z-index:1; background-color:#f0f0f0\">";
str += answer + "</div>";
document.getElementById('gcard').innerHTML = str;
}

}
request.send('big_pic_path=' + pic_path);
}