// JavaScript Document
var a = jQuery.noConflict();
a(function(){
		a.fn.supersized.options = {  
			startwidth: 1024,  
			startheight: 768,
			minsize: .50,
			slideshow: 0,
			slideinterval:10000
		};
        a('#supersize').supersized(); 
    });

jQuery(document).ready(function(){
    jQuery('#slideshow').cycle({
        fx:     'fade',
        speed:  'fast',
        timeout: 10000,
        pager:  '#slider_nav',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#slider_nav li:eq(' + (idx) + ') a';
        }
    });

    //-- Menu hover
    jQuery("li.oneCol").hover(function(){jQuery(this).children('div').hide();jQuery(this).children('div').fadeIn('slow');});
    jQuery("li.twoCol").hover(function(){jQuery(this).children('div').hide();jQuery(this).children('div').fadeIn('slow');});
    jQuery("li.threeCol").hover(function(){jQuery(this).children('div').hide();jQuery(this).children('div').fadeIn('slow');});
    jQuery("li.fourCol").hover(function(){jQuery(this).children('div').hide();jQuery(this).children('div').fadeIn('slow');});

});


jQuery(document).ready(function() {

jQuery("#navLeft ul").hide();
jQuery("#navLeft li:has(ul)").each(function() {
jQuery(this).children().slideUp(400);
});

jQuery("li.p1:has(ul)").click(function(event){
if (this == event.target) {
var current = this;
jQuery("#navLeft li:has(ul)").each(function() {
if (this != current) jQuery(this).children().slideUp(400);
});
jQuery("ul:first", jQuery(this)).slideToggle(400);
}
});

jQuery("li.p2:has(ul)").click(function(event){
if (this == event.target) {
var current = this;
jQuery("li.p2:has(ul)").each(function() {
if (this != current) jQuery(this).children().slideUp(400);
});
jQuery("li.p3:has(ul)").each(function() {
if (this != current) jQuery(this).children().slideUp(400);
});
jQuery("ul:first", jQuery(this)).slideToggle(400);
}
});

jQuery("li.p3:has(ul)").click(function(event){
if (this == event.target) {
var current = this;
jQuery("li.p3:has(ul)").each(function() {
if (this != current) jQuery(this).children().slideUp(400);
});
jQuery("ul:first", jQuery(this)).slideToggle(400);
}
});

});




jQuery(document).ready(function(){
        //  Initialize Backgound Stretcher
        /*
		jQuery(document).bgStretcher({
			images: ['../../skin/frontend/default/default/images/hussy/bg01.jpg'],
			imageWidth: 1024, imageHeight: 768
		});
		*/
		jQuery('#toggleAnimation').click(function(){
	       if(jQuery(this).val() == "Pause Animation"){
	           jQuery(this).val("Resume Animation");
	           jQuery(document).bgStretcher.pause();
	       } else {
	           jQuery(this).val("Pause Animation");
	           jQuery(document).bgStretcher.play();
	       }
		});
	});


<!--news ticker js-->

	jQuery(document).ready(function(){	
		jQuery("#newsticker").easySlider({
			prevText:'<img src="./skin/frontend/default/default/images/hussy/arrow_btm.png"  />',
			nextText:'<img src="./skin/frontend/default/default/images/hussy/arrow_btn.png"  />',
			orientation:'vertical'
			
		});
	});



/*
Supersized - Full Screen Background/Slideshow jQuery Plugin
supersized.1.0.js
February 2009
By Sam Dunn
www.buildinternet.com / www.onemightyroar.com
*/
(function(jQuery){

	//Resize image on ready or resize
	jQuery.fn.supersized = function() {
	
		var options = jQuery.extend(jQuery.fn.supersized.defaults, jQuery.fn.supersized.options);
		
		if (options.slideshow == 1){
			setInterval("theslideshow()", options.slideinterval);
		}
		
		jQuery().ready(function() {
			jQuery('#supersize').resizenow(); 
		});
		jQuery(window).bind("resize", function(){
    		jQuery('#supersize').resizenow(); 
		});
	};
	
	//Adjust image size
	jQuery.fn.resizenow = function() {
		
		var options = jQuery.extend(jQuery.fn.supersized.defaults, jQuery.fn.supersized.options);
		
	  	return this.each(function() {
	  		
			//Define image ratio & minimum dimensions
			var minwidth = options.minsize*(options.startwidth);
			var minheight = options.minsize*(options.startheight);
			var ratio = options.startheight/options.startwidth;
			
			//Gather browser and current image size
			var imagewidth = jQuery(this).width();
			var imageheight = jQuery(this).height();
			var browserwidth = jQuery(window).width();
			var browserheight = jQuery(window).height();
			
			//Check for minimum dimensions
			if ((browserheight < minheight) && (browserwidth < minwidth)){
				jQuery(this).height(minheight);
				jQuery(this).width(minwidth);
			}
			else{	
				//When browser is taller	
				if (browserheight > browserwidth){
				    imageheight = browserheight;
				    jQuery(this).height(browserheight);
				    imagewidth = browserheight/ratio;
				    jQuery(this).width(imagewidth);
				    
				    if (browserwidth > imagewidth){
				    	imagewidth = browserwidth;
				    	jQuery(this).width(browserwidth);
				    	imageheight = browserwidth * ratio;
				    	jQuery(this).height(imageheight);
				    }
				
				}
				
				//When browser is wider
				if (browserwidth >= browserheight){
				    imagewidth = browserwidth;
				    jQuery(this).width(browserwidth);
				    imageheight = browserwidth * ratio;
				    jQuery(this).height(imageheight);
				    
				    if (browserheight > imageheight){
				    	imageheight = browserheight;
				    	jQuery(this).height(browserheight);
				    	imagewidth = browserheight/ratio;
				    	jQuery(this).width(imagewidth);
				    }
				}
			}
			return false;
		});
	};
	
	jQuery.fn.supersized.defaults = { 
			startwidth: 640,  
			startheight: 480,
			minsize: .5,
			slideshow: 0,
			slideinterval: 5000  
	};jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel();
	});
	
})(jQuery);


