﻿//Sets MaxLength for TextArea
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function changeTitle(title) {
	document.title = title;
}

active_fd_x = 0;
function toggleFDMenu(e,a,m,oc,ml) // e= elementid, a= add pic, m= minus pic, oc= open/close(0,1), ml= menu level
{
	//element = document.getElementById(e).style;
	if ((active_fd_x != 0) && (active_fd_x != e) && (oc == 1) && (ml == 1))
	{
	 	//alert(active_fd_x);
		document.getElementById(active_fd_x + '_sub').style.display='none';
			if (active_fd_x.indexOf('_sub')<0)
				{
				document.getElementById(active_fd_x + '_sub_sub').style.display='none';
				}
			if (active_fd_x.indexOf('_sub')>1)
				{
				document.getElementById(active_fd_x).style.display='none';
				}
		document.getElementById(active_fd_x + '_pic').src = a;
	}

	if (document.getElementById(e + '_sub').style.display=='none')
	{
		document.getElementById(e + '_sub').style.display='block';
	 	document.getElementById(e + '_pic').src = m;
		active_fd_x = e;
	} else {
		if (active_fd_x == e)
		{
			document.getElementById(e + '_sub').style.display='none';
	 		document.getElementById(e + '_pic').src = a;
	 	} else {
	 	//alert(e);
	 	//alert(active_fd_x);
			document.getElementById(e + '_sub').style.display='none';
			if (e.indexOf('_sub')<0)
				{
				document.getElementById(e + '_sub_sub').style.display='none';
				}
	 		document.getElementById(e + '_pic').src = a;
	 	}
	}
}





	active_fd_l1 = 0;
	active_fd_l2 = 0;

	//e = element, a = plus img, m = minus img, oc = open or close, ml = menu level (0,1)
	function fdMenu(e, a, m, oc, ml) {
		var thee = document.getElementById(e); var thes = document.getElementById(e + '_sub'); var thep = document.getElementById(e + '_pic');
		var the_act1_s = document.getElementById(active_fd_l1 + '_sub'); var the_act1_p = document.getElementById(active_fd_l1 + '_pic');
		var the_act2_s = document.getElementById(active_fd_l2 + '_sub'); var the_act2_p = document.getElementById(active_fd_l2 + '_pic')
		if (thes.style.display=='none')
		{
			//Should We Close Last Menu?
			if (oc == 1) {
				//Which Sub Menu Level Should Be Closed?
				if (ml == 0) {
					if (active_fd_l1 != 0) {
						the_act1_s.style.display = 'none';
						the_act1_p.src = a;
					}
				} else {
					if (active_fd_l2 != 0) {
						the_act2_s.style.display = 'none';
						the_act2_p.src = a;
					}
				}
			}
			thes.style.display = 'block';
			thep.src = m;
			//Sets the Active Menu (Last Menu Clicked)
			if (ml == 0) {active_fd_l1 = e;} else {active_fd_l2 = e;}
		}
		else
		{
			thes.style.display='none';
			thep.src = a;
		}
	}
	//0: identity, 1: plus profile
	function MembersSignUpValidate(this_profiletype,adr,adr2,zc,ct,cn,ctr,tel,fax,mob,pic) {
		isValid = true;
		var ErrMsg = ":ايرادات زير در فرم تکميل شده وجود دارد\n\n";
		var re;
		var str;

		str = document.getElementById('memberssignup_fullname').value;
	    if (str.length < 4)
	    {
	        ErrMsg = ErrMsg + "                        نام و نام خانوادگی -\n";
	        isValid = false;
	    }

	    str = document.getElementById('memberssignup_username').value;
	    re = /^[a-zA-Z0-9]{3,20}$/;
	    str = str.toString( );
	    if (!str.match(re)) {
	        ErrMsg = ErrMsg + "                             شناسه کاربری -\n";
	        isValid = false;
	    }

	    str = document.getElementById('memberssignup_password').value;
	    str2 = document.getElementById('memberssignup_repassword').value;
	    if ((str.length < 5)||(str != str2))
	    {
	        ErrMsg = ErrMsg + "                                     کلمه عبور -\n";
	        isValid = false;
	    }

	    str = document.getElementById('memberssignup_emailaddress').value;
	    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,}))$/;
	    str = str.toString( );
	    if (!str.match(re)) {
	        ErrMsg = ErrMsg + "                                  آدرس ايميل -\n";
	        isValid = false;
	    }


	    //Check Profile If It Should Be Checked
	    if (this_profiletype == 1) {
	    	ErrMsg = ErrMsg + '\n';

	    	if (adr == 'on') {
			    str = document.getElementById('memberssignup_address1').value;
			    if (str.length < 5)
			    {
			        ErrMsg = ErrMsg + "                                         نشانی -\n";
			        isValid = false;
			    }
		    }

	    	if (zc == 'on') {
			    str = document.getElementById('memberssignup_zipcode').value;
			    if (str.length < 4)
			    {
			        ErrMsg = ErrMsg + "                                     کد پستی -\n";
			        isValid = false;
			    }
			}

	    	if (ct == 'on') {
			    str = document.getElementById('memberssignup_city').value;
			    if (str.length < 3)
			    {
			        ErrMsg = ErrMsg + "                                            شهر -\n";
			        isValid = false;
			    }
			}

	    	if (ctr == 'on') {
			    str = document.getElementById('memberssignup_country').value;
			    if (str.length < 3)
			    {
			        ErrMsg = ErrMsg + "                                           کشور -\n";
			        isValid = false;
			    }
			}

	    	if (tel == 'on') {
			    str = document.getElementById('memberssignup_telephone').value;
			    re = /^([+]{1}|[0]{2})[0-9]{1,3}[-|.|\s]{0,1}[0-9]{7,11}$/;
			    str = str.toString( );
			    if (!str.match(re)) {
			        ErrMsg = ErrMsg + "     شماره تلفن 00982187654321 -\n";
			        isValid = false;
			    }
			}

	    	if (mob == 'on') {
			    str = document.getElementById('memberssignup_mobile').value;
			    re = /^(09){1}[0-9]{9}$/;
			    str = str.toString( );
			    if (!str.match(re)) {
			        ErrMsg = ErrMsg + " شماره تلفن همراه 09121234567 -\n";
			        isValid = false;
			    }
			}

	    }

	    //Showing Error And Return False

	    if (!isValid) {
	    	ErrMsg = ErrMsg + "\n.لطفا فرم را با دقت بيشتری تکميل کنيد"
	    	alert(ErrMsg);
	    	}

	    return isValid;
	}


	function MembersSignUpValidate_EN(this_profiletype,adr,adr2,zc,ct,cn,ctr,tel,fax,mob,pic) {
		isValid = true;
		var ErrMsg = "The Following Errors Occurred: \n\n";
		var re;
		var str;

		str = document.getElementById('memberssignup_fullname').value;
	    if (str.length < 4)
	    {
	        ErrMsg = ErrMsg + "-FirstName & LastName \n";
	        isValid = false;
	    }

	    str = document.getElementById('memberssignup_username').value;
	    re = /^[a-zA-Z0-9]{3,20}$/;
	    str = str.toString( );
	    if (!str.match(re)) {
	        ErrMsg = ErrMsg + "-Username \n";
	        isValid = false;
	    }

	    str = document.getElementById('memberssignup_password').value;
	    str2 = document.getElementById('memberssignup_repassword').value;
	    if ((str.length < 5)||(str != str2))
	    {
	        ErrMsg = ErrMsg + "-Password \n";
	        isValid = false;
	    }

	    str = document.getElementById('memberssignup_emailaddress').value;
	    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,}))$/;
	    str = str.toString( );
	    if (!str.match(re)) {
	        ErrMsg = ErrMsg + "-Email Address \n";
	        isValid = false;
	    }


	    //Check Profile If It Should Be Checked
	    if (this_profiletype == 1) {
	    	ErrMsg = ErrMsg + '\n';

	    	if (adr == 'on') {
			    str = document.getElementById('memberssignup_address1').value;
			    if (str.length < 5)
			    {
			        ErrMsg = ErrMsg + "-Address \n";
			        isValid = false;
			    }
		    }

	    	if (zc == 'on') {
			    str = document.getElementById('memberssignup_zipcode').value;
			    if (str.length < 4)
			    {
			        ErrMsg = ErrMsg + "-Postal Code \n";
			        isValid = false;
			    }
			}

	    	if (ct == 'on') {
			    str = document.getElementById('memberssignup_city').value;
			    if (str.length < 3)
			    {
			        ErrMsg = ErrMsg + "-City \n";
			        isValid = false;
			    }
			}

	    	if (ctr == 'on') {
			    str = document.getElementById('memberssignup_country').value;
			    if (str.length < 3)
			    {
			        ErrMsg = ErrMsg + "-Country \n";
			        isValid = false;
			    }
			}

	    	if (tel == 'on') {
			    str = document.getElementById('memberssignup_telephone').value;
			    re = /^([+]{1}|[0]{2})[0-9]{1,3}[-|.|\s]{0,1}[0-9]{7,11}$/;
			    str = str.toString( );
			    if (!str.match(re)) {
			        ErrMsg = ErrMsg + "-Telephone Number 00982187654321 \n";
			        isValid = false;
			    }
			}

	    	if (mob == 'on') {
			    str = document.getElementById('memberssignup_mobile').value;
			    re = /^(09){1}[0-9]{9}$/;
			    str = str.toString( );
			    if (!str.match(re)) {
			        ErrMsg = ErrMsg + "-CellPhone Number 09121234567 \n";
			        isValid = false;
			    }
			}

	    }

	    //Showing Error And Return False

	    if (!isValid) {
	    	ErrMsg = ErrMsg + "\n Please Fill The Blanks Correctly"
	    	alert(ErrMsg);
	    	}

	    return isValid;
	}


	// UPDATE PROFILE ********************************************************
	//0: identity, 1: plus profile
	function MembersEditProfileValidate(this_whichdata, this_profiletype,adr,adr2,zc,ct,cn,ctr,tel,fax,mob,pic) {
		isValid = true;
		var ErrMsg = ":ايرادات زير در فرم تکميل شده وجود دارد\n\n";
		var re;
		var str;

		if ((this_whichdata == 4) || (this_whichdata == 6)) {
			str = document.getElementById('memberseditprofile_fullname').value;
		    if (str.length < 4)
		    {
		        ErrMsg = ErrMsg + "                        نام و نام خانوادگی -\n";
		        isValid = false;
		    }
		}

	    str = document.getElementById('memberseditprofile_password').value;
	    if (str.length < 5)
	    {
	        ErrMsg = ErrMsg + "                                     کلمه عبور -\n";
	        isValid = false;
	    }

		if ((this_whichdata == 2) || (this_whichdata == 6)) {
		    str = document.getElementById('memberseditprofile_emailaddress').value;
		    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,}))$/;
		    str = str.toString( );
		    if (!str.match(re)) {
		        ErrMsg = ErrMsg + "                                  آدرس ايميل -\n";
		        isValid = false;
		    }
		}

	    //Check Profile If It Should Be Checked
	    if (this_profiletype == 1) {
	    	ErrMsg = ErrMsg + '\n';

	    	if (adr == 'on') {
			    str = document.getElementById('memberseditprofile_address1').value;
			    if (str.length < 5)
			    {
			        ErrMsg = ErrMsg + "                                         نشانی -\n";
			        isValid = false;
			    }
			}

	    	if (zc == 'on') {
			    str = document.getElementById('memberseditprofile_zipcode').value;
			    if (str.length < 4)
			    {
			        ErrMsg = ErrMsg + "                                     کد پستی -\n";
			        isValid = false;
			    }
			}

	    	if (ct == 'on') {
			    str = document.getElementById('memberseditprofile_city').value;
			    if (str.length < 3)
			    {
			        ErrMsg = ErrMsg + "                                            شهر -\n";
			        isValid = false;
			    }
			}

	    	if (ctr == 'on') {
			    str = document.getElementById('memberseditprofile_country').value;
			    if (str.length < 3)
			    {
			        ErrMsg = ErrMsg + "                                           کشور -\n";
			        isValid = false;
			    }
			}

	    	if (tel == 'on') {
			    str = document.getElementById('memberseditprofile_telephone').value;
			    re = /^([+]{1}|[0]{2})[0-9]{1,3}[-|.|\s]{0,1}[0-9]{7,11}$/;
			    str = str.toString( );
			    if (!str.match(re)) {
			        ErrMsg = ErrMsg + "     شماره تلفن 00982187654321 -\n";
			        isValid = false;
			    }
			}

	    	if (mob == 'on') {
			    str = document.getElementById('memberseditprofile_mobile').value;
			    re = /^(09){1}[0-9]{9}$/;
			    str = str.toString( );
			    if (!str.match(re)) {
			        ErrMsg = ErrMsg + " شماره تلفن همراه 09121234567 -\n";
			        isValid = false;
			    }
			}
	    }

	    //Showing Error And Return False

	    if (!isValid) {
	    	ErrMsg = ErrMsg + "\n.لطفا فرم را با دقت بيشتری تکميل کنيد"
	    	alert(ErrMsg);
	    	}

	    return isValid;
	}



	// UPDATE PROFILE ********************************************************
	//0: identity, 1: plus profile
	function MembersEditProfileValidate_EN(this_whichdata, this_profiletype,adr,adr2,zc,ct,cn,ctr,tel,fax,mob,pic) {
		isValid = true;
		var ErrMsg = "The Following Errors Occurred: \n\n";
		var re;
		var str;

		if ((this_whichdata == 4) || (this_whichdata == 6)) {
			str = document.getElementById('memberseditprofile_fullname').value;
		    if (str.length < 4)
		    {
	        ErrMsg = ErrMsg + "-FirstName & LastName \n";
		        isValid = false;
		    }
		}

	    str = document.getElementById('memberseditprofile_password').value;
	    if (str.length < 5)
	    {
	        ErrMsg = ErrMsg + "-Password \n";
	        isValid = false;
	    }

		if ((this_whichdata == 2) || (this_whichdata == 6)) {
		    str = document.getElementById('memberseditprofile_emailaddress').value;
		    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,}))$/;
		    str = str.toString( );
		    if (!str.match(re)) {
	        ErrMsg = ErrMsg + "-Email Address \n";
		        isValid = false;
		    }
		}

	    //Check Profile If It Should Be Checked
	    if (this_profiletype == 1) {
	    	ErrMsg = ErrMsg + '\n';

	    	if (adr == 'on') {
			    str = document.getElementById('memberseditprofile_address1').value;
			    if (str.length < 5)
			    {
			        ErrMsg = ErrMsg + "-Address \n";
			        isValid = false;
			    }
			}

	    	if (zc == 'on') {
			    str = document.getElementById('memberseditprofile_zipcode').value;
			    if (str.length < 4)
			    {
			        ErrMsg = ErrMsg + "-Postal Code \n";
			        isValid = false;
			    }
			}

	    	if (ct == 'on') {
			    str = document.getElementById('memberseditprofile_city').value;
			    if (str.length < 3)
			    {
			        ErrMsg = ErrMsg + "-City \n";
			        isValid = false;
			    }
			}

	    	if (ctr == 'on') {
			    str = document.getElementById('memberseditprofile_country').value;
			    if (str.length < 3)
			    {
			        ErrMsg = ErrMsg + "-Country \n";
			        isValid = false;
			    }
			}

	    	if (tel == 'on') {
			    str = document.getElementById('memberseditprofile_telephone').value;
			    re = /^([+]{1}|[0]{2})[0-9]{1,3}[-|.|\s]{0,1}[0-9]{7,11}$/;
			    str = str.toString( );
			    if (!str.match(re)) {
			        ErrMsg = ErrMsg + "-Telephone Number 00982187654321 \n";
			        isValid = false;
			    }
			}

	    	if (mob == 'on') {
			    str = document.getElementById('memberseditprofile_mobile').value;
			    re = /^(09){1}[0-9]{9}$/;
			    str = str.toString( );
			    if (!str.match(re)) {
			        ErrMsg = ErrMsg + "-CellPhone Number 09121234567 \n";
			        isValid = false;
			    }
			}
	    }

	    //Showing Error And Return False

	    if (!isValid) {
	    	ErrMsg = ErrMsg + "\n Please Fill The Blanks Correctly"
	    	alert(ErrMsg);
	    	}

	    return isValid;
	}



	function FAQValidate() {
		isValid = true;
		var ErrMsg = ":ايرادات زير در فرم تکميل شده وجود دارد\n\n";
		var re;
		var str;

		str = document.getElementById('askfaq_name').value;
	    if (str.length < 4)
	    {
	        ErrMsg = ErrMsg + "                        نام و نام خانوادگی -\n";
	        isValid = false;
	    }

	    str = document.getElementById('askfaq_email').value;
	    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,}))$/;
	    str = str.toString( );
	    if (!str.match(re)) {
	        ErrMsg = ErrMsg + "                                  آدرس ايميل -\n";
	        isValid = false;
	    }

	    str = document.getElementById('askfaq_heading').value;
	    if (str.length < 3)
	    {
	        ErrMsg = ErrMsg + "                                 عنوان سوال -\n";
	        isValid = false;
	    }

	    str = document.getElementById('askfaq_question').value;
	    if (str.length < 3)
	    {
	        ErrMsg = ErrMsg + "                                    متن سوال -\n";
	        isValid = false;
	    }


	    //Showing Error And Return False

	    if (!isValid) {
	    	ErrMsg = ErrMsg + "\n.لطفا فرم را با دقت بيشتری تکميل کنيد"
	    	alert(ErrMsg);
	    	}

	    return isValid;
	}



	function TELLAFRIENDValidate() {
		isValid = true;
		var ErrMsg = ":ايرادات زير در فرم تکميل شده وجود دارد\n\n";
		var re;
		var str;

		str = document.getElementById('tafyourname').value;
	    if (str.length < 4)
	    {
	        ErrMsg = ErrMsg + "                                     نام شما  -\n";
	        isValid = false;
	    }

	    str = document.getElementById('tafyouremail').value;
	    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,}))$/;
	    str = str.toString( );
	    if (!str.match(re)) {
	        ErrMsg = ErrMsg + "                                  ایمیل شما -\n";
	        isValid = false;
	    }

		str = document.getElementById('taffriendname').value;
	    if (str.length < 4)
	    {
	        ErrMsg = ErrMsg + "                          نام دوست شما  -\n";
	        isValid = false;
	    }

	    str = document.getElementById('taffriendemail').value;
	    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,}))$/;
	    str = str.toString( );
	    if (!str.match(re)) {
	        ErrMsg = ErrMsg + "                       ایمیل دوست شما -\n";
	        isValid = false;
	    }

	    //Showing Error And Return False

	    if (!isValid) {
	    	ErrMsg = ErrMsg + "\n.لطفا فرم را با دقت بيشتری تکميل کنيد"
	    	alert(ErrMsg);
	    	}

	    return isValid;
	}

