function iepngfix() {
	if (!/MSIE (5\.5|6)/.test(navigator.userAgent) || typeof filters == 'unknown') return;
	iePNGFix(0);
}
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function ShowAlert (id,alertname,txt) {
	document.getElementById(id).className = 'alertinput';
	document.getElementById(id).focus();
	dofadein(alertname,'9');
	document.getElementById(alertname).innerHTML = txt;
}
function HideAlert (id,alertname) {
	document.getElementById(id).className = '';
	document.getElementById(alertname).innerHTML = '';
}
function AlertForm (alerts,mode,name,alertname,funcname) {
	var AlertInput = alerts.split(",");
	var ModeInput = mode.split(",");
	var NameInput = name.split(",");
	for (i=0; i < AlertInput.length; i++){
	    if (ModeInput[i] == "normal"){
		   	if (document.getElementById(AlertInput[i]).value == ""){
	 	       	ShowAlert (AlertInput[i],alertname,'لطفا قسمت ('+NameInput[i]+') را تکمیل فرمایید.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
 		if (ModeInput[i] == "select"){
		   	if (document.getElementById(AlertInput[i]).value == ""){
			   	ShowAlert (AlertInput[i],alertname,'لطفا قسمت ('+NameInput[i]+') را انتخاب فرمایید.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "minchar6"){
		   	if (document.getElementById(AlertInput[i]).value.length < 6){
			    ShowAlert (AlertInput[i],alertname,'('+NameInput[i]+') باید بیش از 6 حرف باشد.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "minchar2"){
		   	if (document.getElementById(AlertInput[i]).value.length < 2){
			    ShowAlert (AlertInput[i],alertname,''+NameInput[i]+' باید بیش از 2 حرف باشد.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "charen"){
		   	if (document.getElementById(AlertInput[i]).value == ""){
	 	       	ShowAlert (AlertInput[i],alertname,'لطفا قسمت ('+NameInput[i]+') را تکمیل فرمایید.')
				return false;
			}else if (!document.getElementById(AlertInput[i]).value.match (/^[\w\.\,\n\+\?\_\!\ \&\(\)\=]+$/)){
			    ShowAlert (AlertInput[i],alertname,'فقط از کاراکتر های انگلیسی استفاده نمایید.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "minchar11"){
		   	if (Left(document.getElementById(AlertInput[i]).value, 2) != "09"){
			   	document.getElementById(AlertInput[i]).value = '09';
			}
		   	if (document.getElementById(AlertInput[i]).value == ""){
	 	       	ShowAlert (AlertInput[i],alertname,'لطفا قسمت ('+NameInput[i]+') را تکمیل فرمایید.')
				return false;
			}else if (document.getElementById(AlertInput[i]).value.length < 11){
			    ShowAlert (AlertInput[i],alertname,'یک شماره موبایل معتبر وارد نمایید.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "number"){
			if (document.getElementById(AlertInput[i]).value == ""){
			    ShowAlert (AlertInput[i],alertname,'لطفا قسمت ('+NameInput[i]+') را تکمیل فرمایید.')
				return false;
			}
			else if (!document.getElementById(AlertInput[i]).value.match(/^[0-9]+$/)){
				ShowAlert (AlertInput[i],alertname,'('+NameInput[i]+') فقط می تواند شامل اعداد باشد.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "number-optional"){
			if (document.getElementById(AlertInput[i]).value != "" && !document.getElementById(AlertInput[i]).value.match(/^[0-9]+$/)){
			   	ShowAlert (AlertInput[i],alertname,'('+NameInput[i]+') فقط می تواند شامل اعداد باشد.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "tel"){
			if (document.getElementById(AlertInput[i]).value == ""){
	 	       	ShowAlert (AlertInput[i],alertname,'لطفا قسمت ('+NameInput[i]+') را تکمیل فرمایید.')
				return false;
			}
			else if (!document.getElementById(AlertInput[i]).value.match(/^[0-9/ /-]+$/)){
				ShowAlert (AlertInput[i],alertname,'('+NameInput[i]+') فقط می تواند شامل اعداد، ( ) و (-) باشد.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "tel-optional"){
			if (document.getElementById(AlertInput[i]).value != "" && !document.getElementById(AlertInput[i]).value.match(/^[0-9/ /-]+$/)){
				ShowAlert (AlertInput[i],alertname,'('+NameInput[i]+') فقط می تواند شامل اعداد، ( ) و (-) باشد.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "website"){
			if (document.getElementById(AlertInput[i]).value == ""){
	 	       	ShowAlert (AlertInput[i],alertname,'لطفا قسمت ('+NameInput[i]+') را تکمیل فرمایید.')
				return false;
			}
			else if (document.getElementById(AlertInput[i]).value.match (/^[\w\-\.\+\?\_\!\&\/\#\%\(\)\=]+$/)){
				ShowAlert (AlertInput[i],alertname,'('+NameInput[i]+') فقط می تواند شامل حروف، اعداد و (-) باشد.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "website-optional"){
			if (document.getElementById(AlertInput[i]).value != "" && !document.getElementById(AlertInput[i]).value.match (/^[\w\-\.\+\?\_\!\&\/\#\%\(\)\=]+$/)){
				ShowAlert (AlertInput[i],alertname,'('+NameInput[i]+') فقط می تواند شامل حروف، اعداد و (-) باشد.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "email"){
			if (document.getElementById(AlertInput[i]).value == ""){
	 	       	ShowAlert (AlertInput[i],alertname,'لطفا قسمت ('+NameInput[i]+') را تکمیل فرمایید.')
				return false;
			}
			else if (!document.getElementById(AlertInput[i]).value.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9\-\.])+\.([A-Za-z]{2,4})$/)){
				ShowAlert (AlertInput[i],alertname,'لطفا یک (ایمیل) معتبر وارد نمایید.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "email-optional"){
			if (document.getElementById(AlertInput[i]).value != "" && !document.getElementById(AlertInput[i]).value.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9\-\.])+\.([A-Za-z]{2,4})$/)){
				ShowAlert (AlertInput[i],alertname,'لطفا یک (ایمیل) معتبر وارد نمایید.')
				return false;
			}
			else {
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "passwordrepeat"){
		   	if (document.getElementById(AlertInput[i]).value != document.getElementById(AlertInput[i-1]).value){
	 	       	ShowAlert (AlertInput[i],alertname,'کلمه عبور و تکرار آن همحوانی ندارد.')
				document.getElementById(AlertInput[i-1]).className = 'alertinput';
				return false;
			}
			else {
				document.getElementById(AlertInput[i-1]).className = '';
				HideAlert (AlertInput[i],alertname);
			}
		}
		if (ModeInput[i] == "check"){
		   	if (document.getElementById(AlertInput[i]).value == ""){
			   	document.getElementById(AlertInput[i-1]).className = 'alertinput';
			   	document.getElementById(alertname).innerHTML = '('+NameInput[i]+') مورد تایید قرار نگرفته است.';
				return false;
			}
			else {
				document.getElementById(AlertInput[i]).className = '';
			}
		}
		if (ModeInput[i] == "hidden"){
		   	if (document.getElementById(AlertInput[i]).value == ""){
	 	       	ShowAlert (AlertInput[i],alertname,'')
				return false;
			}
			else {
				document.getElementById(AlertInput[i]).className = '';
			}
		}
	}
	if (funcname == 'sendsms') {
	    ajaxdo('../include/sendsms.asp','vertical','ss_alert','0','0','action=do&name='+ajaxvalue('ss_name')+'&mob='+ajaxvalue('ss_mob')+'&message='+ajaxvalue('ss_message')+'&tomob='+ajaxvalue('ss_tomob')+'&adsid='+ajaxvalue('ss_adsid')+'')
	}
	if (funcname == 'sendmail') {
	    ajaxdo('../include/sendmail.asp','vertical','sm_alert','0','0','action=do&name='+ajaxvalue('sm_name')+'&email='+ajaxvalue('sm_email')+'&message='+ajaxvalue('sm_message')+'&toemail='+ajaxvalue('sm_toemail')+'&adsid='+ajaxvalue('sm_adsid')+'&adstitle='+ajaxvalue('sm_adstitle')+'')
	}
	if (funcname == 'tellafriend') {
	    ajaxdo('../include/tellafriend.asp','vertical','tf_alert','0','0','action=do&email='+ajaxvalue('tf_email')+'&friendemail='+ajaxvalue('tf_friendemail')+'&message='+ajaxvalue('tf_message')+'')
	}
}
function CharCount(){
	TotalCount = 90;
	MessageCount = document.getElementById('ss_message').value.length;
	FreeMessageCount = TotalCount - MessageCount;
   	if (MessageCount > TotalCount){
	   	ShowAlert ('ss_message','ss_alert','پیام شما باید حداکثر &#1785;&#1776; کاراکتر باشد.')
		document.getElementById('ss_count').innerHTML = FreeMessageCount;
		blnSend = 'false';
	}
	else {
		document.getElementById('ss_count').innerHTML = FreeMessageCount;
		HideAlert ('ss_message','ss_alert');
		blnSend = 'true';
	}
}
//--------------------------------------------------------------------
function AdsImageOver(id,simg1,simg2,simg3,img){
	if (simg1 > 0){document.getElementById('simg1').className='slr_showads_div_image_small';}
	if (simg2 > 0){document.getElementById('simg2').className='slr_showads_div_image_small';}
	if (simg3 > 0){document.getElementById('simg3').className='slr_showads_div_image_small';}
	document.getElementById('simg'+id).className='slr_showads_div_image_small_over';
	if (simg1 > 0){document.getElementById('bimg1').style.display='none';}
	if (simg2 > 0){document.getElementById('bimg2').style.display='none';}
	if (simg3 > 0){document.getElementById('bimg3').style.display='none';}
	dofadein('bimg'+id,'9');
	document.getElementById('bimg'+id).style.display = '';
}
function TabClick(id){
	marqueepage = 1;
	document.getElementById('tab1').className='slr_tab_title';
	document.getElementById('tab2').className='slr_tab_title';
	document.getElementById('tab3').className='slr_tab_title';
	document.getElementById('tab4').className='slr_tab_title';
	document.getElementById('tab'+id).className='slr_tab_title_active';
}
function marqueeright (pageads){
	rightPos = parseInt(document.getElementById('AdsMarquee').style.right);
	newrightPos = -marqueepage * 580;
	marqueepage = marqueepage + 1;
	if (marqueepage == pageads){
	   document.getElementById('catmarqueeleftbtn').innerHTML='<div class="slr_pagenext_noactive">&nbsp;</div>';
	}
	if (pageads == 1){
	   document.getElementById('catmarqueeleftbtn').innerHTML='<div class="slr_pagenext_noactive">&nbsp;</div>';
	}
	if (marqueepage > 1){
	   document.getElementById('catmarqueerightbtn').innerHTML='<div class="slr_pageprev" onmouseover="this.className = &#39;slr_pageprev_over&#39;" onmouseout="this.className = &#39;slr_pageprev&#39;" onclick="marqueeleft('+pageads+');">&nbsp;</div>';
	}
	movemarqueeright()
}
function movemarqueeright(){
	if (Math.abs(rightPos - newrightPos)>.001){
	    rightPos = (newrightPos - rightPos) * .2  + rightPos;	
		document.getElementById('AdsMarquee').style.right = rightPos+"px";
		setTimeout("movemarqueeright()", 50);
	}
}
function marqueeleft (pageads){
	leftPos = parseInt(document.getElementById('AdsMarquee').style.right);
	newleftPos = -(marqueepage-2) * 580;
	marqueepage = marqueepage - 1;
	if (marqueepage == 1){
	   document.getElementById('catmarqueerightbtn').innerHTML='<div class="slr_pageprev_noactive">&nbsp;</div>';
	}
	if (pageads == 1){
	   document.getElementById('catmarqueeleftbtn').innerHTML='<div class="slr_pagenext" onmouseover="this.className = &#39;slr_pagenext_over&#39;" onmouseout="this.className = &#39;slr_pagenext&#39;" onclick="marqueeright('+pageads+');">&nbsp;</div>';
	}
	if (marqueepage < pageads){
	   document.getElementById('catmarqueeleftbtn').innerHTML='<div class="slr_pagenext" onmouseover="this.className = &#39;slr_pagenext_over&#39;" onmouseout="this.className = &#39;slr_pagenext&#39;" onclick="marqueeright('+pageads+');">&nbsp;</div>';
	}
	movemarqueeleft()
}
function movemarqueeleft(){
	if (Math.abs(leftPos - newleftPos)>.001){
	    leftPos = (newleftPos - leftPos) * .2  + leftPos;	
		document.getElementById('AdsMarquee').style.right = leftPos+"px";
		setTimeout("movemarqueeleft()", 50);
	}
}
//--------------------------------------------------------------------
function dofadeout(id,fromopacity,mode){
	FromOpacity = fromopacity
	DivHeight = parseInt(document.getElementById(id).style.height);
	NewDivHeight = DivHeight
	fadeout(id)
}
function fadeout(id){
	if (FromOpacity > 0){
	    FromOpacity = FromOpacity - 1
		NewDivHeight = NewDivHeight - (DivHeight/10)
		document.getElementById(id).style.opacity = "0."+FromOpacity;
		document.getElementById(id).style.filter = "alpha(opacity="+parseInt(FromOpacity)*10+")";
		document.getElementById(id).style.height = NewDivHeight+"px";
		setTimeout("fadeout(\'" + id + "\')", 50);
	}else{
		if (mode='display') {
		   	document.getElementById(id).style.display = 'none';
		}else if (mode='clear') {
			document.getElementById(id).innerHTML='';
		}
	}	 
}
function dofadein(id,toopacity){
	FromOpacity = 0
	ToOpacity = toopacity
	fadein(id)
}
function fadein(id){
	if (FromOpacity < ToOpacity){
	    FromOpacity = FromOpacity + 1
		document.getElementById(id).style.opacity = "0."+parseInt(FromOpacity);
		document.getElementById(id).style.filter = "alpha(opacity="+parseInt(FromOpacity)*10+")";
		setTimeout("fadein(\'" + id + "\')", 50);
	}
}
//--------------------------------------------------------------------
function ajaxwin(page, mode, siberid, post, title){
	if (mode == "sendemail"){
		document.getElementById('window_small').style.display ='';
	   	document.getElementById('window_small_icon').innerHTML='<img src="../images/icon_bigmail.png"/>';
		document.getElementById('window_small_title').innerHTML='ارسال ایمیل به آگهی دهنده';
		win_mover(70, 'window_small', 300);
  		ajaxdo(page+'.asp', 'block', 'window_small_content','0', '0', post);
	}
	if (mode == "sendsms"){
		document.getElementById('window_small').style.display ='';
	   	document.getElementById('window_small_icon').innerHTML='<img src="../images/icon_bigsms.png"/>';
		document.getElementById('window_small_title').innerHTML='ارسال پیامک به آگهی دهنده';
		win_mover(70, 'window_small', 300);
  		ajaxdo(page+'.asp', 'block', 'window_small_content','0', '0', post);
	}
	if (mode == "tellafriend"){
		document.getElementById('window_small').style.display ='';
	   	document.getElementById('window_small_icon').innerHTML='<img src="../images/icon_bigtellafriend.png"/>';
		document.getElementById('window_small_title').innerHTML='ارسال این آگهی برای دوست';
		win_mover(70, 'window_small', 300);
  		ajaxdo(page+'.asp', 'block', 'window_small_content','0', '0', post);
	}
}
function ajaxwin_close(mode){
	if (mode == "window"){
		document.getElementById('window').style.display ='none';
		document.getElementById('window_small').style.display ='none';
		dofadeout('layer','6','display');
	}
	if (mode == "window_small"){
		document.getElementById('window_small').style.display ='none';
	}
}
//--------------------------------------------------------------------
function loading_effect(k){
	ht = document.getElementsByTagName("html");
	if(k==1){
	    ht[0].style.cursor = 'wait';
	}else{
	    ht[0].style.cursor = 'auto';
	}
}

function ajaxdo(url, type, id, func, siberid, post){
 	var xmlhttp=false;
	if (type=='block'){document.getElementById(id).innerHTML='<div style="text-align: center; padding: 40px 0px 60px 0px;"><img src="images/loading.gif" width="16" height="16" style="margin-top: 10px;"><br>لطفا چند لحظه صبر كنيد ...</div>';}
	if (type=='tab'){document.getElementById(id).innerHTML='<div style="text-align: center; padding: 40px 0px 40px 0px;"><img src="images/loading.gif" width="16" height="16" style="margin-top: 10px;"><br>لطفا چند لحظه صبر كنيد ...</div>';}
	if (type=='blank'){}
    if (type=='vertical'){document.getElementById(id).innerHTML='<span style="color: #737373;">لطفا چند لحظه صبر كنيد ...</span>';}
	loading_effect(1);
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
       	try {
        	xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
        } 
        catch (e) {
            try {xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');} 
			catch (E) { 
            xmlhttp = false; 
            }
    	}
    @end @*/
    
	if(!xmlhttp) {xmlhttp=new XMLHttpRequest();}
	
	xmlhttp.open('POST', url, true);
        xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); post=post+'&my_time='+escape(new Date().getTime());
        xmlhttp.send(post); 
        xmlhttp.onreadystatechange = function() {
			 if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
                document.getElementById(id).innerHTML =xmlhttp.responseText;
             }else if(xmlhttp.status == 404 && type != 'blank'){
				document.getElementById(id).innerHTML = '<div class="slr_arrow" id="error">سیستم قادر به یافتن فایل مورد نظر نمی باشد. لطفا این مشکل را از طریق فرم موجود در صفحه تماس با ما به اطلاع مدیران سایت برسانید.</div>';
			 }else if(xmlhttp.status == 500){
			 	document.getElementById(id).innerHTML = '<div class="slr_arrow" id="error">خطا در سیستم. لطفا این مشکل را از طریق فرم موجود در صفحه تماس با ما به اطلاع مدیران سایت برسانید.</div>';
			 }else if(xmlhttp.status == 0 && type != 'blank'){
			   	document.getElementById(id).innerHTML = '<div class="slr_arrow" id="error">متاسفانه در حال حاضر دریافت اطلاعات امکان پذیر نمی باشد. لطفا پس از بررسی اتصال اینترنت خود مجددا سعی نمایید.</div>';
			 }
			 loading_effect(0);
        }
}
function ajaxvalue(id){
	if(!document.getElementById(id)){
		return '';
	}else if(document.getElementById(id).type == 'checkbox'){
        return document.getElementById(id).checked;
	}else{
        return encodeURIComponent(ajaxreplace(document.getElementById(id).value));
	}
}
function ajaxreplace(note){
	note= note.replace(/&/g,"&#38;");
	note= note.replace(/\*/g,"&#42;");
	return note;
}
//--------------------------------------------------------------------
var DivY= 500;
var DivY0 = DivY/6;
var PoseActive=0;

function win_mover(my_y, go_up_id_old, leftpx){
	go_up_id=go_up_id_old;
	newleft=document.body.clientWidth/2 - parseInt(document.getElementById(go_up_id).style.width)/2;
	document.getElementById(go_up_id).style.top = "0px";
	document.getElementById(go_up_id).style.left = newleft-leftpx+"px";
	
	DivY = document.body.clientHeight+1500;
    DivY0 = DivY/my_y;
	Pos();
	DivUp();
	document.getElementById(go_up_id).style.display="";
}
function Pos(){
	if (window.innerHeight)
	{
	    pos = window.pageYOffset
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
	 	pos = document.documentElement.scrollTop
	}
	else if (document.body)
	{
		pos = document.body.scrollTop
	}
	if (PoseActive)
	{
		document.getElementById(go_up_id).style.top = DivY + pos+"px";
		temp = setTimeout('Pos()',300);
	}
}
function DivUp(){
	if (Math.abs(DivY- DivY0)>.1){
		DivY = (DivY0 - DivY) * .2  + DivY;
		document.getElementById(go_up_id).style.top = DivY + pos+"px";
		setTimeout("DivUp()", 50);
	}
	else
	{
	 	PoseActive = 0;
	}
}