// JavaScript Document
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
$(document).ready(function(){
	/* menu */
	$.preloadImages(
		'http://www.zenbisalon.com/images/comn/home-on.png',
		'http://www.zenbisalon.com/images/comn/services-on.png',
		'http://www.zenbisalon.com/images/comn/about-us-on.png',
		'http://www.zenbisalon.com/images/comn/special-feature-on.png',
		'http://www.zenbisalon.com/images/comn/contact-us-on.png'
	);
	$('img#m-home').hover(function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/home-on.png");},function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/home.png");});
	$('img#m-services').hover(function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/services-on.png");},function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/services.png");});
	$('img#m-about-us').hover(function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/about-us-on.png");},function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/about-us.png");});
	$('img#m-special-feature').hover(function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/special-feature-on.png");},function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/special-feature.png");});
	$('img#m-contact-us').hover(function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/contact-us-on.png");},function(){$(this).attr("src","http://www.zenbisalon.com/images/comn/contact-us.png");});
	
	/* service display scroll */
	$('#services2').css("display", "block");
	
	/* services - products display scroll */
	$('#recommended-businesses').css("display", "block");
	
	/* servics - bridal & wedding arrangements testimonals */
	$('#testimonial').css("display", "block");
	
	/* about us scroll */
	$('#c-about-us').css("display", "block");
});

jQuery.fn.overlay = function() {
	return (this.each(
		function() {
			var xScroll, yScroll, windowWidth, windowHeight, pageHeight, pageWidth;
			
			if (document.body.offsetHeight) {
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			} 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.scrollWidth;
				yScroll = window.innerHeight + window.scrollMaxY;
			}
			
			if (self.innerHeight) {	// all except Explorer
				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 = windowWidth;
			} else {
				pageWidth = xScroll;
			}
			
			jQuery(this).css({width: pageWidth + 'px', height: pageHeight + 'px'});
		}
	))
};

jQuery.fn.staffbox = function() {
	return (this.each(
		function() {
			var x, y, w, h, ww, hh, padx, pady, borx, bory;
			
			//browser size
			ww = document.documentElement.clientWidth || document.body.clientWidth;
			hh = document.documentElement.clientHeight || document.body.clientHeight;
			
			if (jQuery.browser.opera) hh = document.body.clientHeight;
			
			//div size
			w = jQuery(this).width();
			h = jQuery(this).height();
			
			//div padding
			padx = jQuery(this).css('padding-left');
			padx = parseInt(padx.substring(0, padx.length - 2));
			pady = jQuery(this).css('padding-top');
			pady = parseInt(pady.substring(0, pady.length - 2));
			
			//div border
			borx = jQuery(this).css('border-left-width');
			borx = parseInt(borx.substring(0, borx.length - 2));
			if(!borx) borx = 0;
			bory = jQuery(this).css('border-top-width');
			bory = parseInt(bory.substring(0, bory.length - 2));
			if(!bory) bory = 0;
			
			x = Math.round((ww - w - 2*padx - 2*borx)/2);
			y = Math.round((hh - h - 2*pady - 2*bory)/2);
			
			//Handle MSIE fix position 
			if(jQuery.browser.msie && jQuery.browser.version == '6.0') {
				var expression = "( " + y + " + ( ignoreMe = "
							   + "document.documentElement.scrollTop ? "
							   + "document.documentElement.scrollTop : "
							   + "document.body.scrollTop ) ) + 'px'";
							 
				jQuery(this).get(0).style.setExpression("top", expression);
			
				jQuery(this).css({position: 'absolute', left: x + 'px'});
			}
			else{
				jQuery(this).css({position: 'fixed', top: y + 'px', left: x + 'px'});
			}
		}
	));
};

jQuery.fn.showbox = function() {
	return (this.each(
		function() {
			var x, y, w, h, ww, hh, padx, pady, borx, bory;
			
			//browser size
			ww = document.documentElement.clientWidth || document.body.clientWidth;
			hh = document.documentElement.clientHeight || document.body.clientHeight;
			
			if (jQuery.browser.opera) hh = document.body.clientHeight;
			
			//div size
			w = jQuery(this).width();
			h = jQuery(this).height();
			
			//div padding
			padx = jQuery(this).css('padding-left');
			padx = parseInt(padx.substring(0, padx.length - 2));
			pady = jQuery(this).css('padding-top');
			pady = parseInt(pady.substring(0, pady.length - 2));
			
			//div border
			borx = jQuery(this).css('border-left-width');
			borx = parseInt(borx.substring(0, borx.length - 2));
			if(!borx) borx = 0;
			bory = jQuery(this).css('border-top-width');
			bory = parseInt(bory.substring(0, bory.length - 2));
			if(!bory) bory = 0;
			
			x = Math.round((ww - w - 2*padx - 2*borx)/2);
			y = Math.round((hh - h - 2*pady - 2*bory)/2);
			
			//Handle MSIE fix position 
			if(jQuery.browser.msie && jQuery.browser.version == '6.0') {
				var expression = "( " + y + " + ( ignoreMe = "
							   + "document.documentElement.scrollTop ? "
							   + "document.documentElement.scrollTop : "
							   + "document.body.scrollTop ) ) + 'px'";
							 
				jQuery(this).get(0).style.setExpression("top", expression);
			
				jQuery(this).css({position: 'absolute', left: x + 'px'});
			}
			else{
				jQuery(this).css({position: 'fixed', top: y + 'px', left: x + 'px'});
			}
		}
	));
};