function applydivider(thenum,sitemapwidth,sitemapwidthtype) {
	var input_text = document.getElementById('sbsitemap').innerHTML;
	var change_text = '<!--@SBML_SITEMAP_DIVIDER_' + thenum + '-->';
	//var output_text = input_text.replace(change_text,'</TD><TD valign="top">');
	var output_text = input_text.replace(change_text,'</TD><TD valign="top" width=' + sitemapwidth + '' + sitemapwidthtype + '>');
	//alert(output_text);
	//document.getElementById('sbsitemap').innerHTML = 'hey!';
	document.getElementById('sbsitemap').innerHTML = output_text;
}


var pageurl = "viewpost.asp?postid=";
var xmlViewPost=getHttp();
var bln_show = false

function RequestID(postid)
{

  	// document.getElementById("Loadimage" + postid).style.display = ''
	$("#Loadimage" + postid).hide()
	xmlViewPost.open("POST", "viewpost.asp", true);
	xmlViewPost.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlViewPost.onreadystatechange = ResponseID;
	xmlViewPost.send("postid=" + postid);
	xmlViewPost.close;

}


function ResponseID()
{

 if (xmlViewPost.readyState == 4)
  {
  if (xmlViewPost.status == 200)
   {
   	var Part = xmlViewPost.responseText.split('<part>');
	document.getElementById("Loadimage" + Part[0]).style.display = 'none'
	document.getElementById("view" + Part[0]).style.display = ''
	document.getElementById("view" + Part[0]).innerHTML = Part[1]
	bln_show = true

   }
}
}



