// JavaScript Document
<!--
	var isDragging=false;
	var modelCurrentIndex=0;
	var rightModelPhotosLeftDiv=null;
	var rightModelPhotosRightDiv=null;
	var rightModelPhotosCenterDiv=null;
	
	function setImageOpacity(obj){
		if(isDragging){
			return;
		}
		var parentDiv = $("rightModelPhotosDiv");
		if(rightModelPhotosLeftDiv==null){
			rightModelPhotosLeftDiv = $("rightModelPhotosLeftDiv");
		}
		if(rightModelPhotosRightDiv==null){
			rightModelPhotosRightDiv = $("rightModelPhotosRightDiv");
		}
		if(rightModelPhotosCenterDiv==null){
			rightModelPhotosCenterDiv = $("rightModelPhotosCenterDiv");	
		}
		
		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(obj.getAttribute("issalon")==1){
		
			modelCurrentIndex=obj.cellIndex;
			var myImage = new Image();
			myImage.src = obj.childNodes[0].getAttribute("alt");
			$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
				parentDiv.innerHTML="";
				parentDiv.innerHTML="<img src='"+myImage.src+"' width='646px' height='432px' border='0' alt'' />";
				$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
			});
		}else{
			
			
			var countSalon=0;
			for(var i=0;i<parentTr.cells.length;i++){
				var curCell = parentTr.cells[i];
				if(curCell.cellIndex<obj.cellIndex){
					if(curCell.getAttribute("issalon")=="1"){
						countSalon++;
					}
				}
			}
			//if we didnt find any salon then our index will be correct to find if it is odd or even
			if(countSalon==0){	
				var index = obj.cellIndex;
				var previousImage=new Image();
				var nextImage=new Image();
				if(index%2==0){
					 previousImage.src = obj.childNodes[0].getAttribute("alt");
					 nextImage.src = parentTr.cells[index+1].childNodes[0].getAttribute("alt");
					 
					 modelCurrentIndex=index;
				}else{
					 
					 nextImage.src = obj.childNodes[0].getAttribute("alt");
					 previousImage.src = parentTr.cells[index-1].childNodes[0].getAttribute("alt");
					 
					 modelCurrentIndex=index-1;
				}
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
						parentDiv.innerHTML="";
						parentDiv.appendChild(rightModelPhotosLeftDiv);
						parentDiv.appendChild(rightModelPhotosCenterDiv);
						parentDiv.appendChild(rightModelPhotosRightDiv);
						$("rightModelPhotosLeftDiv").innerHTML="<img src='"+previousImage.src+"' border='0' width='320px' height='432px' border='0' />";
						$("rightModelPhotosRightDiv").innerHTML="<img src='"+nextImage.src+"' border='0' width='320px' height='432px' border='0' />";
						$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}else{
				var index = obj.cellIndex;
				var previousImage=new Image();
				var nextImage=new Image();
				if((index-countSalon)%2==0){
					 previousImage.src = obj.childNodes[0].getAttribute("alt");
					 nextImage.src = parentTr.cells[index+1].childNodes[0].getAttribute("alt");
					 
					 modelCurrentIndex=index;
					 
				}else{
					 nextImage.src = obj.childNodes[0].getAttribute("alt");
					 previousImage.src = parentTr.cells[index-1].childNodes[0].getAttribute("alt");
					 
					 modelCurrentIndex=index-1;
					 
				}
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
						parentDiv.innerHTML="";
						parentDiv.appendChild(rightModelPhotosLeftDiv);
						parentDiv.appendChild(rightModelPhotosCenterDiv);
						parentDiv.appendChild(rightModelPhotosRightDiv);
						$("rightModelPhotosLeftDiv").innerHTML="<img src='"+previousImage.src+"' border='0' width='320px' height='432px' border='0' />";
						$("rightModelPhotosRightDiv").innerHTML="<img src='"+nextImage.src+"' border='0' width='320px' height='432px' border='0' />";
						$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}
			
		}
		//$('t').value=modelCurrentIndex;
	}
	function unsetImageOpacity(obj){
		var parentTr = obj.parentNode;
		for(var i=0;i<parentTr.cells.length;i++){
			var curCell = parentTr.cells[i];
			$(curCell).setOpacity(1.0);
		}
	}
	
	function getPreviousModelImage(){
		if(rightModelPhotosLeftDiv==null){
			rightModelPhotosLeftDiv = $("rightModelPhotosLeftDiv");
		}
		if(rightModelPhotosRightDiv==null){
			rightModelPhotosRightDiv = $("rightModelPhotosRightDiv");
		}
		if(rightModelPhotosCenterDiv==null){
			rightModelPhotosCenterDiv = $("rightModelPhotosCenterDiv");	
		}
		var t = $("tableModelPhotos");
		var cells = t.tBodies[0].rows[0].cells;
		if(modelCurrentIndex==0){
			modelCurrentIndex=cells.length-1;
			if(cells[modelCurrentIndex].getAttribute("issalon")==1){
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
					$("rightModelPhotosDiv").innerHTML="";
					var image = new Image();
					image.src = cells[modelCurrentIndex].childNodes[0].getAttribute("alt");
					$("rightModelPhotosDiv").innerHTML="<img src='"+image.src+"' border='0' width='646px' height='432px' />";
					$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}else{
				modelCurrentIndex=cells.length-2;
				var firstImage = new Image();
				var secImage = new Image();
				firstImage.src = cells[modelCurrentIndex].childNodes[0].getAttribute("alt");
				secImage.src = cells[modelCurrentIndex+1].childNodes[0].getAttribute("alt");
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
					$("rightModelPhotosDiv").innerHTML="";
					$("rightModelPhotosDiv").appendChild(rightModelPhotosLeftDiv);
					$("rightModelPhotosDiv").appendChild(rightModelPhotosCenterDiv);
					$("rightModelPhotosDiv").appendChild(rightModelPhotosRightDiv);
					$("rightModelPhotosLeftDiv").innerHTML="<img src='"+firstImage.src+"' border='0' width='320px' height='432px' border='0' />";
					$("rightModelPhotosRightDiv").innerHTML="<img src='"+secImage.src+"' border='0' width='320px' height='432px' border='0' />";
					$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}
		}else{
			modelCurrentIndex=modelCurrentIndex-1;
			if(cells[modelCurrentIndex].getAttribute("issalon")==1){
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
					$("rightModelPhotosDiv").innerHTML="";
					var image = new Image();
					image.src = cells[modelCurrentIndex].childNodes[0].getAttribute("alt");
					$("rightModelPhotosDiv").innerHTML="<img src='"+image.src+"' border='0' width='646px' height='432px' />";
					$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}else{
				//alert(true);
				modelCurrentIndex=modelCurrentIndex-1;
				var firstImage = new Image();
				var secImage = new Image();
				firstImage.src = cells[modelCurrentIndex].childNodes[0].getAttribute("alt");
				secImage.src = cells[modelCurrentIndex+1].childNodes[0].getAttribute("alt");
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
					$("rightModelPhotosDiv").innerHTML="";
					$("rightModelPhotosDiv").appendChild(rightModelPhotosLeftDiv);
					$("rightModelPhotosDiv").appendChild(rightModelPhotosCenterDiv);
					$("rightModelPhotosDiv").appendChild(rightModelPhotosRightDiv);
					$("rightModelPhotosLeftDiv").innerHTML="<img src='"+firstImage.src+"' border='0' width='320px' height='432px' border='0' />";
					$("rightModelPhotosRightDiv").innerHTML="<img src='"+secImage.src+"' border='0' width='320px' height='432px' border='0' />";
					$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}
		}
	}
	
	function getNextModelImage(){
		if(rightModelPhotosLeftDiv==null){
			rightModelPhotosLeftDiv = $("rightModelPhotosLeftDiv");
		}
		if(rightModelPhotosRightDiv==null){
			rightModelPhotosRightDiv = $("rightModelPhotosRightDiv");
		}
		if(rightModelPhotosCenterDiv==null){
			rightModelPhotosCenterDiv = $("rightModelPhotosCenterDiv");	
		}
		var t = $("tableModelPhotos");
		var cells = t.tBodies[0].rows[0].cells;
		
		if( ( cells[modelCurrentIndex].getAttribute("issalon")==1 && modelCurrentIndex==cells.length-1 ) || 
			( cells[modelCurrentIndex].getAttribute("issalon")==0 && modelCurrentIndex+1==cells.length-1) ){
			modelCurrentIndex=0;
			if(cells[modelCurrentIndex].getAttribute("issalon")==1){
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
					$("rightModelPhotosDiv").innerHTML="";
					var image = new Image();
					image.src = cells[modelCurrentIndex].childNodes[0].getAttribute("alt");
					$("rightModelPhotosDiv").innerHTML="<img src='"+image.src+"' border='0' width='646px' height='432px' />";
					$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}else{
				var firstImage = new Image();
				var secImage = new Image();
				firstImage.src = cells[modelCurrentIndex].childNodes[0].getAttribute("alt");
				secImage.src = cells[modelCurrentIndex+1].childNodes[0].getAttribute("alt");
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
					$("rightModelPhotosDiv").innerHTML="";
					$("rightModelPhotosDiv").appendChild(rightModelPhotosLeftDiv);
					$("rightModelPhotosDiv").appendChild(rightModelPhotosCenterDiv);
					$("rightModelPhotosDiv").appendChild(rightModelPhotosRightDiv);
					$("rightModelPhotosLeftDiv").innerHTML="<img src='"+firstImage.src+"' border='0' width='320px' height='432px' border='0' />";
					$("rightModelPhotosRightDiv").innerHTML="<img src='"+secImage.src+"' border='0' width='320px' height='432px' border='0' />";
					$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}
		}else{
			if(cells[modelCurrentIndex].getAttribute("issalon")==1){
				modelCurrentIndex=modelCurrentIndex+1;
			}else{
				modelCurrentIndex=modelCurrentIndex+2;
			}
			if(cells[modelCurrentIndex].getAttribute("issalon")==1){
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
					$("rightModelPhotosDiv").innerHTML="";
					var image = new Image();
					image.src = cells[modelCurrentIndex].childNodes[0].getAttribute("alt");
					$("rightModelPhotosDiv").innerHTML="<img src='"+image.src+"' border='0' width='646px' height='432px' />";
					$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}else{
				var firstImage = new Image();
				var secImage = new Image();
				firstImage.src = cells[modelCurrentIndex].childNodes[0].getAttribute("alt");
				secImage.src = cells[modelCurrentIndex+1].childNodes[0].getAttribute("alt");
				$jquery("#rightModelPhotosDiv").animate({opacity:0.0},300,function(){
					$("rightModelPhotosDiv").innerHTML="";
					$("rightModelPhotosDiv").appendChild(rightModelPhotosLeftDiv);
					$("rightModelPhotosDiv").appendChild(rightModelPhotosCenterDiv);
					$("rightModelPhotosDiv").appendChild(rightModelPhotosRightDiv);
					$("rightModelPhotosLeftDiv").innerHTML="<img src='"+firstImage.src+"' border='0' width='320px' height='432px' border='0' />";
					$("rightModelPhotosRightDiv").innerHTML="<img src='"+secImage.src+"' border='0' width='320px' height='432px' border='0' />";
					$jquery("#rightModelPhotosDiv").animate({opacity:1.0},300,function(){});
				});
			}
		}
	}
	
	
	function getModel(){
		if(!$("divScrollbar")){
			return;
		}
		var parentWidth=$("divModelPhotosWrapper").offsetWidth;
		var childWidth=$("tableModelPhotos").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);
						
						if(parseInt(divScrollChild.style.left)<0){
							$("tableModelPhotos").style.left="0px";
							divScrollChild.style.left=0+"px";
						}else if(parseInt(divScrollChild.style.left)>parentWidth-divScrollChild.offsetWidth){
							divScrollChild.style.left=parentWidth-divScrollChild.offsetWidth+"px";
							$("tableModelPhotos").style.left=$("divModelPhotosWrapper").offsetWidth-$("tableModelPhotos").offsetWidth+20+"px";
						}else{
							$("tableModelPhotos").style.left=-percent+"px";
						}
						return false;
					}
				};
				document.onmouseup=function(){
					isDrag=false;
					isDragging=false;
					document.onmousemove=null;
					document.onmousedown=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;
				document.onmouseup=null;
			};
			
		}else{
			$("divScrollbar").style.display='none';
		}
	
	}//function getModel();
	
	function gotoHome(){
		$(document.body).setOpacity(0.0);
		
		document.body.innerHTML=homeO;
		
		var currentPage = document.getElementById("currentPageModel").value;
		
		$("currentPageModel").value=1;
		$("hasPageModel").value=0;
		
		var params = "&cn="+categoryNameModel;
		if(intown!=null){
			params+="&it=1";
			if($("ilft").value==0){
				//showPassword();
				//return;
			}
		}
		if(booking!=null){
			params+="&b=1";
		}
		if(national!=null){
			params+="&n="+national;
		}
		if(newface!=null){
			params+="&nf=1";
		}
		
		
		
			var optionsModels = {
				method:'get',
				parameters:'p='+currentPage+params,
				onCreate:function(){
					
				},
				onSuccess:function(transport){
					
					var response = transport.responseText.split("~");
					$("ulAllModels").innerHTML=response[1];
					$jquery("#rightPhotosDiv").animate({opacity:0.0},500,function(){
						$("rightPhotosDiv").innerHTML=response[0];
						tooltipShow=true;
						$jquery("#rightPhotosDiv").animate({opacity:1.0},500,function(){
							$(document.body).setOpacity(1.0);
						});
					});
				},
				onFailure:function(){
					tooltipShow=true;
				}
			};
			var ajaxOptions = new Ajax.Request("getMainModels.php",optionsModels);
		
		
	}
	
	
	
	
	function getModel2(){
		if(!$("divScrollbar2")){
			return;
		}
		var parentWidth=$("divModelPhotosWrapper2").offsetWidth;
		var childWidth=$("tableModelPhotos2").offsetWidth;
		var diff = childWidth-parentWidth;
		
		var firstPosLeft=0;
		var pointerPosLeft=0;
		var diffPosLeft=0;
		
		if(childWidth>parentWidth){
			
			var isDrag=false;
			var divScroll = $("divScrollbar2");
			divScroll.style.display='block';
			
			var divScrollChild = $("divScrollbarChild2");
			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);
						
						if(parseInt(divScrollChild.style.left)<0){
							$("tableModelPhotos2").style.left="0px";
							divScrollChild.style.left=0+"px";
						}else if(parseInt(divScrollChild.style.left)>parentWidth-divScrollChild.offsetWidth){
							divScrollChild.style.left=parentWidth-divScrollChild.offsetWidth+"px";
						}else{
							$("tableModelPhotos2").style.left=-percent+"px";
						}
						return false;
					}
				};
				document.onmouseup=function(){
					isDrag=false;
					isDragging=false;
					document.onmousemove=null;
					document.onmousedown=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;
				document.onmouseup=null;
			};
			
		}else{
			$("divScrollbar2").style.display='none';
		}
	
	}//function getModel();
	
	
//-->