function pimgtoggle(source, imgsrc1, imgsrc2)
{
    if(source.src == imgsrc1)
    {
        source.src = imgsrc2;
        return;
    }
}

/******************************************************
	* jQuery plug-in
	* Easy Background Image Resizer
	* Developed by J.P. Given (http://johnpatrickgiven.com)
	* Useage: anyone so long as credit is left alone
******************************************************/

var containerObj;
var center = 0;


(function(a) {
	// plugin definition
	a.fn.ezBgResize = function(cntr) {

		if (cntr) {
			center = 1;
		}

		// First position object
		containerObj = this;

		containerObj.css("visibility","hidden");

		a("body").css({
			"overflow-x":"hidden"
		});

		a(window).load(function() {
			resizeImage();
		});

		a(window).bind("resize",function() {
			resizeImage();
		});

	};

	function resizeImage() {

		a("body").css({
			"overflow-x":"auto"
		});

		containerObj.css({
			"position":"fixed",
			"top":"0px",
			"left":"0px",
			"z-index":"-1",
			"overflow":"hidden",
			"width":getWindowWidth() + "px",
			"height":getWindowHeight() + "px"
		});

		// Resize the img object to the proper ratio of the window.
		var iw = containerObj.children('img').width();
		var ih = containerObj.children('img').height();
		if (a(window).width() > a(window).height()) {
			if (iw > ih) {
				var fRatio = iw/ih;
				containerObj.children('img').css("width",a(window).width() + "px");
				containerObj.children('img').css("height",Math.round(a(window).width() * (1/fRatio)));

				var newIh = Math.round(a(window).width() * (1/fRatio));

				if(newIh < a(window).height()) {
					var fRatio = ih/iw;
					containerObj.children('img').css("height",a(window).height());
					containerObj.children('img').css("width",Math.round(a(window).height() * (1/fRatio)));
				}
			} else {
				var fRatio = ih/iw;
				containerObj.children('img').css("height",a(window).height());
				containerObj.children('img').css("width",Math.round(a(window).height() * (1/fRatio)));
			}
		} else {
			var fRatio = ih/iw;
			containerObj.children('img').css("height",a(window).height());
			containerObj.children('img').css("width",Math.round(a(window).height() * (1/fRatio)));
		}

		containerObj.css("visibility","visible");

		// Center BG Image
		if (center) {

			containerObj.children('img').css("position","relative");

			if (containerObj.children('img').width() > containerObj.width()) {
				var wDiff = (containerObj.children('img').width() - containerObj.width()) / 2;
				containerObj.children('img').css("left", "-" + wDiff + "px");
			}
		}
	}
})(jQuery);

// Dependable function to get Window Height
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
};

// Dependable function to get Window Width
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
};

/*
jQuery(document).ready(function() {
jQuery("#masterWrap").ezBgResize();
});

*/

function togglecollection(first,second,third) {
    
    jQuery(first).hide();
    jQuery(second).hide();
    jQuery(third).show();

    return false;
}
jQuery(document).ready(function() {
jQuery(".MagicToolboxSelectorsContainer").jCarouselLite({
    btnNext: ".nextgalleryimage",
    btnPrev: ".prevgalleryimage",
    visible: 4


    });
   jQuery(".MagicToolboxSelectorsContainer").css({ top: '20px' });



jQuery("#selorder").change(function () {
            var tmplocation = window.location.href.toString();
            if (tmplocation.indexOf("?")==-1) {
                var divider = "?";
            } else {
                var divider = "&";
            }
            
          if(jQuery("#selorder").val()=='price_desc') {
              if (tmplocation.indexOf("order=")==-1) {
                window.location.href = tmplocation + divider + 'order=price&dir=desc';
              } else {
                 
                 tmplocation.replace(/dir=asc/g, "dir=desc");
                 window.location.href = tmplocation;
              }
          }
           if(jQuery("#selorder").val()=='price_asc') {
             if (tmplocation.indexOf("order=")==-1) {
                window.location.href = tmplocation + divider +'order=price&dir=asc';
              } else {
                 tmplocation.replace(/dir=desc/g, "dir=asc");
                 window.location.href = tmplocation;
              }
          }
        })

});
jQuery.noConflict();