function getHttp()
{
	var xmlhttp;
	try
	{
		xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			if (typeof XMLHttpRequest != 'undefined')
			{
				xmlhttp = new XMLHttpRequest();
			}
		}
	}
	return xmlhttp;
}

function deletepost(postid,catid)
{
	if (confirm('آیا اطمینان دارید که می خواهید این پست و تمام نظرات آن را حذف کنید؟')){
	window.location = 'index.asp?action=delpost&postid=' + postid + '&catid=' + catid}
}

function delopinion(opid, catid, postid)
{
	if (confirm('آیا اطمینان دارید که می خواهید این نظر را حذف کنید؟')){
	window.location = 'index.asp?action=delopinion&opid=' + opid + '&postid=' + postid + '&catid=' + catid
	}
}

function resetform(thisform)
{

for ( var i=0; i<thisform.elements.length; i++ )
{
	if (thisform.elements[i].type!="submit" && thisform.elements[i].type!="button" && thisform.elements[i].type!="image")
	{
		thisform.elements[i].value = ''
	}
}

}

function newSearchReplace(str_txt, str_desc)
{
	var input_text = document.body.innerHTML;

	var change_text = new RegExp(' ' + str_txt + ' ' , "g");
	var output_text = input_text.replace(change_text, ' ' + str_desc + ' ' );

	var change_text = new RegExp(' ' + str_txt , "g");
	var output_text = output_text.replace(change_text, ' ' + str_desc );

	var change_text = new RegExp('&nbsp;' + str_txt , "g");
	var output_text = output_text.replace(change_text, '&nbsp;' + str_desc );

	document.body.innerHTML = output_text;
}

	var xmlSave=getHttp();
	var Query = '' ;
	var lastElemName = '';

	function Get_Request()
	{
		Query = ''
		document.getElementById('button').disabled = true ;
		document.getElementById('img').style.display = 'block' ;
		xmlSave.open("POST", "/frontend/survey/saveform.asp", true);
		xmlSave.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlSave.onreadystatechange = Set_Request;
		var x=document.getElementById("frmsurvey");
		//alert(formData2QueryString(document.frmsurvey))
		var ElemName = '' ;
		for (var i=0;i<x.length;i++)
		  {

			if ((x.elements[i].type == "text")||(x.elements[i].type == "hidden")||(x.elements[i].type == "textarea"))
			{

				Query += x.elements[i].name + '=' + encodeURI(x.elements[i].value.replace('&', 'Hu!Z')) + '&'
			}


			else if(x.elements[i].type == "checkbox")
			{
				if (x.elements[i].checked==true)
				{
					if (ElemName == '' || ElemName != x.elements[i].name)
					{

						if (ElemName != '')
						{
							Query += ' &'
						}

						Query += x.elements[i].name + '=' + x.elements[i].value
						ElemName = x.elements[i].name

					}
					else
					{
						Query += ',' + x.elements[i].value
					}
				}
		//		else
		//		{
		//			if (ElemName == '' || ElemName != x.elements[i].name)
		//			{
		//				ElemName = x.elements[i].name
		//				Query += '&' + x.elements[i].name + '=,'
		//			}
		//			else
		//			{
		//				Query += ','
		//			}

		//		}
			}

			else if(x.elements[i].type == "radio")
			{
				if (x.elements[i].checked==true)
				{
					Query += x.elements[i].name + '=' + x.elements[i].value + '&'
				}
			}

			else if(x.elements[i].type == "select-one")
			{
				//if ( x.elements[i].value != '' && x.elements[i].name.indexOf("surveyselectdate_") == -1 )
				if ( x.elements[i].value != '' )
				{
					Query += x.elements[i].name + '=' + x.elements[i].value + '&'
				}
			}

		  }
		//document.write(Query);
		xmlSave.send(Query);
		xmlSave.close;
	}

	function Set_Request()
	{

	if (xmlSave.readyState == 4)
	  {

	  if (xmlSave.status == 200 )
	   {
		document.getElementById('img').style.display = 'none';

	 	if (xmlSave.responseText.indexOf('SurveyEnd') == -1)
	 	{

  			document.getElementById('button').disabled = false;
		 	var Result = xmlSave.responseText.split("<part>");
			document.getElementById("PageTitle").innerHTML = Result[0] ;
		 	document.getElementById("PageText").innerHTML = Result[1] ;
		 	document.getElementById("FormContent").innerHTML = '';
		 	document.getElementById("FormContent").innerHTML = document.getElementById("FormContent").innerHTML + Result[2] ;
			document.getElementById("pn").value = Result[3];
			alert(Result[2])
			//document.getElementById("scripting").innerHTML = Result[4];

		}
		else
		{
			document.getElementById("StartSurvey").style.display = 'none'
			document.getElementById("EndSurvey").style.display = 'block'
		}

		}
	   }
	}

