function initPage(){
	$(".pageBottomMainCat a").hover(
		function (){
			containerOfEle = $(this).closest(".pageBottomMainCat");
			indexOfMain = $(".pageBottomMainCat").index(containerOfEle);
			if($(".pageBottomSubCategoryItemCont").length<indexOfMain)
				return
			$(".pageBottomSubCategoryItemCont").eq(indexOfMain).css("display","block");
		},
		function (){
			
		}
	);
	$(".pageBottomMainCat").hover(
		function (){
			
		},
		function (){
			indexOfMain = $(".pageBottomMainCat").index(this);
			if($(".pageBottomSubCategoryItemCont").length<indexOfMain)
				return
			$(".pageBottomSubCategoryItemCont").eq(indexOfMain).css("display","none");
		}
	);
	$.fx.prototype.cur = function(){
	    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
	      return this.elem[ this.prop ];
	    }
	    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
	    return typeof r == 'undefined' ? 0 : r;
	}
	if($(".galleryAuto").length>0){
		galleryAuto = setTimeout("moveGallery('left','true')",5000);
	}
	$("a[class=galleryItemHref]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			html = "";
			if(currentIndex>0 && currentArray.length>1)
				html = html + '<span id="fancybox-left-ico" class="fancy-ico fancy-icoLeft" onClick="moveLeft();"></span>';
			if((currentIndex+1)<currentArray.length)
				html = html + '<span id="fancybox-right-ico" class="fancy-ico fancy-icoRight" onClick="moveRight();"></span>';
			html = html + '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
			return html;
		}
	});
}
function moveGallery(action,setInterval){
	if(canMove==false)
		return;
	clearTimeout(galleryAuto);
	canMove = false;
	imageRow = currentImage;
	switch(action){
		case "right":
			newXCoord = imageWidth;
			imageRow--;
			break;
		case "left":
			newXCoord = -imageWidth;
			imageRow++;
			break;
		default:
			return;
	}
	if(imageRow==maxImages)
		$(".galleryArrowsLeft").css("display","none");
	else
		$(".galleryArrowsLeft").css("display","block");
	if(imageRow==1)
		$(".galleryArrowsRight").css("display","none");
	else
		$(".galleryArrowsRight").css("display","block");
	if(imageRow>maxImages || imageRow<1){
		if(setInterval=="true"){
			$(".galleryInnerWidth").css("right",0);
			galleryAuto = setTimeout("moveGallery('left','true')",5000);
			canMove = true;
			currentImage = 1;
			return;
		}
		canMove = true;
		return;
	}
	currentright = parseInt($(".galleryInnerWidth").css('right'));
	nextRight = parseInt(currentright)+parseInt(newXCoord);
	$(".galleryInnerWidth").animate({
		right: nextRight+'px'
	}, 300, function() {
    	canMove = true;
		currentImage = imageRow;
		if(setInterval=="true"){
			galleryAuto = setTimeout("moveGallery('left','true')",5000);
		}
  });
}
function moveGalleryLtr(action){
	if(canMove==false)
		return;
	canMove = false;
	imageRow = currentImage;
	switch(action){
		case "left":
			newXCoord = imageWidth;
			imageRow--;
			break;
		case "right":
			newXCoord = -imageWidth;
			imageRow++;
			break;
		default:
			return;
	}
	if(imageRow==maxImages)
		$(".galleryArrowsRight").css("display","none");
	else
		$(".galleryArrowsRight").css("display","block");
	if(imageRow==1)
		$(".galleryArrowsLeft").css("display","none");
	else
		$(".galleryArrowsLeft").css("display","block");
	if(imageRow>maxImages || imageRow<1){
		canMove = true;
		return;
	}
	currentright = parseInt($(".galleryInnerWidth").css('left'));
	nextRight = parseInt(currentright)+parseInt(newXCoord);
	$(".galleryInnerWidth").animate({
		left: nextRight+'px'
	}, 300, function() {
    	canMove = true;
		currentImage = imageRow;
  });
}

function moveRight(){
	$.fancybox.next();
}
function moveLeft(){
	$.fancybox.prev();
}
