ana = this;
ana.errors = {};
ana.number = 0;

jQuery(document).ready(function($){
$(document).pngFix();
<!-- BEGIN Ticket_Script -->	
	jQuery("#List").dragsort({dragSelector:'.Ticket_Move',dragEnd: dragticket});
	function dragticket(){jQuery(".Ticket").animate({marginTop: "10px"}, 200);}
<!-- END Ticket_Script -->
//*********************************************Put Loading In Center Screen
function centerThis(div) {
		var winH = $(window).height();
		var winW = $(window).width();
		var centerDiv = $('#' + div);
		var top = String((winH/2-centerDiv.height()/2)+$(window).scrollTop());
		var left = String(winW/2-centerDiv.width()/2);
		centerDiv.animate({"top": top+"px"}, "fast");
		centerDiv.animate({"left": left+"px"}, "fast");
	}
//*********************************************Hidden Loading Box & UnBind(resize-scrool)
function hideloading(){
	jQuery("select").show();
	jQuery('.loadboxOverlay').fadeOut('normal').remove();
	jQuery('#loadbox').fadeOut('normal').remove();
	$(window).unbind('resize scroll');
}
//*********************************************Overlay For IE 6
function IE6Overlay(divclass){
	jQuery("select").hide();
	jQuery('.'+divclass).css({"position":"absolute", width:$(window).width(), height:$(window).height(), top:$(window).scrollTop(), left:$(window).scrollLeft()});
}
//*********************************************Show Loading Box & Bind(resize-scrool)
function showloading(message,type){
	jQuery('.loadboxOverlay').remove();
	jQuery('#loadbox').remove();
	var ladsid = jQuery('#loadingimg').attr('alt');
	jQuery.post("/page/ads.html", { adsid : ladsid ,action : 'countlads'});
		
	var loadingimg = '<a target="_blank" href="/page/ads.html?part=2&click='+ladsid+'"><img src="'+jQuery('#loadingimg').attr('src')+'" /></a>';
	switch(type)
	{	//Loading
		case 1: message += '<br /><img src="/images/sendload.gif" style="margin-top:5px;" />'; break;
		//Error Send Data
		case 2: message = '<img src="/images/alert.png" width="25" height="25" align="right" />' + message; break;
		//Success Send Data
		case 3: message = '<img src="/images/send_ok.png" width="25" height="25" align="right" />' + message; break;
		//Information
		case 4: message = '<img src="/images/alert.png" width="25" height="25" align="right" />' + message; break;
		default:message += '<br /><img src="/images/sendload.gif" style="margin-top:5px;" />'; break;
	}
	jQuery('<div />').addClass('loadboxOverlay').appendTo('body').show();
	//---------------------------Detect Browser
	if (window.XMLHttpRequest) {
		if(document.epando){//ie7
			jQuery('.loadboxOverlay').css({"position":"absolute", width:'100%', height:'100%', top:'0px', left:'0px'});
		}else{//mozilla, safari, opera 9…etc
			jQuery('.loadboxOverlay').css({"position":"fixed", width:'100%', height:'100%', top:'0px', left:'0px'});}
	} else {//ie6
	IE6Overlay('loadboxOverlay');}
	//----------------------------------------
	jQuery('<div />').html('<table border="0" cellspacing="0" cellpadding="0" id="loadbox"><tr><td id="lboxTopRight"></td><td id="lboxTopCenter">&nbsp;</td><td id="lboxTopLeft"></td></tr><tr><td id="lboxMiddleRight">&nbsp;</td><td id="lboxContent">'+loadingimg+'</td><td id="lboxMiddleLeft">&nbsp;</td></tr><tr><td id="lboxBottomRight">&nbsp;</td><td id="lboxBottomCenter"><div>'+message+'</div></td><td id="lboxBottomLeft">&nbsp;</td></tr></table>').appendTo('body').show();
	var resizeTimer = null;
	centerThis('loadbox');
	$(window).bind('resize scroll', function() {
		IE6Overlay('loadboxOverlay');
		if(resizeTimer) 
			clearTimeout(resizeTimer);
		resizeTimer = setTimeout(function() {centerThis('loadbox')}, 600);
    });
}
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
 jQuery('#user_information').validate({
	success: function(label) {
		label.html("&nbsp;").addClass("checked");
	},
	submitHandler: function(form) {
		showloading('در حال ارسال اطلاعات<br />...لطفا صبر کنید',1);
		jQuery('.ticket_submit').attr('disabled',true);
		jQuery(form).ajaxStop(function() {setTimeout(function() {hideloading();}, 5000);})
		.ajaxError(function(a, b, e) {showloading('<strong>خطا در ارسال اطلاعات</strong><br />در حال حاضر ارسال اطلاعات امکانپذیر نیست',2);});
		jQuery(form).ajaxSubmit({
			url:"/userpanel/action.html",
			data: ({action : 'usersetting',sendtype : 'ajax'}),
			success: function(msg){
				if (msg=="saveok"){
				showloading('<strong>اطلاعات شما با موفقیت ویرایش گردید</strong>',3);
				jQuery('#newpass').val('');
				jQuery('#oldpass').val('');
				setTimeout(function() {document.location="/userpanel/wellcome.html";}, 6000);
				}
				if (msg=="passerror"){
				jQuery('#newpass').val('');
				jQuery('#oldpass').val('');
				showloading('<strong>خطا در ذخیره اطلاعات</strong><br />کلمه عبور قدیمی وارد شده اشتباه است',4);
				}
				
			}
		});
	}
});
 
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
jQuery(".ticket_delete").click(function(){
	var t_id = jQuery(this).attr('t_id');
	if (confirm('آیا برای حذف این آگهی مطمئن هستید؟ \n در صورت حذف اطلاعات آگهی قابل بازیابی نیست')){
		showloading('<strong>در حال اجرای درخواست حذف</strong><br />لطفا تا پایان عملیات صبر کنید',1);
		jQuery.post("/userpanel/action.html", { ticketid : t_id ,sendtype : 'ajax' ,action : 'deleteticket'},
		  function(msg){
			if (msg=="ok"){
				showloading('<strong>آگهی مورد نظر با موفقیت حذف شد</strong>',3);
				setTimeout(function() {hideloading();jQuery('#ticketlist_'+t_id).fadeOut('normal');}, 6000);
			}
			else{showloading('<strong>خطا در ارسال اطلاعات</strong><br />اجرای درخواست شما با مشکل مواجه شد <br />لطفا با پشتیبانی تماس بگیرید',2);
				setTimeout(function() {hideloading();}, 6000);}
		  }
		);
	}
});
jQuery(".ticket_renew").click(function(){
	var t_id = jQuery(this).attr('t_id');
	showloading('<strong>در حال اجرای درخواست یه روز رسانی</strong><br />لطفا تا بارگذاری کامل صبر کنید',1);
	jQuery.post("/userpanel/action.html", { ticketid : t_id ,sendtype : 'ajax' ,action : 'renewticket'},
	  function(msg){
		if (msg.toLowerCase() == "ok" ){
			showloading('<strong>به روز رسانی با موفقیت انجام شد</strong><br />آگهی شما در سطر اول به نمایش در می آید',3);
			setTimeout(function() {hideloading();document.location='/userpanel/manageticket.html';}, 6000);
		}else{showloading('<strong>خطا در ارسال اطلاعات</strong><br />اجرای درخواست شما با مشکل مواجه شد <br />لطفا با پشتیبانی تماس بگیرید',2);
			setTimeout(function() {hideloading();}, 6000);
		}
	  }
	);
});
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
<!-- BEGIN addticket_script -->
	jQuery("input[name='t_specific']").click(function(){
		if(jQuery(this).val()=="1") jQuery(".specific").fadeIn("normal");
		else jQuery(".specific").fadeOut("normal");
	});
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	jQuery(".new_box").change(function(){
		var tagname=jQuery(this).tagName();
		var boxname=jQuery(this).attr('name');
		if (tagname=="SELECT") var boxvalue=jQuery('.new_box option:selected').text();
		else if(tagname=="TEXTAREA") var boxvalue=jQuery(this).val().replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<BR/>");
		else var boxvalue=jQuery(this).val().replace(/</g, "&lt;").replace(/>/g, "&gt;");
		jQuery("#pr_"+boxname).html(boxvalue);
		if(jQuery(this).attr('fildhide')=="true")
			if(boxvalue=="") jQuery("#tr_"+boxname).fadeOut('normal');
			else jQuery("#tr_"+boxname).fadeIn('normal');
		else{ if(boxvalue=="") jQuery("#pr_"+boxname).html(jQuery(this).attr('title'));
		}
	});
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
	jQuery('#addticket').validate({
		errorContainer: jQuery('div.container'),
		errorLabelContainer: jQuery('ol', jQuery('div.container')),
		wrapper: 'li',
		rules: {
			t_title: {required: true, minlength: 5},
			t_category: 'required',
			t_text: {required: true, minlength: 50},
			t_username: {minlength: 3},
			t_price: {minlength: 3},
			t_tel: {minlength: 7,digits: true},
			t_link: {minlength: 11,url: true},
			t_address: {minlength: 10},
			t_hesab: {required: '#specific:checked'},
			t_fish_number: {required: '#specific:checked'}
		},
		submitHandler: function(form) {
			if(jQuery('#t_picture').val()=='')
				if (confirm('آگهی شما بدون تصویر ثبت خواهد شد \n آیا مطمئن هستید')){
					jQuery('#t_picture').val('null');
					send_tiket(form);
				}else return false;
			else send_tiket(form);
		}});
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
function send_tiket(form){
	showloading('در حال ارسال اطلاعات<br />...لطفا صبر کنید',1);
	jQuery('.ticket_submit').attr('disabled',true);
	jQuery(form).ajaxStop(function() {setTimeout(function() {hideloading();}, 5000);})
	.ajaxError(function(a, b, e) {showloading('<strong>خطا در ارسال اطلاعات</strong><br />در حال حاضر ارسال اطلاعات امکانپذیر نیست',2);});
	jQuery(form).ajaxSubmit({
		url:"/userpanel/action.html",
		data: ({sendtype : 'ajax',action : jQuery("#ticketaction").val()}),
		success: function(msg){
			//alert(msg);
			switch(msg){
				case "ok":
					showloading('<strong>اطلاعات شما با موفقیت ثبت شد</strong><br />لطفا تا بارگذاری لیست آگهی ها صبر کنید',3);
					setTimeout(function() {document.location="/userpanel/manageticket.html";}, 3000);
				break;
				case "repeat":
					jQuery('#t_title').val('');
					jQuery('#pr_t_title').html('');
					showloading('<strong>خطا در انجام عملیات</strong><br />عنوان آگهی شما تکراریست <br />لطفا عنوان آگهی را تغییر دهید',4);
					setTimeout(function() {
						hideloading();
						jQuery('.ticket_submit').attr('disabled',false);
						jQuery('#t_title').focus();
					}, 5000); 
				break;
				case "lenerror":
					jQuery('#t_title').val('');
					jQuery('#pr_t_title').html('');
					showloading('<strong>خطا در انجام عملیات</strong><br />عنوان آگهی شما بیش از حد مجاز است<br />لطفا عنوان آگهی را تغییر دهید',4);
					setTimeout(function() {
						hideloading();
						jQuery('.ticket_submit').attr('disabled',false);
						jQuery('#t_title').focus();
					}, 5000); 
				break;
			}

		}
	}); 
}
<!-- END addticket_script -->
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
jQuery(".showmessage").click(function(){
	var messageid = jQuery(this).attr('m_id');
	var messagetitle =  jQuery("#message"+messageid).attr('title');
	jQuery("#message"+messageid).css({'font-weight' : 'normal'});
	jQuery.fn.colorbox({ href: '/userpanel/read-message-' + messageid + '.html' , open:true, title:messagetitle});
});
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
jQuery(".deletemessage").click(function(){
	var messageid = jQuery(this).attr('m_id');
	if(confirm('آیا برای حذف مطمئن هستید')){
		showloading('<strong>در حال اجرای درخواست حذف پیام</strong><br />لطفا تا اتمام عملیات صبر کنید',1);
		jQuery.get('/userpanel/delete-message-' + messageid + '.html',
		   function(data){
			if(data=="ok"){
				jQuery("#message"+messageid).fadeOut('normal');
				showloading('<strong>عملیات شما با موفقیت انجام شد</strong>',3);
				setTimeout(function() {hideloading();}, 3000);
			}else
				showloading('<strong>اجرای درخواست حذف با مشکل مواجه شد</strong><br />در صورت تکرا در صفحه تماس با ما مطرح کنید',2);
		   }
		);
		return true;
	}
	else
		return false;
});
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
jQuery("#tcontact_form").submit(function(){
	var form_inputs =["tcontact_name","tcontact_phemail","tcontact_message"];
	var count=0;
	for( var i=0; i< form_inputs.length; i++){
		if(!empty_val(jQuery('#'+form_inputs[i]))){
			if(!eval("validate_"+form_inputs[i]+"();")){
				count++;
			}else{
				count=0;
			}
		}else{
			jQuery('#'+form_inputs[i]).focus();
			count++;
			return false;	
		}
	}
	if(count!=0){return false;}
	showloading('<strong>در حال ارسال پیام به آگهی دهنده</strong><br />لطفا تا اتمام عملیات صبر کنید',1);
	jQuery('.submitfrm').attr('disabled',true);
	jQuery(this).ajaxStop(function() {setTimeout(function() {hideloading();}, 3000);})
	.ajaxError(function(a, b, e) {showloading('<strong>خطا در ارسال اطلاعات</strong><br />در حال حاضر ارسال اطلاعات امکانپذیر نیست',2);});
	jQuery(this).ajaxSubmit({
		data: ({sendtype : 'ajax'}),
		success: function(msg){
			if (msg=="ok"){
				showloading('<strong>پیغام شما با موفقیت دریافت شد</strong><br />از تماس شما متشکریم',3);
				setTimeout(function() {
					hideloading();
					jQuery('#tcontact_div').fadeOut('normal').html('پیغام شما با موفقیت به آگهی دهنده ارسال شد<br />لطفا توجه كنيد:<br />امكان دارد آگهي دهندگان <b>صندوق پیام</b>خود را به ندرت بررسي كنند. <br />	بنابراين خواهشمند است، در صورتيكه پاسخ خود را به موقع دريافت نكرديد، با شماره تلفن و يا ايميل آگهي دهنده كه در متن آگهي موجود است، با وي تماس بگيريد. ').fadeIn('normal');
				}, 4000); 
			}else if(msg=="error"){
				showloading('<strong>خطا در ارسال اطلاعات</strong><br />طریقه دسترسی برای ثبت پیام صحیح نیست',2);
				setTimeout(function() {hideloading();}, 5000); 
			}else{
				showloading('<strong>خطا در ارسال اطلاعات</strong><br />لطفا در ساعت دیگری تلاش کنید',2);
				setTimeout(function() {document.location="";}, 6000);
			}
		}
	}); 	
	return false;
});
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
jQuery(".Ticket").hover(function(){
	jQuery(this).animate({marginTop: "-=10px"}, 200);
	$(this).addClass("featuredItemHover");
}, function() {
	jQuery(this).animate({marginTop: "+=10px"}, 200);
	$(this).removeClass("featuredItemHover");
	}
);

	
	var postcounter =0 ;
	
	
jQuery("#sponsor").click(function(){
	var delayout = 600;
	var contain = jQuery("#sponsor_contian");
	var offset = jQuery(this).offset();
	var menutop = parseInt(offset.top+(jQuery(this).height()/2));
	var menuleft = parseInt(offset.left);
	if (contain.is(":visible")) {contain.slideUp("fast"); return true;}
	jQuery("#sponsor_contian").css({left:menuleft+"px", top:menutop+"px"}).slideDown("fast");
	if(postcounter==0)
		jQuery.post("/page/ads.html", { adsid : contain.attr('adsid') ,action : 'countspads'},function(msg){postcounter++;});
	jQuery(this).bind("mouseleave", function(e){
		setTimeout(function() {
			var endx = menuleft+contain.width();
			var endy = menutop+contain.height();
			if ((e.pageX>=menuleft && e.pageX<=endx) && (e.pageY>=menutop && e.pageY<=endy))
				contain.bind("mouseleave", function(e){setTimeout(function() {contain.slideUp("fast");}, delayout);});
			else
				setTimeout(function() {contain.slideUp("fast");}, delayout);
		}, delayout);
	});
});
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
jQuery('#forget_form').validate({
	errorContainer: $('div.forget_container'),
	submitHandler: function(form) {
				jQuery('#forget_submit').attr('disabled',true);
				showloading('درحال بررسی اطلاعات',1);
				jQuery(form).ajaxStop(function() {setTimeout(function() {alert('Error Sending Data To Server , Server Is Busy');}, 5000);})
				.ajaxError(function(a, b, e) {showloading('<p><strong>خطا در ارسال اطلاعات</strong><br />در حال حاضر ارسال اطلاعات امکانپذیر نیست</p>',2);});
				jQuery(form).ajaxSubmit({
					url:"/page/forget.html",
					data: ({sendtype : 'ajax'}),
					success: function(msg){
						//alert(msg);
						if (msg=="forgetok"){
							hideloading();
							showloading('<p><strong>حال میتوانید با کلمه عبور جدید وارد شوید</strong><br />کلمه عبور شما با موفقیت تغییر کرد</p>',3);
							setTimeout(function() {document.location="/";}, 3000);
						}else if(msg=="userexist"){
							hideloading();
							jQuery('#reg_email').val('');
							showloading('<p><strong>خطا در انجام عملیات</strong><br />اطلاعات شما با هیچ یک از کاربران سایت مطابقت ندارد</p>',4);
							setTimeout(function() {
								hideloading();
								document.location="/page/forget.html";
							}, 5000); 
						}else{
							hideloading();
							showloading('<p><strong>خطا در ارسال اطلاعات</strong><br />بازیابی کلمه عبور به علت شلوغی امکانپذیر نیست لطفا کمی صبر کنید</p>',4);
							setTimeout(function() {document.location="/page/forget.html";}, 3000);
						}
					}
				}); 
			}
});
//showloading('<p><strong>حال میتوانید با کلمه عبور جدید وارد شوید</strong>sssdadasdasd<br />sadad<br /><br />کلمه عبور شما با موفقیت تغییر کرد</p>',3);
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
jkmegamenu.definemenu("megaanchor", "megamenu1", "click");
jkmegamenu.render($);

jQuery('.menulink').lavaLamp({
	fx: 'easeOutBounce',
	speed: 1000,
	returnDelay:1000,
	returnHome:true,
	homeLeft: -1,
	homeTop: -1,
	homeWidth:5,
	homeHeight:1
});
	jQuery('#top_menu').lavaLamp({fx: 'easeOutBounce', speed: 333});
	$('#search_category').selectbox({
		inputType: 'span',
		inputClass: 'selectbox2',
		containerClass: 'selectbox2-wrapper',
		loopnoStep: true
	});
	
	$(".action_icon").mouseover(function(){
		var imagename=$(this).attr('src');
		$(this).attr('src',imagename.replace('1','2'));
	}).mouseout(function(){
		var imagename=$(this).attr('src');
		$(this).attr('src',imagename.replace('2','1'));
	});
	jQuery('.tooltip,.action_icon').tooltip({track: true,delay: 0,showURL: false,showBody: " - ",fade: 450});
	
	jQuery.fn.tagName = function() {return this.get(0).tagName;}




<!-- BEGIN contactus-source -->{d}
var loader = jQuery('<div id="loader">loading</div>')
			.appendTo("#subplace")
			.hide();
jQuery().ajaxStart(function() {
			loader.show("slow");
		}).ajaxStop(function() {
			loader.hide("slow");
		}).ajaxError(function(a, b, e) {
			throw e;
		});
jQuery('#contactusform').validate({
	success: function(label) {
		label.html("&nbsp;").addClass("checked");
	},
	submitHandler: function(form) {
			jQuery("#submit").fadeOut("slow");
			jQuery(form).ajaxSubmit({
			target:"#result",
			url:"/page/contactus.html",
			data: ({sendtype : 'ajax',action : 'post'})
			});
	}
});

<!-- END contactus-source -->
	jQuery(".comment_fild,.tcontact_fild").focus(function(){
		var boxname=jQuery(this).attr('name');
		jQuery('#comment_'+boxname).fadeIn("normal");
		jQuery(this).css('background-color','#F4F4F4');
		jQuery(this).css('border','1px solid #B7B7B7');
	}).blur(function(){
		var boxname=jQuery(this).attr('name');
		jQuery('#comment_'+boxname).fadeOut("normal");
		jQuery(this).css('background-color','#FFFFFF');
		jQuery(this).css('border','1px solid #CCCCCC');
	});
	

jQuery('.required_register').blur(function(){
		if(!empty_val(jQuery(this))){
			var box_id=jQuery(this).attr("id");
			eval("validate_"+box_id+"('"+box_id+"');");
		}
		if(!ana.errors[jQuery(this).attr("id")])
			hideErrorDiv(jQuery('#'+jQuery(this).attr("id")));
	});


});

