

//Clear Inputs - Usage: onfocus='clearDefault(this)'
function clearDefault(el) {
  			if (el.defaultValue==el.value) el.value = ""
		}

//Advanced Clear Inputs - Return Original Value
(function($){jQuery.fn.clearField=function(b){b=jQuery.extend({blurClass:'clearFieldBlurred',activeClass:'clearFieldActive'},b);jQuery(this).each(function(){var a=jQuery(this);if(a.attr('rel')==undefined){a.attr('rel',a.val()).addClass(b.blurClass)}a.focus(function(){if(a.val()==a.attr('rel')){a.val('').removeClass(b.blurClass).addClass(b.activeClass)}});a.blur(function(){if(a.val()==''){a.val(a.attr('rel')).removeClass(b.activeClass).addClass(b.blurClass)}})});return jQuery}})(jQuery);

// JavaScript Config
function addBookmark() {
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
        window.external.AddFavorite(location.href,document.title);
    }
    else if (navigator.appName=="Netscape") {
        window.sidebar.addPanel(document.title,location.href,"");
    }
}

function sendrecommend() {
    if (Page_ClientValidate("recommend")) {
        $.ajax({
            type: "POST",
            url: "sendrecommend.aspx",
            data: { url: document.location.href, name: $("#ctl00_txtReccomendName").val(), friendname: $("#ctl00_txtReccomendFriendName").val(), email: $("#ctl00_txtReccomendEnail").val() },
            success: function(msg) {
                $('#thankstab').html(msg);
                $('#thankstab').show();
                $('#sendtab').hide();
            }
        });
    }
    return false;
}
function showdialog() {
    $('#recommenddialog').dialog('open');
    $('#thankstab').hide();
    $('#sendtab').show();
     return false;
}
//Tabs
$(document).ready(function() {
    $("#recommenddialog").dialog({ autoOpen: false, modal: true, resizable: false ,width:642,height:220}); 
});

function formatText(index, panel) {
    return index + "";
}
$(function () {
    $('.anythingSlider').anythingSlider({
        easing: "easeInOutExpo",
        autoPlay: true,
        delay: 4000,
        startStopped: false,
        animationTime: 600,
        hashTags: false,
        buildNavigation: true,
        pauseOnHover: true,
        startText: "",
        stopText: "",
        navigationFormatter: formatText
    });
    $("#slide-jump").click(function () {
        $('.anythingSlider').anythingSlider(6);
    });
});
		
// Internet Explorer 6 + 7 Dropdown Navigation Fix
initNav=function(){if(document.all&&document.getElementById){var navRoot=document.getElementById("topmenu");var lis=navRoot.getElementsByTagName("li");for(var i=0;i<lis.length;i++){lis[i].onmouseover=function(){this.className+=" hover";this.getElementsByTagName("a")[0].className+=" hover";hideSelectBoxes(this.getElementsByTagName("ul").item(0));}
lis[i].onmouseout=function(){this.className=this.className.replace(" hover","");this.getElementsByTagName("a")[0].className=this.getElementsByTagName("a")[0].className.replace(" hover","");showSelectBoxes(this.getElementsByTagName("ul").item(0));}}}}
if(document.all&&window.attachEvent)attachEvent("onload",initNav);function hideSelectBoxes(object){if(!object)return;if(!object.sboxes)object.sboxes=[];var ol=getElementX(object);var ot=getElementY(object);var ow=object.offsetWidth;var oh=object.offsetHeight;var sboxes=document.all.tags("select");for(var i=0;i<sboxes.length;i++){var node=sboxes[i].parentNode;while(node!=object&&node.tagName!="BODY")
node=node.parentNode;var skip=(node==object);if(skip)continue;var t=getElementY(sboxes[i]);var l=getElementX(sboxes[i]);var w=sboxes[i].offsetWidth;var h=sboxes[i].offsetHeight;var ver=false;if(t>ot&&t<(ot+oh))ver=true;else if((t+h)>ot&&(t+h)<(ot+oh))ver=true;var hor=false;if(l>ol&&l<(ol+ow))hor=true;else if((l+w)>ol&&(l+w)<(ol+ow))hor=true;else if(l<ol&&(l+w)>ol)hor=true;if(ver&&hor&&sboxes[i].style.visibility!="hidden")object.sboxes[object.sboxes.length]=sboxes[i];}
for(var i=0;i<object.sboxes.length;i++)
object.sboxes[i].style.visibility="hidden";}
function showSelectBoxes(object){if(!object)return;if(!object.sboxes)return;for(var i=0;i<object.sboxes.length;i++)
object.sboxes[i].style.visibility="";object.sboxes=[];}
function getElementX(object){return getElementC(object,true)}
function getElementY(object){return getElementC(object,false)}
function getElementC(element,xAxis){var initialElement=element;var c=0;while(element!=null){c+=(xAxis)?element.offsetLeft:element.offsetTop;if(element.style.position=="absolute")break;else element=element.offsetParent;}
var elementWnd=document.window;if(!elementWnd)return c;if(!elementWnd.frameElement)return c;return c+getElementC(elementWnd.frameElement,xAxis);}