function getHttp()
{
	var xmlhttp;
	try
	{
		xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			if (typeof XMLHttpRequest != 'undefined')
			{
				xmlhttp = new XMLHttpRequest();
			}
		}
	}
	return xmlhttp;
}









// ======================
// Function name:	Fix Persian Char
// Created Date:	06 October 2010
// ======================
function FixPersianChar(uPageID){
	$("body").attr("id", "PID-" + uPageID)
	uPageHtml = $("#PID-" + uPageID).html()
	uPageHtml = uPageHtml.replace(/ي/gi, "ی")
//	uPageHtml = uPageHtml.replace(/%D9%8A/gi, "%DB%8C")
	document.getElementById("PID-" + uPageID).innerHTML = uPageHtml
//	$("body").html(upagehtml)

}

// ======================
// Function name:	Load Weblog Post
// ======================
function loadWeblogPost(postid){
	$.ajax({
		type: 'POST',
		data: "postid=" + postid,
		url: "/weblog/viewpost.asp",
		beforeSend: function() {
			$("#Loadimage" + postid).show()
		},
		success: function(resultback) {
			$("#view" + postid).html(resultback).slideDown()
		},
		complete: function() {
			$("#Loadimage" + postid).hide()
		}
	});
}


// ======================
// Function name:	Weather Condition
// Created Date:	2:15 PM Monday, 01 August 2011
// ======================
function WeatherCondition(cntid, strplzwait){
	$.ajax({
		type: "POST",
		data: "cntid=" + cntid,
		url: "/admin/modules/weather/actions.asp",
		beforeSend: function() {
			$("#weatherplace_" + cntid).prepend("<span>" + strplzwait + "</span>")
			//$(".yweather").append("<div class='yweather-loader'>Please wait ...</div>");
		},
		success: function(resultback) {
			$("#weatherplace_" + cntid).append(resultback);
		},
		complete: function() {
			$("#weatherplace_" + cntid + " span:first").remove()
		},
		error: function(XHRObject, options, errorThrown) {
			$("#weatherplace_" + cntid).html("N/A");
		}
	});
}



