﻿

$(document).ready(function(){
	
	$("a[rel='colorboxes']").colorbox();
	//$("a[rel='video']").colorbox({width:"400", height:"350", iframe:true});
	
	///menu
	$("#kiarnag").animate({opacity:0.4}, {duration:200,queue:false}); 
	$(".menu li").mouseover(function(){
		
			if($(this).attr("class")=='')
			$(this).animate({backgroundPosition:"(0px -2px)"}, {duration:200,queue:false}); 
			//$(this).css("padding-top",20);
		});
		
		$(".menu li").mouseout(function(){
			if($(this).attr("class")=='')
			$(this).animate({backgroundPosition:"(0px -11px)"}, {duration:200,queue:false}); 
			//$(this).css("padding-top",15);
		});
		
		$("#kiarang").mouseover(function(){
			$(this).animate({opacity:0.99}, {duration:200,queue:false}); 
		});
		$("#kiarang").mouseout(function(){
			$(this).animate({opacity:0.4}, {duration:200,queue:false}); 
		});
	
	//end menu
		$(".sitemap-div div img").mouseover(function(){
		
			$(this).animate({opacity:0.99}, {duration:200,queue:false}); 
		});
		$(".sitemap-div div img").mouseout(function(){
			$(this).animate({opacity:0.3}, {duration:200,queue:false}); 
		});
	
	});

//bgPositionAnimate
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);
//end


function focus1(id1){
	id1.style.backgroundColor='#ffffff';
	}
	function focus0(id1,fill){
		if(fill==false && id1.value==''){
		id1.style.backgroundColor='#ffeeee';
			}
			else if(fill==false && id1.value!='')
			{	
					if(id1.alt=='email' || id1.alt=='repemail'){
					
						var email = id1.value;
						var filter =  /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/;
							if (!filter.test(email)) {
								alert('! لطفا آدرس پست الکترونیکی را به درستی وارد کنید ');
									id1.style.backgroundColor='#ffeeee';
													}
								else{
									id1.style.backgroundColor='#eeffee';
									}
			} else{
			id1.style.backgroundColor='#eeffee';}
			
				  }else{
				  id1.style.backgroundColor='#eeeeee';
				  }
	}
	
function func_check_cons(){         
  f=document.consult_frm;		

 if(
 f.description.value=="" ||
f.tell.value=="" 

 )
			{
   alert("لطفا قسمتهای ستاره دار فرم را تکمیل نمایید");
   return false;
			}
	
			
   f.submit();
	}
	
		function func_contact_check(){
		  f= document.getElementById('contact_frm');
		 if( f.name.value=="" || f.email.value=="" || (f.tell.value=="" && f.cellphone.value=="") || f.body1.value=="" )
			{
   alert("لطفا قسمتهای ستاره دار فرم را تکمیل نمایید");
   return;
			}
document.contact_frm.submit();
   return(true);
	}