// Scroll to Anchor
jQuery(document).ready(function()  {
    jQuery('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
            var $target = jQuery(this.hash);
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({scrollTop: targetOffset}, 700);
                return false;
            }
        }
    });
 });

//Tabs
$(document).ready(function() {
	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
 
});

jQuery.fn.equalCols = function(){
	//Array Sorter
	var sortNumber = function(a,b){return b - a;};
	var heights = [];
	//Push each height into an array
	$(this).each(function(){
		heights.push($(this).height());
	});
	heights.sort(sortNumber);
	var maxHeight = heights[0];
	return this.each(function(){
		//Set each column to the max height
		$(this).css({'height': maxHeight});
	});
};
//Usage
jQuery(function($){
	//Select the columns that need to be equal e.g
	$('div.boxes').equalCols();
	$('.box,.box,.box').equalCols();
});

//Homepage PopUp
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

//Easy Slider
(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {			
			prevId: 		'prevBtn',
			prevText: 		'Previous',
			nextId: 		'nextBtn',	
			nextText: 		'Next',
			controlsShow:	true,
			controlsBefore:	'',
			controlsAfter:	'',	
			controlsFade:	true,
			firstId: 		'firstBtn',
			firstText: 		'First',
			firstShow:		false,
			lastId: 		'lastBtn',	
			lastText: 		'Last',
			lastShow:		false,				
			vertical:		false,
			speed: 			800,
			auto:			false,
			pause:			2000,
			continuous:		false
		}; 
		
		var options = $.extend(defaults, options);  
				
		this.each(function() {  
			var obj = $(this); 				
			var s = $("li", obj).length;
			var w = $("li", obj).width(); 
			var h = $("li", obj).height(); 
			obj.width(w); 
			obj.height(h); 
			obj.css("overflow","hidden");
			var ts = s-1;
			var t = 0;
			$("ul", obj).css('width',s*w);			
			if(!options.vertical) $("li", obj).css('float','left');
			
			if(options.controlsShow){
				var html = options.controlsBefore;
				if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>';
				html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';
				html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>';
				if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>';
				html += options.controlsAfter;						
				$(obj).after(html);										
			};
	
			$("a","#"+options.nextId).click(function(){		
				animate("next",true);
			});
			$("a","#"+options.prevId).click(function(){		
				animate("prev",true);				
			});	
			$("a","#"+options.firstId).click(function(){		
				animate("first",true);
			});				
			$("a","#"+options.lastId).click(function(){		
				animate("last",true);				
			});		
			
			function animate(dir,clicked){
				var ot = t;				
				switch(dir){
					case "next":
						t = (ot>=ts) ? (options.continuous ? 0 : ts) : t+1;						
						break; 
					case "prev":
						t = (t<=0) ? (options.continuous ? ts : 0) : t-1;
						break; 
					case "first":
						t = 0;
						break; 
					case "last":
						t = ts;
						break; 
					default:
						break; 
				};	
				
				var diff = Math.abs(ot-t);
				var speed = diff*options.speed;						
				if(!options.vertical) {
					p = (t*w*-1);
					$("ul",obj).animate(
						{ marginLeft: p }, 
						speed
					);				
				} else {
					p = (t*h*-1);
					$("ul",obj).animate(
						{ marginTop: p }, 
						speed
					);					
				};
				
				if(!options.continuous && options.controlsFade){					
					if(t==ts){
						$("a","#"+options.nextId).hide();
						$("a","#"+options.lastId).hide();
					} else {
						$("a","#"+options.nextId).show();
						$("a","#"+options.lastId).show();					
					};
					if(t==0){
						$("a","#"+options.prevId).hide();
						$("a","#"+options.firstId).hide();
					} else {
						$("a","#"+options.prevId).show();
						$("a","#"+options.firstId).show();
					};					
				};				
				
				if(clicked) clearTimeout(timeout);
				if(options.auto && dir=="next" && !clicked){;
					timeout = setTimeout(function(){
						animate("next",false);
					},diff*options.speed+options.pause);
				};
				
			};
			// init
			var timeout;
			if(options.auto){;
				timeout = setTimeout(function(){
					animate("next",false);
				},options.pause);
			};		
		
			if(!options.continuous && options.controlsFade){					
				$("a","#"+options.prevId).hide();
				$("a","#"+options.firstId).hide();				
			};				
			
		});
	  
	};

})(jQuery);

