var WaitMSG = "Please Wait ...";
var WaitMSG2 = "
";
var WaitMSG5 = "

";
var WaitMSG3 = " | در حال ارسال اطلاعات ... |
"
var WaitMSG4 = " | برای بازشدن صفحه کمی صبر کنید ... |
"
var xmlhttp=false;
function $( Element )
{
if( document.getElementById( Element ) )
{
return document.getElementById( Element );
} else
{
return "";
}
}
function doeval(js)
{
if( js!=null )
{
var sc = document.createElement("script");
jsCode = js;sc.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(sc);
sc.text="try{eval(jsCode);}catch(e){}jsCode=\"\";";
sc.text="// :-)";
}
}
function AddToBookMark( title , url )
{
if( ! title ) title = "بزرگترین سایت تفریح و سرگرمی";
if( ! url) url = "default.htm";
if (window.sidebar)
{
window.sidebar.addPanel( title , url ,"" );
}
else if( window.external )
{
window.external.AddFavorite( url, title);
}
else if(window.opera && window.print)
{
var elem = document.createElement( 'a' );
elem.setAttribute( 'href' , url );
elem.setAttribute( 'title' ,title);
elem.setAttribute( 'rel' , 'sidebar' );
elem.click();
}
}
function GetValue(id)
{
if( document.getElementById(id) )
{
if( document.getElementById(id).type == "textarea" )
{
return GetAjaxValue( document.getElementById(id).value );
} else
if( document.getElementById(id).type == "checkbox" )
{
if( document.getElementById(id).checked )
{
return "1";
} else
{
return "0";
}
} else
{
return GetAjaxValue( document.getElementById(id).value );
}
} else
{
return '';
}
}
function GetAjaxValue(Text)
{
Text = Text.replace(/&/g,"**1**");
Text = Text.replace(/=/g,"**2**");
Text = Text.replace(/\+/g,"**3**");
return Text;
}
function ChatKeyDown( e )
{
var key;
var Char;
if( window.event )
{
key = e.keyCode;
}
else if( e.which )
{
key = e.which;
}
if( key > 128 )
{
$( 'Send' ).innerHTML = " | لطفا فقط فینگیلیش تایپ کنید . |
";
return false;
} else
{
if( key == 13 )
{
SendNewMessage();
}
return true;
}
}
function AddSmile( SM )
{
var Message = $( 'Message' ).value;
$( 'Message' ).value = Message + SM;
$( 'Message' ).focus();
}
function getscript( str )
{
let_out=str;
jstr=let_out.split("");
if( newstr[1]!=null )
{
doeval( newstr[0] );
}
}
return let_out;
}
function Load( URL , id , Load , Data , Method )
{
if( window.XMLHttpRequest )
{
xmlhttp=new XMLHttpRequest;
if( xmlhttp.overrideMimeType )
{
xmlhttp.overrideMimeType("text/xml");
}
} else
if( window.ActiveXObject )
{
try
{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch( e )
{
try
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch( e )
{
xmlhttp=false;
}
}
}
if( !xmlhttp )
{
alert("Connect Failure");
return false;
}
if( Method=="Get" )
{
xmlhttp.open("GET",URL,true);
} else
if( Method=="Post" )
{
xmlhttp.open("POST",URL,true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
}
xmlhttp.onreadystatechange = function()
{
if( xmlhttp.readyState == 4 && xmlhttp.status == 200 )
{
Response = xmlhttp.responseText;
Response = getscript(Response);
$( id ).innerHTML = Response;
} else
if( xmlhttp.readyState == 0 || xmlhttp.readyState==1 || xmlhttp.readyState==2 || xmlhttp.readyState==3 )
{
if( Load )
{
$( id ).innerHTML = Load;
}
}
}
xmlhttp.send(Data);
}
function Show( URL , ID )
{
Load(URL,ID,WaitMSG,"","Get");
}
function Search()
{
var KeyWord = document.getElementById('KeyWord').value;
window.location.href = '../funsara.com/Search/'+KeyWord;
}
function SendNewMessage()
{
var Name = GetValue("Name");
var Message = GetValue("Message");
Load( "ChatBox.php" , "Send" , WaitMSG3 , "Name="+Name+"&Message="+Message,"Post");
}
function SendComment()
{
var Name = GetValue("CommentName");
var Web = GetValue("CommentWeb");
var Email = GetValue("CommentEmail");
var Message = GetValue("UserMessage");
var PostID = GetValue("PostID");
var Private = GetValue("Private");
var SecCode = GetValue("SecCode");
Load( "Comments.php" , "CommentStatus" , WaitMSG3 , "Name="+Name+"&SecCode="+SecCode+"&Web="+Web+"&Email="+Email+"&Message="+Message+"&PostID="+PostID+"&Private="+Private,"Post");
}
function DeleteMSG( id )
{
if( confirm( "آیا از پاک کردن این پیام مطمئن هستید ؟" ) )
{
Load( "ChatBox.php" , "Send" , WaitMSG3 , "id="+id ,"Post");
}
}
function WriteInDiv(id, String)
{
if( document.getElementById(id) )
{
document.getElementById(id).innerHTML = String;
}
}
function ChatBox()
{
Load( "ChatBox.php@Reload=OK" , "ChatPlace" , "" , "" , "Get" );
setTimeout("ChatBox();Empty()",60000);
}
function Empty()
{
WriteInDiv( "Send" , "" );
}
function ReloadChatBox()
{
Load( "ChatBox.php@Reload=OK" , "ChatPlace" , "" , "" , "Get" );
setTimeout('Empty()',3000);
}
function OpenComment()
{
var PostID = GetValue("PostID");
window.open( "Comments.php@PostID=" + PostID , 'Comment' ,'status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no ,width=535px,height=500px');
}
function OpenChatBox()
{
window.open( "../funsara.com/ChatBox.php" , 'ChatBox' ,'status=no,scrollbars=yes,toolbar=no,menubar=no,location=no ,width=330px,height=580px');
}
function NewSecCode(Page)
{
Load( Page+"?New" , "SecIMG" , Wait1 , "" , "Get" );
}
function NewSecCode2()
{
$( "SecIMG" ).innerHTML = "
";
}
function ChangeTitle( New )
{
document.title = New;
}
function Cancell()
{
$( "Name" ).value = "";
$( "Message" ).value = "";
}
function SendYourMessage()
{
var Email = GetValue( 'E-Mail' );
var Message = GetValue( 'Form-Message' );
var ValidateEmail = $( 'E-Mail' ).accept;
var ValidateMessage = $( 'Form-Message' ).accept;
if( ValidateEmail == 1 && ValidateMessage == 1 )
{
Load( "Send.php" , "Result" , WaitMSG5 , "E-Mail="+Email+"&Message="+Message,"Post");
} else
{
alert( 'لطفا تمامی موارد را تکمیل کنید .' );
}
}
function SendYourFriend()
{
var ID = GetValue( 'ID' );
var Email = GetValue( 'Friend-EMail' );
var Name = GetValue( 'Your-Name' );
var ValidateEmail = $( 'Friend-EMail' ).accept;
var ValidateName = $( 'Your-Name' ).accept;
if( ValidateEmail == 1 && ValidateName == 1 )
{
$( "ToFriend" ).style.display = "none";
Load( "Send.php" , "ViewStatus" , WaitMSG5 , "E-Mail="+Email+"&Name="+Name+"&ID="+ID,"Post");
} else
{
alert( 'لطفا تمامی موارد را تکمیل کنید .' );
}
}
function CheckEmail()
{
if( GetValue( "E-Mail" ) == "" )
{
WriteInDiv( "EmailError" , "لطفا پست الکترونیک خود را وارد کنید ." );
} else
{
re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(! re.test( GetValue( 'E-Mail' ) ) )
{
WriteInDiv( "EmailError" , "پست الکترونیک معتبر نمی باشد ." );
} else
{
WriteInDiv( "EmailError" , "پست الکترونیک تایید شد ." );
$( 'E-Mail' ).accept = 1;
}
}
}
function CheckMessage()
{
if( GetValue( "Form-Message" ) == "" )
{
WriteInDiv( "MessageError" , "لطفا پیام خود را وارد کنید ." );
} else
{
WriteInDiv( "MessageError" , "متن پیام شما تایید شد ." );
$( 'Form-Message' ).accept = 1;
}
}
function CheckFriendEmail()
{
if( GetValue( "Friend-EMail" ) == "" )
{
WriteInDiv( "ToFriend" , "لطفا پست الکترونیک خود را وارد کنید ." );
$( 'Friend-EMail' ).accept = 0
} else
{
re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(! re.test( GetValue( 'Friend-EMail' ) ) )
{
WriteInDiv( "ToFriend" , "پست الکترونیک معتبر نمی باشد ." );
$( 'Friend-EMail' ).accept = 0;
} else
{
WriteInDiv( "ToFriend" , "پست الکترونیک تایید شد ." );
$( 'Friend-EMail' ).accept = 1;
}
}
}
function CheckYourName()
{
if( GetValue( "Your-Name" ) == "" )
{
WriteInDiv( "ToFriend" , "لطفا پیام خود را وارد کنید ." );
$( 'Your-Name' ).accept = 0;
} else
{
WriteInDiv( "ToFriend" , "متن پیام شما تایید شد ." );
$( 'Your-Name' ).accept = 1;
}
}
function ChangeFontSize( Type )
{
switch( Type )
{
case 0 : $( 'Content' ).style.fontSize = "11px";break
case 1 : $( 'Content' ).style.fontSize = "12px";break
case 2 : $( 'Content' ).style.fontSize = "13px";break
case 3 : $( 'Content' ).style.fontSize = "14px";break
case 4 : $( 'Content' ).style.fontSize = "15px";break
}
}
function ChangeLineHeight( Size )
{
switch( Size )
{
case 0 : document.getElementsByTagName( "p" )[1].style.margin="3px 0px";document.getElementsByTagName( "p" )[1].style.lineHeight="1.6em"; break;
case 1 : document.getElementsByTagName( "p" )[1].style.margin="7px 0px";document.getElementsByTagName( "p" )[1].style.lineHeight="1.8em"; break;
case 2 : document.getElementsByTagName( "p" )[1].style.margin="9px 0px";document.getElementsByTagName( "p" )[1].style.lineHeight="2em"; break;
}
}