// ======================
// Function name:	Deposit Payment
// Created Date:	07 September 2011
// ======================
function validateFrmDeposit(frmid){
	$('#frmdeposit-' + frmid + ' tr[class=invalidamount]').hide()
	$('#frmdeposit-' + frmid + ' input[name=deposit-reffer]').val($(location).attr('href'))
	dfamount = $.trim($('#frmdeposit-' + frmid + ' input[name=deposit-amount]').val())
	dfamountfrom = $.trim($('#frmdeposit-' + frmid + ' input[name=deposit-amountfrom]').val())
	dfamountto = $.trim($('#frmdeposit-' + frmid + ' input[name=deposit-amountto]').val())

	if (dfamount.length == 0 || isNaN(dfamount) || dfamount.indexOf(',') > -1 || dfamount.indexOf('.') > -1){
		$('#frmdeposit-' + frmid + ' input[name=deposit-amount]').focus();
		$('#frmdeposit-' + frmid + ' tr[class=invalidamount]').show();
		return false;
	}
	else{
		if (parseInt(dfamount) < dfamountfrom || parseInt(dfamount) > dfamountto){
			$('#frmdeposit-' + frmid + ' input[name=deposit-amount]').focus();
			$('#frmdeposit-' + frmid + ' tr[class=invalidamount]').show();
			return false;
		}
	}
	if ($.trim($('#frmdeposit-' + frmid + ' input[name=deposit-name]').val()).length == 0){
		$('#frmdeposit-' + frmid + ' input[name=deposit-name]').focus();
		return false;
	}
	dfmail = $.trim($('#frmdeposit-' + frmid + ' input[name=deposit-email]').val())
	if (dfmail.length == 0){
		$('#frmdeposit-' + frmid + ' input[name=deposit-email]').focus();
		return false;
	}
	else{
		regexmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/
		if (!regexmail.test(dfmail)){
			$('#frmdeposit-' + frmid + ' input[name=deposit-email]').focus();
			return false;
		}
	}
	if ($.trim($('#frmdeposit-' + frmid + ' input[name=deposit-desc]').val()).length == 0){
		$('#frmdeposit-' + frmid + ' input[name=deposit-desc]').focus();
		return false;
	}

	//depositPayment(frmid);

	$('#frmdeposit-' + frmid + ' button').attr("disabled", "disabled")
	$('#frmdeposit-' + frmid + ' tr[class=depositwaitarea]').show()
}