$(document).ready(function(){	
	$("#testimonialbox").easySlider({
		vertical: true,
		auto: true,
		pause: 4000,
		controlsFade: false,
		continuous:true
	});
});

jQuery(document).ready(function () {
    var needrestart = false;
    $("ul#prod_results").each(function (inx, el) {
        var h = 0;
        var sh = 0;
        var rowh = [];
        var rowsh = [];

        $(el).find("li > a").each(function (inx, l_el) {

            if (!rowh[(inx - (inx % 5)) / 5]) rowh[(inx - (inx % 5)) / 5] = 0;
            if ($(l_el).find("img").get(0).complete) {
                if ($(l_el).find("img").height() + $(l_el).find("span").eq(0).height() + $(l_el).find("span").eq(1).height() > rowh[(inx - (inx % 5)) / 5]) {
                    rowh[(inx - (inx % 5)) / 5] = $(l_el).find("img").height() + $(l_el).find("span").eq(0).height() + $(l_el).find("span").eq(1).height();
                    rowsh[(inx - (inx % 5)) / 5] = $(l_el).find("img").height();
                }
            }
            else {
                needrestart = true;
            }
        });

        $(el).find("li").each(function (inx, l_el) {

            if (rowh[(inx - (inx % 5)) / 5] != 0) {
                $(l_el).height(rowh[(inx - (inx % 5)) / 5] + 20);
                $(l_el).find("a > span").eq(0).css('top', rowsh[(inx - (inx % 5)) / 5]);
            }


        });



    });
    if (needrestart) {
        setTimeout(arguments.callee, 2000);
    }
});


jQuery(document).ready(function() {
    var needrestart = false;
    $("ul#prod_results_home").each(function(inx, el) {
        var h = 0;
        var sh = 0;
        var rowh = [];
        var rowsh = [];

        $(el).find("li > a").each(function(inx, l_el) {

            if (!rowh[(inx - (inx % 5)) / 5]) rowh[(inx - (inx % 5)) / 5] = 0;
            if ($(l_el).find("img").get(0).complete) {
                if ($(l_el).find("img").height() + $(l_el).find("span").eq(0).height() + $(l_el).find("span").eq(1).height() > rowh[(inx - (inx % 5)) / 5]) {
                    rowh[(inx - (inx % 5)) / 5] = $(l_el).find("img").height() + $(l_el).find("span").eq(0).height() + $(l_el).find("span").eq(1).height();
                    rowsh[(inx - (inx % 5)) / 5] = $(l_el).find("span").eq(0).height();
                }
            }
            else {
                needrestart = true;
            }
        });

        $(el).find("li").each(function(inx, l_el) {

            if (rowh[(inx - (inx % 5)) / 5] != 0) {
                $(l_el).height(rowh[(inx - (inx % 5)) / 5] + 20);
                $(l_el).find("a > img").eq(0).css('top', rowsh[(inx - (inx % 5)) / 5]+5);
            }


        });



    });
    if (needrestart) {
        setTimeout(arguments.callee, 2000);
    }
});



jQuery(document).ready(function () {
    var needrestart = false;
    $("ul.related_products").each(function (inx, el) {
        var h = 0;
        var sh = 0;
        var rowh = [];
        var rowsh = [];

        $(el).find("li > a").each(function (inx, l_el) {

            if (!rowh[(inx - (inx % 6)) / 6]) rowh[(inx - (inx % 6)) / 6] = 0;
            if ($(l_el).find("img").get(0).complete) {
                if ($(l_el).find("img").height() + $(l_el).find("span").eq(0).height()  > rowh[(inx - (inx % 5)) / 5]) {
                    rowh[(inx - (inx % 5)) / 5] = $(l_el).find("img").height() + $(l_el).find("span").eq(0).height();
                    rowsh[(inx - (inx % 5)) / 5] = $(l_el).find("img").height();
                }
            }
            else {
                needrestart = true;
            }
        });

        $(el).find("li").each(function (inx, l_el) {

            if (rowh[(inx - (inx % 6)) / 6] != 0) {
                $(l_el).height(rowh[(inx - (inx % 6)) / 6] + 15);
                $(l_el).find("a > span").eq(0).css('top', rowsh[(inx - (inx % 6)) / 6]);
            }


        });



    });
    if (needrestart) {
        setTimeout(arguments.callee, 2000);
    }
});
