jQuery.noConflict();

/* on homepage mod_EurekaBanner */

//commented out: to fix issue # 12 eureka-notes sheet
/* 
function createSearch(){
	var desc = document.getElementById("txtSearchProduct").value;
	var model = document.getElementById("txtSearchModel").value;		
	document.getElementById("searchModelGo").href = "index.php?option=com_pnasearch&description="+ desc +"&model="+model;
	document.getElementById("searchProductGo").href = "index.php?option=com_pnasearch&description="+ desc +"&model="+model;
}

*/

function createSearch(){
 var desc = document.getElementById("txtSearchProduct").value;
 if(desc == "Enter Product Description"){
  desc = "";
 }
 
 var model = document.getElementById("txtSearchModel").value;
 if(model == "Enter Model Number"){
  model = "";
 }
 
 var type = document.getElementById("txtSearchItem").value;
 if(type == "Enter Vacuum Type"){
  type = "";
 }
 
 //document.getElementById("searchModelGo").href = "index.php?option=com_pnasearch&description="+ desc +"&model="+model;
 document.getElementById("searchModelGo").href = "index.php?option=com_pnasearch&description="+ desc +"&model="+model+"&type="+type;
 
 //document.getElementById("searchProductGo").href = "index.php?option=com_pnasearch&description="+ desc +"&model="+model;
 document.getElementById("searchProductGo").href = "index.php?option=com_pnasearch&description="+ desc +"&model="+model+"&type="+type;
 
 //document.getElementById("searchItemGo").href = "index.php?option=com_pnasearch&description="+ desc +"&model="+model;
 document.getElementById("searchItemGo").href = "index.php?option=com_pnasearch&description="+ desc +"&model="+model+"&type="+type;
}



function registerNewsLetter(){
	document.getElementById("newsLetterGoBtn").href = "index.php?option=com_ccnewsletter&task=addSubscriber&email=" + document.getElementById("newsLetterEmail").value ;
}


	
/* Clear Default Form Value */
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 