// ======================
// Function name:	Deposit Payment
// Created Date:	11:49 AM Saturday, 10 September 2011
// ======================
function depositPayment(frmid){
	$.ajax({
		type: 'POST',
		data: "action=savetechnicalinfo&" +$("#frmdeposit-" + frmid).serialize(),
		url: "/frontend/ebanking-deposit.asp",
		beforeSend: function() {
			$('#frmdeposit-' + frmid + ' tr[class=depositerrorarea]').html("").hide()
			$('#frmdeposit-' + frmid + ' input, #frmdeposit-' + frmid + ' textarea').attr("readonly", "readonly")
			$('#frmdeposit-' + frmid + ' button').attr("disabled", "disabled")
			$('#frmdeposit-' + frmid + ' tr[class=depositwaitarea]').show()
		},
		success: function(resultback) {
			if (resultback == "invalidamount"){
				$('#frmdeposit-' + frmid + ' tr[class=invalidamount]').show();
			}
			if (resultback == "bankmethodnotfound"){
				$('#frmdeposit-' + frmid + ' tr[class=invalidamount] span').html("Epay method not found!!").show();
			}
		},
		complete: function() {
			$('#frmdeposit-' + frmid + ' tr[class=depositwaitarea]').hide()
			$('#frmdeposit-' + frmid + ' button').removeAttr("disabled")
			$('#frmdeposit-' + frmid + ' input, #frmdeposit-' + frmid + ' textarea').removeAttr("readonly")
		},
		error: function(XHRObject, options, errorThrown) {
			$('#frmdeposit-' + frmid + ' button').removeAttr("disabled")
			$('#frmdeposit-' + frmid + ' input, #frmdeposit-' + frmid + ' textarea').removeAttr("readonly")
			$('#frmdeposit-' + frmid + ' tr[class=depositerrorarea]').html(XHRObject.responseText).show()
		}
	});
}





