// JavaScript Document
$(document).ready(function() {
	// What's New
	$('span#WhatsNewPopupOpener').click(function() {
		var parId = $(this).parent('div').attr('id');
		parId = parId.indexOf('Active') == -1 ? parId + 'Active' : parId.replace('Active','');
		$(this).parent('div').attr('id', parId);
	});
	
	// Contact us and login on the ribbon
	$('span.OpenerOnGreyRibbon').click(function(){
		var openerElmId = $(this).attr('id');
		if(openerElmId.indexOf('Active') == -1)
		{
			$('div#' + openerElmId.replace('PopupOpener', 'Wrapper')).css('display', 'block');
			$(this).attr('id', openerElmId + 'Active');
		}
		else
		{
			$('div#' + openerElmId.replace('PopupOpenerActive', 'Wrapper')).css('display', 'none');
			$(this).attr('id', openerElmId.replace('Active',''));
		}
	});
	$('span.OpenerOnGreyRibbon').mouseenter(function(){
		var openerElmId = $(this).attr('id');
		if(openerElmId.indexOf('Active') == -1)
		{
			$('div#' + openerElmId.replace('PopupOpener', 'Wrapper')).css('display', 'block');
			$(this).attr('id', openerElmId + 'Active');
		}		
	});
	
	// Prod Cat Boxes on Homepage
	$('div.ProdCatBox').mouseover(function() {
		$(this).css('border-color', '#FEDE00');
		$(this).children('p').children('a').css('color', '#FEDE00'); 
	}).mouseout(function(){
		$(this).css('border-color', '#E0E1DB');	
		$(this).children('p').children('a').css('color', '#9C9B89');
	});
	
	// Prod Item Large - Caption
	$('div.productItemLargeWrapper div h4').click(function(){
		$(this).parent('div').css('display', 'none');
		if($(this).parent('div').attr('class') == 'productItemLargeImageCaption')
		{
			$(this).parent('div').siblings('div.productItemLargeImageMoreInfo').css('display', 'block');
		}
		else
		{
			$(this).parent('div').siblings('div.productItemLargeImageCaption').css('display', 'block');
		}
	});
	
	$('span.productItemCaseStudyActive').click(function() {
		var id = $(this).parent('div').attr('id');
		$(this).css('display', 'none');
		$('div#' + id + ' span.productItemCaseStudy').css('display','block');
		id = id.replace('productItemLarge', 'caseStudyPopupWrapper');
		$('div#' + id).css('display', 'none');
	});
	
	$('span.productItemCaseStudy').click(function() {
		var id = $(this).parent('div').attr('id');
		$(this).css('display', 'none');
		$('div#' + id + ' span.productItemCaseStudyActive').css('display','block');
		$('div#' + id + ' span.productItemCaseStudyActive span').css('display','block');
		id = id.replace('productItemLarge', 'caseStudyPopupWrapper');
		$('div#' + id).css('display', 'block');
	});
	
	$('div.productItemThumbsWrapper img').click(function() {
		var id = $(this).attr('id');
		$('div.productItemLargeWrapper').css('display', 'none');
		id = id.replace('productItemThumb', 'productItemLarge');
		$('div#' + id).css('display', 'block');
	});
	
	// Form button
	$('input.formButton').mouseover(function(){
		$(this).addClass('formButtonHover');								 
	}).mouseout(function(){
		$(this).removeClass('formButtonHover');		
	});
	
	// Product listing button
	$('span.productItemTab').mouseover(function(){
		$(this).addClass('productItemTabHover');								 
	}).mouseout(function(){
		$(this).removeClass('productItemTabHover');		
	});
	$('a.productItemTab').mouseover(function(){
		$(this).addClass('productItemTabHover');								 
	}).mouseout(function(){
		$(this).removeClass('productItemTabHover');		
	});
});

function clearFieldDefault(jqElm, strDefault)
{
	if(jqElm.val().toLowerCase() == strDefault.toLowerCase())
	{
		jqElm.val('');
	}
}

function restoreFieldDefault(jqElm, strDefault)
{
	if(jqElm.val().toLowerCase() == strDefault.toLowerCase() || jqElm.val() == '')
	{
		jqElm.val(strDefault);
	}
}