jQuery(document).ready(function() {
	/* main search error checking */
	jQuery("#pp_search").submit(function() {
		if (jQuery("#ps_search_str").val() == 'Enter search term(s)' || jQuery("#ps_search_str").val() == '') {
			jQuery(".pixsearch_err").css( { visibility: 'visible' });
			jQuery(".pixsearch_err").hide();
			jQuery(".pixsearch_err").slideDown();
			//setTimeout("jQuery('.pixsearch_err').slideUp();", 2500); 
			return false;
		}
	});
	
	jQuery("#searchgo").blur(function() {
		jQuery(".pixsearch_err").slideUp();
			//alert(jQuery("#pixsearch_err").val());
	});
	
	jQuery("#ps_search_str").focus(function() {
		if (jQuery(this).val() == 'Enter search term(s)') {
			jQuery(this).val('');
			jQuery(this).addClass('searchActive');
		}
		jQuery(".pixsearch_err").slideUp();
	});
	
	jQuery("#ps_search_str").blur(function() {
		if (jQuery(this).val() == '') {
			jQuery(this).val('Enter search term(s)');
			jQuery(this).removeClass('searchActive');
		}
	});
								
								
								
	/**
	*** reset 'all vaccums' menu height according to content.
	*** -- offset adjusted for IE problems
	**/
	
	var vacuums = new Array(jQuery("#topnav .upright ul"), jQuery("#topnav .lightweight ul"), jQuery("#topnav .canister ul"));
	
	//find the max height of the menus
	var maxObj = vacuums[0];
	jQuery(vacuums).each(function() {
		if (maxObj && jQuery(maxObj).height() < jQuery(this).height())
			maxObj = jQuery(this);
	});
	
	
	//compute new height for each menu
	maxObjHeight = jQuery(maxObj).height();
	//if(typeof jQuery("#topnav .upright .title").offset() == 'undefined')	//throws an error if obj not on page. check
	//	top = 0;
	//else
	
	//alert("max obj height: " + maxObjHeight);
	
	var titleHeight = jQuery("#topnav .upright .title").height();
	var titleTop = 85;
	
	//alert("title height: " + titleHeight + "\ntitle top: " + titleTop);

		
	//maxObjHeight = maxObjHeight+titleHeight+titleTop - 19;
	maxObjHeight = maxObjHeight + titleHeight + titleTop;
	//alert("new max ojb height: " + maxObjHeight);

	//if the height is less than size of silhouette, make it size of silhouette
	if (maxObjHeight> jQuery("#topnav .upright .image").height()) {
		//alert("make size of silh");
		//alert(h);
			
		jQuery("#topnav .upright").height(maxObjHeight);
		jQuery("#topnav .lightweight").height(maxObjHeight);
		jQuery("#topnav .canister").height(maxObjHeight);
	} else {
		//alert("new size: " + jQuery("#topnav .upright .image").height()+80);
		
		jQuery("#topnav .upright").height(jQuery("#topnav .upright .image").height()+80);
		jQuery("#topnav .lightweight").height(jQuery("#topnav .upright .image").height()+80);
		jQuery("#topnav .canister").height(jQuery("#topnav .upright .image").height()+80);
	}
	




	/* set the bounding boxes height/width (cannot style in IE) */
	


	var browser = navigator.appVersion.split(" ")[2];
	var vers = navigator.appVersion.split(" ")[3];
	
	
	jQuery("div.wrapper").each(function() {
		//jQuery(this).width(jQuery(this).width() - 12);
	
		jQuery(this).children("div.colleft").height(parseInt(jQuery(this).height()) - 44);
		jQuery(this).children("div.colright").height(parseInt(jQuery(this).height()) - 44);

		//alert(jQuery(this).height());
		jQuery(this).children("div.background").height(parseInt(jQuery(this).height()));
		jQuery(this).children("div.background").width(parseInt(jQuery(this).width()));
		
		
		//alert(jQuery(this).width());
		
		jQuery(this).children("div.bottom").width(parseInt(jQuery(this).width()) - 56);
		jQuery(this).children("div.top").width(parseInt(jQuery(this).width()) -56);
		//alert(jQuery(this).width());
		

	});
	
	/*alert(jQuery(".allvacuums div.bottom").width());*/



		
	if (browser == "MSIE" && vers == "6.0;") {
		//jQuery("div.lifestyle").css({ 'margin-left': "-30px" });
	
		jQuery("div.allvacuums").css({ 'margin-left': "-5px" });
		
		jQuery("div.allvacuums div.bottom").width(parseInt(jQuery("div.allvacuums div.bottom").width() -1));
		jQuery("div.lifestyle div.bottom").width(parseInt(jQuery("div.lifestyle div.bottom").width() -1));
		//jQuery("div.lifestyle div.topright").css({ right: "-25px" } );
		jQuery("div.allvacuums div.topright").css({ right: "-25px" } );
		//jQuery("div.allvacuums div.top").css({ top: "-12px" } );
		
		//jQuery("div.allvacuums div.topright").css( { right: '-12px' } );
		//jQuery("div.allvacuums div.bottomright").css( { right: '-12px' } );
		

	}



	// emulate li:hover for non supported browsers (ie6)
	// make the entire element clickable to link defined
	
	jQuery(".level1").hover(function() {
		jQuery(this).children(".level1_div").css( {visibility: "visible"} );
		jQuery(this).children("a").addClass("link_hover");
	
		jQuery(".lifestyle .content li").hover(function() {
			jQuery(this).addClass("rollmenu_hover");
		}, function() {
			jQuery(this).removeClass("rollmenu_hover");
		});
	}, function() {
		jQuery(this).children(".level1_div").css( {visibility: "hidden"} );
		jQuery(this).children("a").removeClass("link_hover");
		//alert("remove");
	});
	
	
	jQuery(".rollmenu li").click(function() {
		window.location = jQuery(this).find(".title").children("a").attr("href");
	});
	
	jQuery(".helpmechoose li").click(function() {
		window.location = jQuery(this).find("a").attr("href");
	});
	
	jQuery(".singlelevel, .multilevel, li.upright, li.lightweight, li.canister").hover(function() {
			jQuery(this).css( { background: "#f1ede1" } );
    }, function() {
			jQuery(this).css( { background: "none" } );
    });
	 
	


});




// this fixes things in safari... $(document).ready() values do not return the same thing in safari.

jQuery(window).load(function() {
	
	jQuery("div.wrapper").each(function() {
		//jQuery(this).width(jQuery(this).width() - 12);
	
		jQuery(this).children("div.colleft").height(parseInt(jQuery(this).height()) - 44);
		jQuery(this).children("div.colright").height(parseInt(jQuery(this).height()) - 44);

		//alert(jQuery(this).height());
		jQuery(this).children("div.background").height(parseInt(jQuery(this).height()));
		jQuery(this).children("div.background").width(parseInt(jQuery(this).width()));
		
		
		//alert(jQuery(this).width());
		
		jQuery(this).children("div.bottom").width(parseInt(jQuery(this).width()) - 56);
		jQuery(this).children("div.top").width(parseInt(jQuery(this).width()) -56);
		//alert(jQuery(this).width());
	});
});