// ======================
//  URL encode / decode
// http://www.webtoolkit.info/
// Added at 10:13 AM Tuesday, 20 September 2011
// ======================
var Url = {
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
		for (var n = 0; n < string.length; n++) {
			var c = string.charCodeAt(n);
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
		return utftext;
	},
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
		while ( i < utftext.length ) {
			c = utftext.charCodeAt(i);
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
		return string;
	}
}




// ======================
//  UGC News Validation
// Added at 12:24 PM Wednesday, 21 September 2011
// ======================
function UGCNewsValidation(){
	$("#newstitle_err, #newsteaser_err, #newsimage_err").hide()
	if ($.trim($("#newstitle").val()).length == 0){
		$("#newstitle_err").html("<label></label><br/>لطفا عنوان خبر را وارد کنید").show()
		$("#newstitle").focus()
		return false;
	}
	if ($.trim($("#newsteaser").val()).length == 0){
		$("#newsteaser_err").html("<label></label><br/>لطفا خلاصه خبر را وارد کنید").show()
		$("#newsteaser").focus()
		return false;
	}
	// agar tasvir ejbaari bood
	if ($("#newsimage").attr("rel") == 1){
		if ($.trim($("#newsimage").val()).length == 0){
			$("#newsimage_err").html("لطفا تصویر خبر را وارد کنید").show()
			$("#newsimage").focus()
			return false;
		}
	}
	// agar format motabar nabood
	if ($.trim($("#newsimage").val()).length != 0){
		fileext = $.trim($("#newsimage").val()).toLowerCase().substr($.trim($("#newsimage").val()).length - 4, 4)
		if (fileext != ".jpg" && fileext != ".png" && fileext != ".gif"){
			$("#newsimage_err").html("فرمت تصویر معتبر نیست").show()
			$("#newsimage").focus()
			return false;
		}
	}
}





// ======================
//  UGC Product Validation
// Added at 9:22 AM Tuesday, 04 October 2011
// ======================
function UGCProductValidation(){
	$("#productstitle_err, #productsstock_err, #productsprice1_err, #productimage_err").hide()
	if ($.trim($("#productstitle").val()).length == 0){
		$("#productstitle_err").html("<label></label><br/>لطفا عنوان محصول را وارد کنید").show()
		$("#productstitle").focus()
		return false;
	}
	if ($.trim($("#productsstock").val()).length == 0){
		$("#productsstock_err").html("لطفا تعداد موجودی را وارد کنید").show()
		$("#productsstock").focus()
		return false;
	}
	if (isNaN($.trim($("#productsstock").val()))){
		$("#productsstock_err").html("لطفا فقط عدد وارد کنید").show()
		$("#productsstock").focus()
		return false;
	}
	if ($.trim($("#productsprice1").val()).length == 0){
		$("#productsprice1_err").html("لطفا قیمت محصول را وارد کنید").show()
		$("#productsprice1").focus()
		return false;
	}
	if (isNaN($.trim($("#productsprice1").val())) || $.trim($("#productsprice1").val()).indexOf(".") > -1){
		$("#productsprice1_err").html("لطفا فقط عدد وارد کنید").show()
		$("#productsprice1").focus()
		return false;
	}
	// agar tasvir ejbaari bood
	if ($("#productimage").attr("rel") == 1){
		if ($.trim($("#productimage").val()).length == 0){
			$("#productimage_err").html("لطفا تصویر محصول را وارد کنید").show()
			$("#productimage").focus()
			return false;
		}
	}
	// agar format motabar nabood
	if ($.trim($("#productimage").val()).length != 0){
		fileext = $.trim($("#productimage").val()).toLowerCase().substr($.trim($("#productimage").val()).length - 4, 4)
		if (fileext != ".jpg" && fileext != ".png" && fileext != ".gif"){
			$("#productimage_err").html("فرمت تصویر معتبر نیست").show()
			$("#productimage").focus()
			return false;
		}
	}
}