ddaccordion.init({
	headerclass: "expandable",
	contentclass: "categoryitems", 
	revealtype: "click",
	collapseprev: false,
	defaultexpanded: [0],
	onemustopen: false,
	animatedefault: false,
	persiststate: true,
	toggleclass: ["", "openheader"],
	togglehtml: ["prefix", "", ""],
	animatespeed: "normal",
	oninit:function(headers, expandedindices){},
	onopenclose:function(header, index, state, isuseractivated){}
})




function empty_val(element){
	if (jQuery.trim(element.val()).length == 0) 
		return true;
	return false;
}

function validate_reg_name(id){
	if(jQuery.trim(jQuery("#"+id).val()).length < 3){
		showErrorDiv(id);
		return false;
	}else
		hideErrorDiv(id);
}
function validate_reg_family(id){
	if(jQuery.trim(jQuery("#"+id).val()).length < 3){
		showErrorDiv(id);
		return false;
	}else
		hideErrorDiv(id);
}

function is_valid_email(email){
	var reemail = new RegExp(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/);
	if(email.match(reemail)) return true;
	return false;
}
function validate_reg_email(id){
	var vla = jQuery("#"+id).val();
	if(jQuery.trim(vla).length < 7){
		showErrorDiv(id);
		return false;
	}else{
		if(is_valid_email(vla)){
			jQuery("#checkimg").fadeIn("normal");
			jQuery("#checkimg").attr('src','/images/loadingsmall.gif');
			jQuery.post("/checkusername.html", { reg_email : vla},
			  function(msg){
				if (msg=="true"){
					jQuery("#checkimg").attr('src','/images/checked.gif');
					hideErrorDiv(id);
				}else{
					jQuery("label[for='reg_email']").html("ایمیل به عنوان نام کاربری در سایت استفاده خواهد شد ، این ایمیل قبلا ثبت نام نموده");
					jQuery("#checkimg").attr('src','/images/unchecked.gif');
					showErrorDiv(id);
					return false;
				}
			  }
			);
		}
		else{
			jQuery("label[for='reg_email']").html("<strong>ایمیل</strong> شما صحیح نیست ، لطفا ایمیل معتبر وارد کنید");
			showErrorDiv(id);
			return false;
		}
	}
}

