// JavaScript Document

var curLh = 0;
var prevLh = 0;
var curSrcLh = "";
var LhthumbSclPos = 1;


var sliderOpen = false;
var scrlCount = 0;
var filePath = path+fotoStartsWith;

function setupLh(curID){
	curLh = curID;
	if(prevLh!=0){
		jQuery("#LhThumb"+prevLh).animate({opacity:0.5},250)
	}
	//alert(MediumImage[curLh-1]+" : "+BigImage[curLh-1])
	populatePopup("Medium"+curLh+".jpg","Enlarge"+curLh+"_1.jpg",desc[curLh-1],hlinks[curLh-1]);
	jQuery("#LhThumb"+curLh).animate({opacity:1},250);
}

function OnThumbLh(id){
	prevLh = Number(curLh);
	id = id.replace("LhThumb","");
	setupLh(id);
}

jQuery(document).ready(function(){
	jQuery('.levisHotNewsTxtSec').jScrollPane();	
	for(i=1;i<=totLh;i++){
		jQuery("#LhThumb"+i).animate({opacity:0.5},250)
		jQuery("#LhThumb"+i).hover(function(){
		id = jQuery(this).attr("id");
		id = id.replace("LhThumb","");
		/*if(id!=curLh){
			temp = jQuery(this).attr("src");
			temp = temp.replace("Off","On");
			jQuery(this).attr("src",temp);
		}*/
		if(id!=curLh){
			jQuery(this).stop().animate({opacity:1},250)
		}
		//jQuery(this).stop().animate({opacity:1},250)
		
		},
		function(){
		id = jQuery(this).attr("id");
		id = id.replace("LhThumb","");
		/*if(id!=curLh){
			temp = jQuery(this).attr("src");
			temp = temp.replace("On","Off");
			jQuery(this).attr("src",temp);
		}*/
		if(id!=curLh){
			jQuery(this).stop().animate({opacity:0.5},250)
		}
		//jQuery(this).stop().animate({opacity:0.5},250)
		
		});
	}
	
	
	jQuery("#LhRightArr").click(function(){
		if(LhthumbSclPos<totLh-4){
			LhthumbSclPos = Number(LhthumbSclPos)+1;
		}
		else{
			LhthumbSclPos = 1;
		}
		setupThumbnails("LhThumbnails",LhthumbSclPos);
	});
	
	jQuery("#LhLeftArr").click(function(){
		if(LhthumbSclPos>1){
			LhthumbSclPos = Number(LhthumbSclPos)-1;
		}
		else{
			LhthumbSclPos = totLh-4;
		}
		setupThumbnails("LhThumbnails",LhthumbSclPos);
	});
	
	jQuery("#SlideOutArr").click(function(){
	if(!sliderOpen){
		tempSrc = jQuery(this).attr("src");
		tempSrc = tempSrc.replace("Right","Left");
		jQuery(this).attr("src",tempSrc);
	 	jQuery("#LHConsLeft").stop().animate({left:(0+"px")},700,"backinout");
	 	jQuery("#LHConsRight").stop().animate({left:(560+"px")},700,"backinout");
		sliderOpen = true;
	}
	else{
		
		tempSrc = jQuery(this).attr("src");
		tempSrc = tempSrc.replace("Left","Right");
		jQuery(this).attr("src",tempSrc);
	 	jQuery("#LHConsLeft").stop().animate({left:(112+"px")},700,"backinout");
	 	jQuery("#LHConsRight").stop().animate({left:(447+"px")},700,"backinout");
		sliderOpen = false;
		
	}
	});
	
	jQuery("#scrlDown").click(function(){
	
		maxScrl = Number(jQuery("#happeningsScrlTxtCons").height()/(190/2));
		if(scrlCount<maxScrl-1){
			scrlCount = scrlCount+1;
			jQuery("#happeningsScrlTxtCons").animate({top:-(scrlCount*(190/2))+"px"},500)
		}
	
	});
	
	jQuery("#scrlUp").click(function(){
	
		maxScrl = Number(jQuery("#happeningsScrlTxtCons").height()/(190/2));
		if(scrlCount>0){
			scrlCount = scrlCount-1;
			jQuery("#happeningsScrlTxtCons").animate({top:-(scrlCount*(190/2))+"px"},500);
		}
	
	});
	
});

function setupThumbnails(holder,movex){
	//alert("movex:"+movex+"  "+(-(movex-1)*59)+"px")
	jQuery("#"+holder).stop().animate({marginLeft:(-(movex-1)*109)+"px"},350);
}

function nextPopup(){
	prevLh = curLh;
	if(curLh>=totLh){
		curLh = 1;
	}
	else{
		curLh = Number(curLh)+1;
	}
	//populatePopup(MediumImage[curLh-1],BigImage[curLh-1]);
	setupLh(curLh);
}

function PreviousPopup(){
	prevLh = curLh;
	if(curLh<=1){
		curLh = totLh;
	}
	else{
		curLh = Number(curLh)-1;
	}
	setupLh(curLh);
	//populatePopup(MediumImage[curLh-1],BigImage[curLh-1]);
}

function populatePopup(mImg,bImg,dImg,lImg){
	
	jQuery("#popupBg").css("display","block");
	jQuery("#popupBg").animate({opacity:0.9},1);
	jQuery("#lhPopUp").css("display","block");
	
	
	tempInnerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' name='imagezoom' width='554' height='364' align='middle' id='imagezoom'><param name='movie' value='../Flash/imagezoomwithDesc.swf?image="+filePath+mImg+"&amp;imagebig="+filePath+bImg+"&amp;imgW=554&amp;imgH=384&amp;desc="+dImg+"&amp;lText="+linkTxt+"&amp;hlink="+lImg+"'/><param name='loop' value='false' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><param name='wmode' value='transparent' /><embed src='../Flash/imagezoomwithDesc.swf?image="+filePath+mImg+"&amp;imagebig="+filePath+bImg+"&amp;imgW=554&amp;imgH=384&amp;desc="+dImg+"&amp;lText="+linkTxt+"&amp;hlink="+lImg+"' width='554' height='364' loop='false' align='middle' menu='false' quality='high' bgcolor='#ffffff' name='imagezoom' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='transparent'></embed></object>";	
 document.getElementById("flashObj").innerHTML = tempInnerHTML;
	
}

function hidePopup(){
	jQuery("#popupBg").css("display","none");
	jQuery("#lhPopUp").css("display","none");
	jQuery("#LhThumb"+curLh).animate({opacity:0.5},250);
	curLh = 0;
	prevLh = 0;
}

