
/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
eval(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

$(document).ready(function() {
	
	 var pageConf = {"serverAddress" : "http://www.zigzagz.net/PhotoBook/"};
	 
	 $(".hdbg").html('<div class="header"><a href="/index.html" style="display:block;height:90px;width:600px;float:left;"></a>'+  
			 '<dl>'+    
			 '<dt class="welcome"><a href="/login.html">Вход</a>|<a href="/register.html">Регистрация</a></dt>'+
			 '<dd>'+
			 '<input type="text" class="headeinput"  id="headeinput">'+
			 '<input type="submit" class="headersubmit" id="headersubmit" value="Поиск фото">'+
			 '</dd>'+
			 '</dl>'+
			 '</div></a>');
	 
	 
	 $(".footer").before('<div class="clear"></div>');
	
	$(".navbg").html('<div id="nav">'+
			 '<ul id="navul">'+
                         
			 '<li style="padding-left:0;width:51px;"><a href="/index.html" >Главная</a></li>'+
                         
			 '<li id="myZigzagMenu">'+
			 '<a href="javascript:void(0);">Мой Zigzag</a>'+
			 '<ul class="dropdown_menu menuMyZigTrig">'+
                           '<li id="myZigPhoto" style="padding-bottom:0;margin-bottom:0;"><a href="/my-album-list.html" >Мои альбомы</a></li>'+
                           '<li><a href="/orderlist.html" >Мои заказы</a></li>'+
                           '<li><a href="/profileupdate.html" >Мой профайл</a></li>'+
						   '<li><a href="/invitation.html" >Пригласить</a></li>'+
                         '</ul>'+
			 '<div class="clear"></div>'+
			 '</li>'+
			 
                         '<li id="myZigUpload"><a  href="javascript:void(0);" >Загрузить</a>'+
                         '<ul class="dropdown_menu menuUploadTrig">'+
                           '<li id="myZigPhoto" style="padding-bottom:0;margin-bottom:0;"><a href="/photoupload.html" >По одной</a></li>'+
                           '<li><a href="/zipupload.html" >ZIP архивом</a></li>'+
                           
			 '</ul>'+
			 '<div class="clear"></div>'+
                         '</li>'+
                         
			 '<li id="myZakazM">'+
			 	'<a href="javascript:void(0);"  id="myZigMakeOrder">Оформить заказ</a>'+
				'<ul class="dropdown_menu myZakaz">'+
                          '<li id="myZigPhoto" style="padding-bottom:0;margin-bottom:0;"><a href="/my-album-list-to-order.html" >Мои альбомы</a></li>'+
                          '<li><a href="/courier-services.html" >Вызов курьера</a></li>'+
                           
                         '</ul>'+
				'</li>'+
				
			 '<li><a href="/feedback.html"  id="myZigFeedback">Обратная связь</a></li>'+
			 '<li><a href="/help/"  id="myZigHelp">Центр помощи</a></li>'+
			 '<li class="lastMenu"><a href="/blog/"  id="blogbutton">Блог</a></li>'+
			 '</ul>'+
			 '<div class="clear"></div>'+
			 '</div>');
	
	  
	$("#nav ul").removeClass("nj");
	 
	 

	 
	$("#myZigzagMenu").hoverIntent({
		 sensitivity: 3,
		 interval : 50,
		 over: function () {
			
			if ( !$(this).hasClass("hovering") ){
			 $(this).addClass("hovering");
			
			
			$(".menuMyZigTrig").css("width" , 137 );
			
			$(this).find(".menuMyZigTrig").hide();
			$(this).find(".menuMyZigTrig").show();
		        $(this).find(".menuMyZigTrig").queue("fx",[]);
			$(this).find(".menuMyZigTrig").slideDown("fast");
		;}},
		 timeout : 500,
		 out : function () {

			 $(this).find(".menuMyZigTrig").hide();
		
			 $(this).removeClass("hovering");
	}});
	$("#myZigUpload").hoverIntent({
		 sensitivity: 3,
		 interval : 50,
		 over: function () {
			
			if ( !$(this).hasClass("hovering") ){
			 $(this).addClass("hovering");
			
			
			$(".menuUploadTrig").css("width" , 137 );
			
			$(this).find(".menuUploadTrig").hide();
			$(this).find(".menuUploadTrig").show();
		        $(this).find(".menuUploadTrig").queue("fx",[]);
			$(this).find(".menuUploadTrig").slideDown("fast");
		;}},
		 timeout : 500,
		 out : function () {

			 $(this).find(".menuUploadTrig").hide();
		
			 $(this).removeClass("hovering");
	}});
	 
	 $("#myZakazM").hoverIntent({
		 sensitivity: 3,
		 interval : 50,
		 over: function () {
			
			if ( !$(this).hasClass("hovering") ){
			 $(this).addClass("hovering");
			
			
			$(".myZakaz").css("width" , 137 );
			
			$(this).find(".myZakaz").hide();
			$(this).find(".myZakaz").show();
		        $(this).find(".myZakaz").queue("fx",[]);
			$(this).find(".myZakaz").slideDown("fast");
		;}},
		 timeout : 500,
		 out : function () {

			 $(this).find(".myZakaz").hide();
		
			 $(this).removeClass("hovering");
	}});
	 
	 var userName = $.cookie("userName");
	 
	 if(userName){
		$(".onlyforregistred").css("display" , "block");
		$(".welcome").empty();
		$(".welcome").append("<span>Добро пожаловать, "+userName+"&nbsp;&nbsp;&nbsp;&nbsp;</span><a class='welcome' style='text-decoration:underline;' id='logoutLink' href='javascript:void(0)'>(выход)</a>");
		$("#logoutLink").click(function(){
			zwsGetJSON("LogoutServlet",{},function(data){
				
				if(data.status=="200"){
					window.location="index.html";
					$.cookie('userName', null);
				}
				if(data.status=="401"){
					window.location="index.html";
					$.cookie('userName', null);
				}
					
			});
		});
	 } 
	 
	 
	 
	 
	 $("#headeinput").bind("keyup", function(event) {
		if(event.keyCode == 13) {
			 $("#headersubmit").trigger("click");
					}
		 });

		 $("#headersubmit").bind("click", function() {
		 var sfVal = $.trim($("#headeinput").val());
		 if(sfVal && sfVal.length > 0) {
		 window.location = "/photo-search.html#q=" + sfVal;
		 }
		 return false;
		 });
		 
         
	 
	 /* BANNER */
	 
	 var bannerName = ["banner.swf?clickTARGET=_blank&clickTAG=http://www.zigzagz.net/convertNegativeToPositive.html","banner_2(rus).swf?clickTARGET=_blank&clickTAG=http://www.zigzagz.net/butterflyAbout.html"];
	 
	 
	 var myBanner = bannerName[Math.floor(Math.random()*2)];
	 $(".advertise").html('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="301" height="100%" align="middle" wmode="transparent">'+
			      '<param name="allowScriptAccess" value="sameDomain" />'+
			      '<param name="movie" value="/swf/'+myBanner+'" />'+
                              '<param name="quality" value="high" />'+
			      '<param name="bgcolor" value="#ffffff" />'+
                              '<param name="SCALE" value="exactfit">'+
			      '<param name="wmode" value="transparent">'+
                              '<embed wmode="transparent" src="/swf/'+myBanner+'" width="301" height="100%" align="middle" quality="high" bgcolor="#fff" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" scale="exactfit" />'+   
                              '</object>');
	 
	 /* Google Analytics */
	 $.getScript("http://www.google-analytics.com/urchin.js" , function()
		     
		     {
			
			 $(document).append("<script type='text/javascript'>"+
                              "_uacct = 'UA-824962-5';"+
                              "urchinTracker();"+
                              "</script>");
			
		     }
		     );
         
	   
	  $(".footer").html('<div style="width:952px;margin:0 auto 0 auto;line-height:45px;color:#fff;font-family:arial;font-size:9pt;"><span style="float:left;">'+
	  '<a href="/promo/products.html" class="footerLink" style="margin-left:0;">Продукция и цены</a>|'+
	  '<a href="/promo/services.html" class="footerLink">Услуги и сервис</a>|'+ 
	  '<a href="/promo/partners.html" class="footerLink">Наши партнёры</a>|'+
	  '<a href="/promo/advertisers.html" class="footerLink">Рекламодателям</a></span><span style="float:right;">Zigzag Photo 2008</span></div>'); 
	  
			
				 
	 });

	 



	 
	 

