﻿//public varibale farsi
var KeylangFarsi=true;
// for keypress
function farsikey(myfield,e)
{
var key;
var basestring=' !"#$%،گ)(×+و-./0123456789:ک,=.؟@ِذ}ىُىلآ÷ـ،/’د×؛َءٍف‘{ًْإ~جژچ^_پشذزیثبلاهتنمئدخحضقسفعرصطغظ<|>ّ';
if (window.event)
 key = window.event.keyCode;
else if (e)
 key = e.which;
 
if (key < 0x0020 || key >= 0x00FF) return true; 
if (KeylangFarsi==true)
{
	if (window.event)
	 window.event.keyCode=basestring.charCodeAt(key-32);
	else if (e)
	 e.which=basestring.charCodeAt(key-32);
}
 return true;
}

// function for keydown
function changelang(objtext1)
{

if (window.event.keyCode==119) 
		KeylangFarsi =(KeylangFarsi==true) ? false : true ;
    if (window.event.altKey && window.event.shiftKey )  
		KeylangFarsi = false ;
	 return true;
}

function On(object) {
object.className='On';
}

function Of(object) {
object.className='Off';
}

function SM(strCode) {
document.getElementById ('cmtbody').value +="[" + strCode +"]";
document.getElementById ("smdiv").style.display="none";
}

function ShowSM() {
document.getElementById ("smdiv").style.display='block';
document.getElementById ("smdiv").style.left =tblC.offsetLeft +25    ;
document.getElementById ("smdiv").style.top =tblC.offsetTop +95     ;
}

function WriteSM(){
s="<div dir=ltr class=\"sbox\" id=\"smdiv\"><div style=\"width:15px;float:right\" align=right ><a style=\"text-decoration: none; color: #800000; font-family: Arial; font-size: 8pt; font-weight: bold\" onclick=\"document.getElementById ('smdiv').style.display='none';\" href=\"javascript:void(0);\">	X</a></div>\n";
s+="<div><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/1.gif\" width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('لبخند')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/2.gif\" width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('ناراحت')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/3.gif\" width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('چشمک')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\"><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/4.gif\" width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('نیشخند')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\"><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/5.gif\" width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('خنده')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ></div>\n";
s+="<div><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/6.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('گریه')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/7.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('قلب')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/8.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('خجالت')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\"><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/9.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('زبان')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\"><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/10.gif\" width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('بوسه')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ></div>\n";
s+="<div><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/11.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('قلب شکسته')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/12.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('تعجب')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/13.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('عصبانی')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\"><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/14.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('رضایت')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\"><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/15.gif\" width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('خونسرد')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ></div>\n";
s+="<div><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/16.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('تشویش')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/17.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('شیطونک')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/18.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('بدرود')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\"><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/19.gif\"  width=\"18\" height=\"18\" hspace=2 class=\"Off\" onclick=\"SM('ناخوش')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\"><img border=\"0\" src=\"http://www.blogfa.com/cmt/images/20.gif\" width=\"18\" height=\"18\" hspace=2 class=\"Off\"  onclick=\"SM('گل')\" onmouseover=\"On(this)\" onmouseout =\"Of(this)\" ></div>\n";
s+="</div>";
document.write (s);
}

			
function IsValidForm() {
if  (document.getElementById ("cwritern").value =="") {
alert("ورود نام نويسنده نظر الزاميست") ;
document.getElementById ("cwritern").focus ();
return false;
}

if  (document.getElementById ("cmtbody").value =="") {
alert("ورود متن نظر الزاميست") ;
document.getElementById ("cmtbody").focus ();
return false;
}
	
if  (document.getElementById ("cmtbody").value.length >2000 ) 	{
alert("تنها مجاز به ورود دو هزار حرف در متن نظرات هستيد") ;
document.getElementById ("cmtbody").focus ();
return false;
}
	
if  (document.getElementById ("cemail").value!="" && IsEmail(document.getElementById ("cemail").value)==false ) 
{
alert("ايميل را به شکل صحيح وارد کنيد") ;
document.getElementById ("cemail").focus ();
return false;
}

/*
if  (document.getElementById ("huchk").value=="" ) 
{
alert("لطفا کد تایید را وارد کنید") ;
document.getElementById ("huchk").focus ();
return false;
}
*/

document.getElementById("chkb").innerHTML="<input type=hidden name='uk' id='iuk' />";
document.getElementById ("iuk").value="4820";	
document.getElementById ("btnSend").disabled=true;

} // end 

function showhumanimg()
{
    if (document.getElementById('trhuman').style.visibility != 'visible'){
    document.getElementById('trhuman').style.visibility='visible';
    var strRand= Math.floor(Math.random()*9000000);
    document.getElementById ("cimgspace").innerHTML ="<img src='cimage.ashx?" + strRand +  "' align='absmiddle' />";
    }
}



function ClearCookie()  {
var exp = new Date();
exp.setTime (exp.getTime() - 1000000000);  //  -1 to make it previous time)
document.cookie ="cmt_writer=; expires=" + exp.toGMTString();
document.cookie ="cmt_email=; expires=" + exp.toGMTString();
document.cookie ="cmt_url=; expires=" + exp.toGMTString();
document.getElementById ("cwritern").value='';
document.getElementById ("cemail").value='';
document.getElementById ("cmturl").value='';
alert("مشخصات شما پاک شد");
  }

function IsEmail(str) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    if (! str.match(re)) {
        return (false);
    }
    return(true);
}	

window.status='F8 => تغییر زبان صفحه کلید ' ;
WriteSM();		