function validate_reg_pass(id){
	if(jQuery.trim(jQuery("#"+id).val()).length < 6){
		showErrorDiv(id);
		return false;
	}else
		hideErrorDiv(id);
}
function validate_reg_repass(id){
	if(jQuery.trim(jQuery("#"+id).val()).length < 6){
		showErrorDiv(id);
		return false;
	}else{
		hideErrorDiv(id);
		if(jQuery("#"+id).val()!=jQuery("#reg_pass").val()){
			showErrorDiv('errorpass');
			ana.errors[id] = true;
			return false;
		}else{
			hideErrorDiv('errorpass');
			ana.errors[id] = false;
			return true
		}		
	}
}


function hideErrorDiv(id){
	jQuery('#error_'+id).hide();
	ana.errors[id] = false;
	if(jQuery('#error_'+id).css('display')=='none')
		if(ana.number<=1) ana.number=0; else ana.number--;
	if (ana.number==0) jQuery('.container').hide();	
}
function showErrorDiv(id){
	if(jQuery('#error_'+id).css('display')=='none')
		ana.number++;
	jQuery('.container').show();
	jQuery('#error_'+id).show();
	ana.errors[id] = true;

}
//*********************************************Put Loading In Center Screen
function hideloading(){
	jQuery("select").show();
	jQuery('.loadboxOverlay').fadeOut('normal').remove();
	jQuery('#loadbox').fadeOut('normal').remove();
	$(window).unbind('resize scroll');
}
function centerThis(div) {
		var winH = $(window).height();
		var winW = $(window).width();
		var centerDiv = $('#' + div);
		var top = String((winH/2-centerDiv.height()/2)+$(window).scrollTop());
		var left = String(winW/2-centerDiv.width()/2);
		centerDiv.animate({"top": top+"px"}, "fast");
		centerDiv.animate({"left": left+"px"}, "fast");
	}
