jQuery.noConflict();
jQuery(document).ready(function(){
var dzZoomed=false;
var dzMenuCurrent=0;
jQuery("div#mainNav ul.menu > li").mouseenter(function(){
	var dzMenuClass=parseInt(jQuery(this).attr("class").split('_').last());
	if (dzMenuCurrent!=dzMenuClass){
		jQuery("div.dzNavSubCat").slideUp("medium");
		jQuery("#mainNav li a span").removeClass("dzHovred");
		dzMenuCurrent=0;
	}
	var self=this;
	jQuery("div.dzNavSubCat").removeClass("dzEnterInMenu");
	jQuery("div#dzsub_"+dzMenuClass).addClass("dzEnterInMenu");
	setTimeout(function(){ 
           if (jQuery("div#dzsub_"+dzMenuClass).hasClass("dzEnterInMenu")){
		if(jQuery("div#dzsub_"+dzMenuClass).length>0 && dzMenuCurrent!=dzMenuClass){
		    jQuery(self).find("a span").addClass("dzHovred");
		    jQuery("div.dzNavSubCat").slideUp("medium");
		    jQuery("#navbox").slideUp("medium");
		    jQuery("div#dzsub_"+dzMenuClass).slideDown();
		    dzMenuCurrent=dzMenuClass;
		}
           }
	},100);
});
jQuery("#dzMouseNavE").mouseleave(function(){
	dzMenuCurrent=0;
	jQuery("div.dzNavSubCat").slideUp("medium");
	jQuery("#mainNav li a span").removeClass("dzHovred");
});
jQuery("div#mainNav ul.menu > li").mouseleave(function(){
	jQuery("div.dzNavSubCat").removeClass("dzEnterInMenu");
});

jQuery("#dzArchive").click(function(){
	jQuery("#dzArchiveBox").fadeToggle("medium");
});
jQuery("#dzShowAll").click(function(){
	jQuery("div.dzNavSubCat").slideUp("medium");
	dzMenuCurrent=0;
	jQuery("#navbox").slideToggle("medium",function(){jQuery("#dzShowAll").toggleClass('collapse');});
});
jQuery(".dzpdfZoom").mouseenter(function(){
	var self=this;
	jQuery(this).addClass('dzMouseEnter');
	setTimeout(function(){ 
		if(jQuery(self).hasClass('dzMouseEnter')){
		     jQuery(self).find('img').animate({height:'350px',width:'250px',top:'-30px',right:'-60px'},"fast",function(){dzZoomed=true;jQuery("#RegistrationRequired").fadeIn("fast");});
		}
	},100);
}).mouseleave(function(){
	jQuery(this).removeClass('dzMouseEnter');
	var self=this;
	if (dzZoomed){
		if (jQuery("#RegistrationRequired").length>0){
			jQuery("#RegistrationRequired").fadeOut("fast");
			jQuery(self).find('img').animate({height:'155px',width:'117px',top:'2px',right:'10px'},"fast",function(){dzZoomed=false;});
		}else{
			jQuery(self).find('img').animate({height:'155px',width:'117px',top:'2px',right:'10px'},"fast",function(){dzZoomed=false;});
		}
	}
});

jQuery('.dzlatestnews .short').mouseenter(function(){
	jQuery(this).addClass('dzMouseEnter');
	var self=this;
	setTimeout(function(){ 
		if(jQuery(self).hasClass('dzMouseEnter') && (jQuery(self).find('div.image').length>0) && (jQuery(self).find('div.image').css("display")=="none")){
			jQuery('.dzlatestnews .short').find('div.image').slideUp("fast");
			jQuery(self).find('div.image').slideDown("fast");
		}
	},100);
});
jQuery('.dzlatestnews .short').mouseleave(function(){
	jQuery(this).removeClass('dzMouseEnter');
});

	var currentHead=1;
	var index=1;
	var dzStop=0;
	var dzLock=0;
	jQuery(".dzclickHead").mouseenter(function(){
		index=jQuery(this).attr("href").split('_').last();
		if(currentHead!=index){
			jQuery("a.dzclickHead").removeClass("dzHeadlinesActive");
			jQuery("a.dzclickHead").closest("div").removeClass("dzHeadlinesActiveArrow");
			jQuery(this).closest("div").addClass("dzHeadlinesActiveArrow");
			jQuery(this).addClass("dzHeadlinesActive");
			jQuery("#dzrot_"+currentHead).animate({opacity:0},"fast",function(){
				jQuery(".dzHeadlinesAll").css("left","470px");
				jQuery("#dzrot_"+index).css("left","0");
				jQuery("#dzrot_"+index).animate({opacity:1},"fast");
				currentHead=index;
				dzStop=2;
			});
		}
	});
	jQuery(".dzThumbHead").mouseenter(function(){
		dzStop=2;
	})
	jQuery(".dzThumbHead").mouseleave(function(){
		dzStop=1;
	});
	dzRotate();
	
	function dzMouseTracking(){
		setTimeout(function(){
			dzRotate();
		},1000);
	}
	function dzRotate(){
		if (dzStop==2){
			dzMouseTracking();
		}
		else{
			setTimeout(function(){
				if (dzStop==1){
					setTimeout(function(){
						if (dzStop==1){
							jQuery("a.dzclickHead").removeClass("dzHeadlinesActive");
							jQuery("a.dzclickHead").closest("div").removeClass("dzHeadlinesActiveArrow");
							index=(currentHead==5)?(1):(parseInt(currentHead)+1);
							jQuery("a[href='#dzrotlink_"+index+"']").addClass("dzHeadlinesActive");
							jQuery("a[href='#dzrotlink_"+index+"']").closest("div").addClass("dzHeadlinesActiveArrow");
							jQuery("#dzrot_"+currentHead).animate({opacity:0},"fast",function(){
								jQuery(".dzHeadlinesAll").css("left","470px");
								jQuery("#dzrot_"+index).css("left","0");
								jQuery("#dzrot_"+index).animate({opacity:1},"fast");
								currentHead=index;
								dzStop=0;
								dzRotate();
							});
						}else {
							dzRotate();
						}
					},5000);
				}
				else{
					if (dzStop!=2){
						jQuery("a.dzclickHead").removeClass("dzHeadlinesActive");
						jQuery("a.dzclickHead").closest("div").removeClass("dzHeadlinesActiveArrow");
						index=(currentHead==5)?(1):(parseInt(currentHead)+1);
						jQuery("a[href='#dzrotlink_"+index+"']").addClass("dzHeadlinesActive");
						jQuery("a[href='#dzrotlink_"+index+"']").closest("div").addClass("dzHeadlinesActiveArrow");
						jQuery("#dzrot_"+currentHead).animate({opacity:0},"fast",function(){
							jQuery(".dzHeadlinesAll").css("left","470px");
							jQuery("#dzrot_"+index).css("left","0");
							jQuery("#dzrot_"+index).animate({opacity:1},"fast");
							currentHead=index;
							dzRotate();
						});
					}else {
						dzRotate();
					}
				}
			}, 5000);
		}
	}
	
	
/**/
	var spcurrentHead=1;
	var spindex=1;
	var spdzStop=0;
	var spdzLock=0;
	jQuery(".spdzclickHead").mouseenter(function(){
		spindex=jQuery(this).attr("href").split('_').last();
		if(spcurrentHead!=spindex){
			jQuery("a.spdzclickHead").removeClass("spdzHeadlinesActive");
			jQuery("a.spdzclickHead").closest("div").removeClass("spdzHeadlinesActiveArrow");
			jQuery(this).closest("div").addClass("spdzHeadlinesActiveArrow");
			jQuery(this).addClass("spdzHeadlinesActive");
			jQuery("#spdzrot_"+spcurrentHead).animate({opacity:0},"fast",function(){
				jQuery(".spdzHeadlinesAll").css("left","470px");
				jQuery("#spdzrot_"+spindex).css("left","0");
				jQuery("#spdzrot_"+spindex).animate({opacity:1},"fast");
				spcurrentHead=spindex;
				spdzStop=2;
			});
		}
	});
	jQuery(".spdzThumbHead").mouseenter(function(){
		spdzStop=2;
	})
	jQuery(".spdzThumbHead").mouseleave(function(){
		spdzStop=1;
	});
	spdzRotate();
	
	function spdzMouseTracking(){
		setTimeout(function(){
			spdzRotate();
		},1000);
	}
	function spdzRotate(){
		if (spdzStop==2){
			spdzMouseTracking();
		}
		else{
			setTimeout(function(){
				if (spdzStop==1){
					setTimeout(function(){
						if (spdzStop==1){
							jQuery("a.spdzclickHead").removeClass("spdzHeadlinesActive");
							jQuery("a.spdzclickHead").closest("div").removeClass("spdzHeadlinesActiveArrow");
							spindex=(spcurrentHead==5)?(1):(parseInt(spcurrentHead)+1);
							jQuery("a[href='#spdzrotlink_"+spindex+"']").addClass("spdzHeadlinesActive");
							jQuery("a[href='#spdzrotlink_"+spindex+"']").closest("div").addClass("spdzHeadlinesActiveArrow");
							jQuery("#spdzrot_"+spcurrentHead).animate({opacity:0},"fast",function(){
								jQuery(".spdzHeadlinesAll").css("left","470px");
								jQuery("#spdzrot_"+spindex).css("left","0");
								jQuery("#spdzrot_"+spindex).animate({opacity:1},"fast");
								spcurrentHead=spindex;
								spdzStop=0;
								spdzRotate();
							});
						}else {
							spdzRotate();
						}
					},5000);
				}
				else{
					if (spdzStop!=2){
						jQuery("a.spdzclickHead").removeClass("spdzHeadlinesActive");
						jQuery("a.spdzclickHead").closest("div").removeClass("spdzHeadlinesActiveArrow");
						spindex=(spcurrentHead==5)?(1):(parseInt(spcurrentHead)+1);
						jQuery("a[href='#spdzrotlink_"+spindex+"']").addClass("spdzHeadlinesActive");
						jQuery("a[href='#spdzrotlink_"+spindex+"']").closest("div").addClass("spdzHeadlinesActiveArrow");
						jQuery("#spdzrot_"+spcurrentHead).animate({opacity:0},"fast",function(){
							jQuery(".spdzHeadlinesAll").css("left","470px");
							jQuery("#spdzrot_"+spindex).css("left","0");
							jQuery("#spdzrot_"+spindex).animate({opacity:1},"fast");
							spcurrentHead=spindex;
							spdzRotate();
						});
					}else {
						spdzRotate();
					}
				}
			}, 5000);
		}
	}


	dzsectionCurrent=1;
	dzsectionMax=(jQuery(".section").length-1)*6;
	jQuery("#gallerySuiv").click(function(){
		if (dzsectionCurrent<dzsectionMax){
			jQuery(".dzsection_"+dzsectionCurrent).fadeOut("medium",function(){
				dzsectionCurrent+=6;
				jQuery(".dzsection_"+dzsectionCurrent).fadeIn("medium");
			});
		}
	});
	jQuery("#galleryPrec").click(function(){
		if (dzsectionCurrent>1){
			jQuery(".dzsection_"+dzsectionCurrent).fadeOut("medium",function(){
				dzsectionCurrent-=6;
				jQuery(".dzsection_"+dzsectionCurrent).fadeIn("medium");
			});
		}
	});
/**/
		var dzVideoCurrent=1;
		var dzVideoMax=parseInt(jQuery(".dzVideoItem").length);
		var dzVideoThumbCurrent=0;
		var dzVideoThumbMax=(Math.ceil(dzVideoMax/3)-1)*264;
		var dzVideoInterruptSliding=false;
		var dzVideoClick=false;
		jQuery("#dzVideoNext").click(function(){
			if (!dzVideoInterruptSliding && dzVideoThumbCurrent<dzVideoThumbMax){
				dzVideoInterruptSliding=true;
				dzVideoThumbCurrent=(dzVideoThumbCurrent<dzVideoThumbMax)?dzVideoThumbCurrent+264:264;
				if(dzVideoThumbCurrent==dzVideoThumbMax){jQuery("#dzVideoNext").addClass("dzVideoDisabled");}
				jQuery("#dzVideoSlider").animate({right:-dzVideoThumbCurrent},function(){dzVideoInterruptSliding=false});
			}
		});
		jQuery("#dzVideoPrec").click(function(){
			if (!dzVideoInterruptSliding && dzVideoThumbCurrent>0){
				dzVideoInterruptSliding=true;
				dzVideoThumbCurrent=(dzVideoThumbCurrent>0)?dzVideoThumbCurrent-264:0;
				if(dzVideoThumbCurrent==dzVideoThumbMax){jQuery("#dzVideoNext").addClass("dzVideoDisabled");}
				jQuery("#dzVideoSlider").animate({right:-dzVideoThumbCurrent},function(){dzVideoInterruptSliding=false});
			}
		});
		jQuery(".dzVideoItemThumb").click(function(){
			dzVideoClick=parseInt(jQuery(this).attr("id").split('_').last());
			if (dzVideoClick!=dzVideoCurrent){
				jQuery(".dzVideoItem").slideUp();
				jQuery("#dzVideo_"+dzVideoClick).slideDown();
				jQuery(".dzVideoItemThumb > div").removeClass("dzVideoThumbCurrent");
				jQuery("#dzVideoItem_"+dzVideoClick+" > div").addClass("dzVideoThumbCurrent");
				dzVideoCurrent=dzVideoClick;
			}
		});
function dzWeather(){
					jQuery("#dzWeatherCancelButton").click(function(){
						jQuery("#dzWeatherChangeBox").hide("medium");
						jQuery("#dzWeatherInformations").show("medium");
					});
					jQuery("#dzWeatherChange").click(function(){
						jQuery("#dzWeatherChangeBox").show("medium");
						jQuery("#dzWeatherInformations").hide("medium");
					});
					jQuery("#dzWeatherDetails").mouseenter(function(){
						jQuery("#dzWeatherMoreInfoBox").show("fast");
					}).mouseleave(function(){
						jQuery("#dzWeatherMoreInfoBox").hide("fast");
					});
					jQuery("#dzWeatherForecast").mouseenter(function(){
						jQuery("#dzWeatherForeCastBox").show("fast");
					}).mouseleave(function(){
						jQuery("#dzWeatherForeCastBox").hide("fast");
					});
					jQuery("#dzWeatherChangeButton").click(function(){
						jQuery("#dzWeatherChangeBox").animate({'opacity':0.3},function(){
	jQuery.get("dzGetWeather.php?w="+jQuery("#dzcity").attr("value"),function(content){
			if(content!="DZKO"){
				jQuery('#dzWeatherContainner').html(content);dzWeather();
			}
			else{
				alert("المدينة المختارة غير مدعومة، يفضل كتابة أسماء المدن بالفرنسية أو الانجليزية.");
				jQuery("#dzWeatherChangeBox").animate({'opacity':1},function(){
					jQuery("#dzWeatherChangeBox").hide("medium");
					jQuery("#dzWeatherInformations").show("medium");
				});
			}
    	}); 

						});
					});
				}
				dzWeather();

	var echoroukTVCurrent="dzEchoroukTVlatest";
	var echoroukLock=false;
	jQuery("#dzEchoroukTVlatestButton").click(function(){
		if (echoroukTVCurrent!="dzEchoroukTVlatest" && !echoroukLock){
			echoroukLock=true;
			jQuery("#"+echoroukTVCurrent).fadeOut("medium",function(){
				jQuery("#dzEchoroukTVlatest").fadeIn("medium");
				echoroukLock=false;
			});
			jQuery("#dzVideosChoiceBox li").removeClass("CurrentBox");
			jQuery(this).addClass("CurrentBox");
			echoroukTVCurrent="dzEchoroukTVlatest";
		}
	});
	jQuery("#dzEchoroukTVPopularButton").click(function(){
		if (echoroukTVCurrent!="dzEchoroukTVPopular" && !echoroukLock){
			echoroukLock=true;
			jQuery("#"+echoroukTVCurrent).fadeOut("medium",function(){
				jQuery("#dzEchoroukTVPopular").fadeIn("medium");
				echoroukLock=false;
			});
			jQuery("#dzVideosChoiceBox li").removeClass("CurrentBox");
			jQuery(this).addClass("CurrentBox");
			echoroukTVCurrent="dzEchoroukTVPopular";
		}
	});
	jQuery("#dzEchoroukTVCommentsButton").click(function(){
		if (echoroukTVCurrent!="dzEchoroukTVComments" && !echoroukLock){
			echoroukLock=true;
			jQuery("#"+echoroukTVCurrent).fadeOut("medium",function(){
				jQuery("#dzEchoroukTVComments").fadeIn("medium");
				echoroukLock=false;
			});
			jQuery("#dzVideosChoiceBox li").removeClass("CurrentBox");
			jQuery(this).addClass("CurrentBox");
			echoroukTVCurrent="dzEchoroukTVComments";
		}
	});
	var CurrentRightVal=0;
	var RightValMax=Math.ceil(parseInt(jQuery("#dzEchoroukTVlatest .dzRightOne").length)/3.0)-1;
	jQuery("#dzEchoroukTVlatest span.left").click(function(){
		if (CurrentRightVal<(RightValMax*477)){
			jQuery("#dzEchoroukTVlatest div.dzMovable").animate({'right':-(CurrentRightVal+477)});
			CurrentRightVal=(CurrentRightVal+477);
		}
	});
	jQuery("#dzEchoroukTVlatest span.right").click(function(){
		if (CurrentRightVal>0){
			jQuery("#dzEchoroukTVlatest div.dzMovable").animate({'right':-(CurrentRightVal-477)});
			CurrentRightVal=(CurrentRightVal-477);
		}
	});

	var dzEchoroukTVPopularCurrentRightVal=0;
	var dzEchoroukTVPopularRightValMax=Math.ceil(parseInt(jQuery("#dzEchoroukTVPopular .dzRightOne").length)/3.0)-1;
	jQuery("#dzEchoroukTVPopular span.left").click(function(){
		if (dzEchoroukTVPopularCurrentRightVal<(dzEchoroukTVPopularRightValMax*477)){
			jQuery("#dzEchoroukTVPopular div.dzMovable").animate({'right':-(dzEchoroukTVPopularCurrentRightVal+477)});
			dzEchoroukTVPopularCurrentRightVal=(dzEchoroukTVPopularCurrentRightVal+477);
		}
	});
	jQuery("#dzEchoroukTVPopular span.right").click(function(){
		if (dzEchoroukTVPopularCurrentRightVal>0){
			jQuery("#dzEchoroukTVPopular div.dzMovable").animate({'right':-(dzEchoroukTVPopularCurrentRightVal-477)});
			dzEchoroukTVPopularCurrentRightVal=(dzEchoroukTVPopularCurrentRightVal-477);
		}
	});

	var dzEchoroukTVCommentsCurrentRightVal=0;
	var dzEchoroukTVCommentsRightValMax=Math.ceil(parseInt(jQuery("#dzEchoroukTVComments .dzRightOne").length)/3.0)-1;
	jQuery("#dzEchoroukTVComments span.left").click(function(){
		if (dzEchoroukTVCommentsCurrentRightVal<(dzEchoroukTVCommentsRightValMax*477)){
			jQuery("#dzEchoroukTVComments div.dzMovable").animate({'right':-(dzEchoroukTVCommentsCurrentRightVal+477)});
			dzEchoroukTVCommentsCurrentRightVal=(dzEchoroukTVCommentsCurrentRightVal+477);
		}
	});
	jQuery("#dzEchoroukTVComments span.right").click(function(){
		if (dzEchoroukTVCommentsCurrentRightVal>0){
			jQuery("#dzEchoroukTVComments div.dzMovable").animate({'right':-(dzEchoroukTVCommentsCurrentRightVal-477)});
			dzEchoroukTVCommentsCurrentRightVal=(dzEchoroukTVCommentsCurrentRightVal-477);
		}
	});

});
