var ms_totalImages = 0;
var ms_imgType =[];
var ms_imgInfo =[];
var ms_imgPath =[];
var ms_imgWidth =[];
var ms_imgHeight =[];
var ms_currentImage = 0;
var self = this;
var isIE = jQuery.browser.msie;
	
jQuery(document).ready(function(){

	document.onkeydown = function(e){
	  if (e == null) { // ie
		keycode = event.keyCode;
	  } else { // mozilla
		keycode = e.which;
	  }
	  if(keycode == 27){ // escape, close box
		closeTip();
	  } 
	}
         
});




this.ms_miniZoom = function(){	
	
	
	jQuery(".shopMainImg").click(function(e){
		
		var imgSrc = jQuery(this).attr("src");
		var imgName = jQuery(this).parent().parent().parent().find(".shopBottomTitle").html();
		var pageHeight = getPageSize()[1];										  
		var self = this;

		//set the height of the overlay
		if(!isIE)
			jQuery("div.overlayDark").css("height",pageHeight).fadeIn(300,function(){
							//Create the markup								  
				jQuery("body").append("<div class='miniZoomTip' id='miniZoomTip'  ><div id='miniZoomTipClose' ><a href='javascript:void(0)'>x close</a></div>"+
				"<img class='noie6trans' src='"
				+imgSrc+"'/><div id='miniZoomTitle'>"
				+imgName+"</div>"
				+"</div>");
				
                var imgWidth = jQuery(".miniZoomTip").find("img").width();
                jQuery(".miniZoomTip").css("width",imgWidth);
	
				putCenter("miniZoomTip");
	 
				
				//close button
				jQuery("#miniZoomTipClose").bind("click",function(e){
					
					closeTip();
					return false;
				});
				
				return false;
			
			});
		else{
			jQuery("div.overlayDark").css("height",pageHeight).show();
							//Create the markup								  
				jQuery("body").append("<div class='miniZoomTip' id='miniZoomTip'  ><div id='miniZoomTipClose' ><a href='javascript:void(0)'>x close</a></div>"+
				"<img class='noie6trans' src='"
				+imgSrc+"'/><div id='miniZoomTitle'>"
				+imgName+"</div>"
				+"</div>");
				
	             var imgWidth = jQuery(".miniZoomTip").find("img").width();;
	             jQuery(".miniZoomTip").css("width",imgWidth);
	
				putCenter("miniZoomTip");
	 
				
				//close button
				jQuery("#miniZoomTipClose").bind("click",function(e){
					
					closeTip();
					return false;
				});
				
				return false;
			
			}
			

			
	

			
			
		});

							

    	
};

function closeTip(){
				jQuery("div.overlayDark").hide();
				
				if(isIE)
					jQuery("div.form-row select").show();
				
				jQuery("#miniZoomTip").remove();
}


//taken from here http://codesnippets.joyent.com/user/winton/tag/javascript
function putCenter(item)  {
  item = $(item);
  var xy = item.getDimensions();
  var win = windowDimensions();
  var scrol = scrollOffset();
  item.style.left = (win[0] / 2) + scrol[0] - (xy.width / 2) + "px";
  item.style.top = (win[1] / 2) + scrol[1] - (xy.height / 2) + "px";
}

function fullScreen(item) {
  item = $(item);
  var win = windowDimensions();
  var scrol = scrollOffset();
  item.style.height = scrol[1] + win[1] + "px";
}
function windowDimensions() {
  var x, y;
  if (self.innerHeight) {
    // all except Explorer
    x = self.innerWidth;
    y = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) {
    // Explorer 6 Strict Mode
    x = document.documentElement.clientWidth;
    y = document.documentElement.clientHeight;
  } else if (document.body) {
    // other Explorers
    x = document.body.clientWidth;
    y = document.body.clientHeight;
  }
  if (!x) x = 0;
  if (!y) y = 0;
  arrayWindowSize = new Array(x,y);
  return arrayWindowSize;
}
function scrollOffset() {
  var x, y;
  if (self.pageYOffset) {
    // all except Explorer
    x = self.pageXOffset;
    y = self.pageYOffset;
  } else if (document.documentElement && document.documentElement.scrollTop) {
    // Explorer 6 Strict
    x = document.documentElement.scrollLeft;
    y = document.documentElement.scrollTop;
  } else if (document.body) {
    // all other Explorers
    x = document.body.scrollLeft;
    y = document.body.scrollTop;
  }
  if (!x) x = 0;
  if (!y) y = 0;
  arrayScrollOffset = new Array(x,y);
  return arrayScrollOffset;
}
////END put center



//taken from lightbox.js
function getPageSize(){
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}