//*********************************************Overlay For IE 6
function IE6Overlay(divclass){
	var $window;
	$window = $(window);
	jQuery("select").hide();
	jQuery('.'+divclass).css({"position":"absolute", width:$window.width(), height:$window.height(), top:$window.scrollTop(), left:$window.scrollLeft()});
}
//*********************************************Show Loading Box & Bind(resize-scrool)

function showloading(message,type){
	jQuery('.loadboxOverlay').remove();
	jQuery('#loadbox').remove();
	var ladsid = jQuery('#loadingimg').attr('alt');
	jQuery.post("/page/ads.html", { adsid : ladsid ,action : 'countlads'});
		
	var loadingimg = '<a target="_blank" href="/page/ads.html?part=2&click='+ladsid+'"><img src="'+jQuery('#loadingimg').attr('src')+'" /></a>';
	switch(type)
	{	//Loading
		case 1: message += '<br /><img src="/images/sendload.gif" style="margin-top:5px;" align="right" />'; break;
		//Error Send Data
		case 2: message = '<img src="/images/alert.png" width="25" height="25" align="right" />' + message; break;
		//Success Send Data
		case 3: message = '<img src="/images/send_ok.png" width="25" height="25" align="right" />' + message; break;
		//Information
		case 4: message = '<img src="/images/alert.png" width="25" height="25" align="right" />' + message; break;
		default:message += '<br /><img src="/images/sendload.gif" style="margin-top:5px;" align="right" />'; break;
	}
	jQuery('<div />').addClass('loadboxOverlay').appendTo('body').show();
	//---------------------------Detect Browser
	if (window.XMLHttpRequest) {
		if(document.epando){//ie7
			jQuery('.loadboxOverlay').css({"position":"absolute", width:'100%', height:'100%', top:'0px', left:'0px'});
		}else{//mozilla, safari, opera 9…etc
			jQuery('.loadboxOverlay').css({"position":"fixed", width:'100%', height:'100%', top:'0px', left:'0px'});}
	} else {//ie6
	IE6Overlay('loadboxOverlay');}
	//----------------------------------------
	jQuery('<div />').html('<table border="0" cellspacing="0" cellpadding="0" id="loadbox"><tr><td id="lboxTopRight"></td><td id="lboxTopCenter">&nbsp;</td><td id="lboxTopLeft"></td></tr><tr><td id="lboxMiddleRight">&nbsp;</td><td id="lboxContent">'+loadingimg+'</td><td id="lboxMiddleLeft">&nbsp;</td></tr><tr><td id="lboxBottomRight">&nbsp;</td><td id="lboxBottomCenter"><div>'+message+'</div></td><td id="lboxBottomLeft">&nbsp;</td></tr></table>').appendTo('body').show();
	var resizeTimer = null;
	centerThis('loadbox');
	$(window).bind('resize scroll', function() {
		IE6Overlay('loadboxOverlay');
		if(resizeTimer) 
			clearTimeout(resizeTimer);
		resizeTimer = setTimeout(function() {centerThis('loadbox')}, 300);
    });
}


