// JavaScript Document
var isDraggingRelease=false;
	var modelCurrentIndexRelease=0;
	
	function setImageOpacityRelease(obj){
		if(isDragging){
			return;
		}
		var parentDiv = $("divReleasePhotosCenter");
		
		
		var parentTr = obj.parentNode;
		for(var i=0;i<parentTr.cells.length;i++){
			var curCell = parentTr.cells[i];
			if(curCell!=obj){
				$(curCell).setOpacity(0.4);
			}
		}
		
			
			//if we didnt find any salon then our index will be correct to find if it is odd or even
				
				var index = obj.cellIndex;
				modelCurrentIndexRelease=index;
				var imageSel = new Image();
				imageSel.src = obj.childNodes[0].getAttribute("alt");
				
				$jquery("#divReleasePhotosCenter").animate({opacity:0.0},300,function(){
						parentDiv.innerHTML="";
						
						parentDiv.innerHTML="<img src='"+imageSel.src+"' border='0' alt='' width='645px' height='416px' />";
						
						$jquery("#divReleasePhotosCenter").animate({opacity:1.0},300,function(){});
				});
			
		//$('t').value=modelCurrentIndex;
	}
	function unsetImageOpacityRelease(obj){
		var parentTr = obj.parentNode;
		for(var i=0;i<parentTr.cells.length;i++){
			var curCell = parentTr.cells[i];
			$(curCell).setOpacity(1.0);
		}
	}
	
	function getPreviousModelImageRelease(){
		var parentDiv = $("divReleasePhotosCenter");
		var t = $("tableModelPhotos");
		var cells = t.tBodies[0].rows[0].cells;
		if(modelCurrentIndexRelease==0){
			modelCurrentIndexRelease=cells.length-1;
			
		}else{
			modelCurrentIndexRelease=modelCurrentIndexRelease-1;
			
		}
		var imageSel = new Image();
		imageSel.src = cells[modelCurrentIndexRelease].childNodes[0].getAttribute("alt");
				
		$jquery("#divReleasePhotosCenter").animate({opacity:0.0},300,function(){
			parentDiv.innerHTML="";
						
			parentDiv.innerHTML="<img src='"+imageSel.src+"' border='0' alt='' width='645px' height='416px' />";
						
			$jquery("#divReleasePhotosCenter").animate({opacity:1.0},300,function(){});
		});
	}
	
	function getNextModelImageRelease(){
		var parentDiv = $("divReleasePhotosCenter");
		var t = $("tableModelPhotos");
		var cells = t.tBodies[0].rows[0].cells;
		
		if(modelCurrentIndexRelease==cells.length-1){
			modelCurrentIndexRelease=0;
		}else{
			modelCurrentIndexRelease=modelCurrentIndexRelease+1;
		}
		var imageSel = new Image();
		imageSel.src=cells[modelCurrentIndexRelease].childNodes[0].getAttribute("alt");
		
		$jquery("#divReleasePhotosCenter").animate({opacity:0.0},300,function(){
			parentDiv.innerHTML="";
						
			parentDiv.innerHTML="<img src='"+imageSel.src+"' border='0' alt='' width='645px' height='416px' />";
						
			$jquery("#divReleasePhotosCenter").animate({opacity:1.0},300,function(){});
		});
	}
	
	
	function getModelRelease(){
		if(!$("divScrollbar")){
			return;
		}
		var parentWidth=$("divModelPhotosWrapper").offsetWidth
		var childWidth=$("tableModelPhotosReleases").offsetWidth;
		var diff = childWidth-parentWidth;
		
		var firstPosLeft=0;
		var pointerPosLeft=0;
		var diffPosLeft=0;
		
		if(childWidth>parentWidth){
			
			var isDrag=false;
			var divScroll = $("divScrollbar");
			divScroll.style.display='block';
			
			var divScrollChild = $("divScrollbarChild");
			divScrollChild.onmousedown=function(e){
				if(!e){e=window.event;}
				isDrag=true;
				isDragging=true;
				firstPosLeft = parseInt(this.style.left);
				pointerPosLeft = parseInt(Event.pointerX(e));
				diffPosLeft = pointerPosLeft-firstPosLeft;
				
				document.onmousemove=function(e){
					if(!e){e=window.event;}
					if(isDrag){
						var pointerX = Event.pointerX(e);
						divScrollChild.style.left=pointerX-diffPosLeft+"px";
						var moveX = parseInt(divScrollChild.style.left);
						var percent = diff/divScroll.offsetWidth;
						percent = percent*moveX;
						percent=parseInt(Math.ceil(percent));
						//alert(percent);
						$("tableModelPhotosReleases").style.left=-percent+"px";
						return false;
					}
				};
				
				document.onmouseup=function(){
					isDrag=false;
					isDragging=false;
					document.onmousemove=null;
				};
				document.onmousedown=function(){
					if(isDrag){
						return false;
					}else{
						return true;
					}
				};
			};
			divScrollChild.onmousemove2=function(e){
				
			};
			divScrollChild.onmouseup=function(e){
				isDrag=false;
				isDragging=false;
				document.onmousemove=null;
			};
			
			
		}else{
			$("divScrollbar").style.display='none';
		}
	
	}//function getModel();
	