// ======================
//  UGC Image Validation
// Added at 1:04 PM Wednesday, 05 October 2011
// ======================
function UGCImageValidation(){
	$("#galleryimage_err").hide()
	if ($.trim($("#galleryimage").val()).length == 0){
		$("#galleryimage_err").html("لطفا تصویر را وارد کنید").show()
		$("#galleryimage").focus()
		return false;
	}
	else {
		fileext = $.trim($("#galleryimage").val()).toLowerCase().substr($.trim($("#galleryimage").val()).length - 4, 4)
		if (fileext != ".jpg" && fileext != ".png" && fileext != ".gif"){
			$("#galleryimage_err").html("فرمت تصویر معتبر نیست").show()
			$("#galleryimage").focus()
			return false;
		}
	}

}






// ======================
//  UGC File Upload Validation
// Added at 3:03 PM Saturday, 08 October 2011
// ======================
function UGCFileValidation(){
	$("#downloadname_err, #downloadfile_err, #downloadmage_err").hide()
	if ($.trim($("#downloadname").val()).length == 0){
		$("#downloadname_err").html("<label></label><br/>لطفا عنوان فایل را وارد کنید").show()
		$("#downloadname").focus()
		return false;
	}
	// agar tasvir ejbaari bood
	if ($("#downloadmage").attr("rel") == 1){
		if ($.trim($("#downloadmage").val()).length == 0){
			$("#downloadmage_err").html("لطفا تصویر مربوطه را وارد کنید").show()
			$("#downloadmage").focus()
			return false;
		}
	}
	// agar format motabar nabood
	if ($.trim($("#downloadmage").val()).length != 0){
		fileext = $.trim($("#downloadmage").val()).toLowerCase().substr($.trim($("#downloadmage").val()).length - 4, 4)
		if (fileext != ".jpg" && fileext != ".png" && fileext != ".gif"){
			$("#downloadmage_err").html("فرمت تصویر معتبر نیست").show()
			$("#downloadmage").focus()
			return false;
		}
	}
	if ($.trim($("#downloadfile").val()).length == 0){
		$("#downloadfile_err").html("لطفا فایل را انتخاب کنید").show()
		$("#downloadfile").focus()
		return false;
	}
	// agar format file kharej az liste extension haye mojaz baraye gorouh bood
	if ($.trim($("#downloadfile").val()).length != 0){
		fileext = $.trim($("#downloadfile").val()).toLowerCase().substr($.trim($("#downloadfile").val()).length - 4, 4)
		catext = $("#downloadext").val()
		if (catext.indexOf(fileext) == -1){
			$("#downloadfile_err").html("فرمت فایل معتبر نیست").show()
			$("#downloadfile").focus()
			return false;
		}
	}
}




// ======================
//  UGC Article Validation
// Added at 3:47 PM Saturday, 29 October 2011
// ======================
function UGCArticleValidation(){
	$("#ugcarticlepagecounter").val(articlepagecounter)
	$("#articlestitle_err, #articlesteaser_err, #articlesimage_err").hide()
	if ($.trim($("#articlestitle").val()).length == 0){
		$("#articlestitle_err").html("<label></label><br/>لطفا عنوان مقاله را وارد کنید").show()
		$("#articlestitle").focus()
		return false;
	}
	if ($.trim($("#articlesteaser").val()).length == 0){
		$("#articlesteaser_err").html("<label></label><br/>لطفا خلاصه مقاله را وارد کنید").show()
		$("#articlesteaser").focus()
		return false;
	}
	// agar tasvir ejbaari bood
	if ($("#articlesimage").attr("rel") == 1){
		if ($.trim($("#articlesimage").val()).length == 0){
			$("#articlesimage_err").html("لطفا تصویر مقاله را وارد کنید").show()
			$("#articlesimage").focus()
			return false;
		}
	}
	// agar format motabar nabood
	if ($.trim($("#articlesimage").val()).length != 0){
		fileext = $.trim($("#articlesimage").val()).toLowerCase().substr($.trim($("#articlesimage").val()).length - 4, 4)
		if (fileext != ".jpg" && fileext != ".png" && fileext != ".gif"){
			$("#articlesimage_err").html("فرمت تصویر معتبر نیست").show()
			$("#articlesimage").focus()
			return false;
		}
	}
}




// ======================
//  Save Poll
// Added at 10:49 AM Sunday, 16 October 2011
// ======================
function SavePoll(cntid, pollid) {
	$pollform = $("form[name='poll_" + pollid + "']")
	$btnsubmit = $("#bln_poll" + pollid)
	$.ajax({
		type: 'POST',
		data: "action=savepoll&" + $pollform.serialize(),
		url: "/admin/modules/poll/actions.asp",
		beforeSend: function() {
			$btnsubmit.attr("disabled", "disabled")
		},
		success: function(resultback) {
			$("#pollmsgarea" + pollid).html("<br/>" + resultback)
		},
		complete: function() {
			$btnsubmit.removeAttr("disabled")
		},
		error: function(XHRObject, options, errorThrown) {
			alert(XHRObject.responseText)
			// $btnsubmit.removeAttr("disabled")
		}
	});
}