function register_validate(form){
	var form_inputs =["reg_name","reg_family","reg_email","reg_pass","reg_repass"];
	for( var i=0; i< form_inputs.length; i++){
		if(!empty_val(jQuery('#'+form_inputs[i]))){
			eval("validate_"+form_inputs[i]+"();");
			if(! ana.errors[form_inputs[i]])
				hideErrorDiv(jQuery('#'+form_inputs[i]).attr("id"));
		}else{
			showErrorDiv(jQuery('#'+form_inputs[i]).attr("id"));	
			ana.errors[form_inputs[i]] = true;	
		}
	}
	var count;
	count =0
	for( elem in ana.errors){
		if(elem!='undefined'){
			if( ana.errors[elem] ){
				jQuery('#error_'+elem).show();
				count++;
			}
		}
	}
	if(count!=0){jQuery('.container').show(); return false;}
	
	
	jQuery('#register_submit').attr('disabled',true);
	showloading('درحال ذخیره اطلاعات شخصی',1);
	jQuery(form).ajaxStop(function() {setTimeout(function() {alert('Error Sending Data To Server , Server Is Busy');}, 5000);})
	.ajaxError(function(a, b, e) {showloading('<p><strong>خطا در ارسال اطلاعات</strong><br />در حال حاضر ارسال اطلاعات امکانپذیر نیست</p>',2);});
	jQuery(form).ajaxSubmit({
		url:"/page/register.html",
		data: ({sendtype : 'ajax'}),
		success: function(msg){
			//alert(msg);
			if (msg=="registerok"){
				hideloading();
				showloading('<p><strong>اطلاعات شما با موفقیت ثبت شد</strong><br />حال میتوانید از امکانات سایت استفاده کنید</p>',1);
				setTimeout(function() {document.location="/userpanel/wellcome.html";}, 3000);
			}else if(msg=="userexist"){
				hideloading();
				jQuery('#reg_email').val('');
				showloading('<p><strong>خطا در انجام عملیات</strong><br />آدرس ایمیل شما در سایت موجود میباشد <br />لطفا فیلد ایمیل را اصلاح کنید</p>',4);
				setTimeout(function() {
					hideloading();
					jQuery('#register_submit').attr('disabled',false);
					jQuery('#reg_email').focus();
				}, 5000); 
			}else{
				hideloading();
				showloading('<p><strong>خطا در ارسال اطلاعات</strong><br />جهت ثبت نام لطفا مجددا تلاش کنید ، لطفا تا بار گذاری مجدد صفحه صبر کنید</p>',4);
				setTimeout(function() {document.location="/page/register.html";}, 3000);
			}
		}
	}); 
	return false;
}
	

//*********************************************************
function validate_tcontact_name(){
	if(jQuery.trim(jQuery("#tcontact_name").val()).length < 3){
		jQuery("#tcontact_name").focus();
		return false;
	}
	return true;
}
function validate_tcontact_phemail(){
	if(jQuery.trim(jQuery("#tcontact_phemail").val()).length < 3){
		jQuery("#tcontact_phemail").focus();
		return false;
	}
	return true;
}
function validate_tcontact_message(){
	if(jQuery.trim(jQuery("#tcontact_message").val()).length < 10){
		jQuery("#tcontact_message").focus()
		return false;
	}else{
		if(jQuery('#tcontact_message').val()==jQuery('#tcontact_message_default').val()){
			alert('لطفا متن پیام را تکمیل کنید');
			jQuery("#tcontact_message").focus()
			return false;
		}
	}
	return true;
}


