
/*Top Navigation sub Menu*/
subMenu = {
	Init:function() {
	var time=0;
	jQuery("#topNav li a").click(function() {
    	clearTimeout(time);
    	prntId=jQuery(this).next().attr('class');
		jQuery("#topNav li").removeClass("active");
		jQuery("#subNav li").hide();
		jQuery("#topNav ul span").hide();
		jQuery("#"+ prntId).show();
		jQuery(this).next().css('display','block');
		jQuery(this).parent().addClass("active");
  		});
	}
	
}

/*
This function adds a class to remove the right margin from the right most box on MLB

Created by : Abid / Sachin
Created on : 9/16/2010
*/

lastCall = {
	Init:function() {
		// Get the number of child DOM elements from 
		countChildElements=jQuery(".contentContainer .boxTopSadow").size();
		// Get the cssclass for each element
		var classNameList = [];
		for(i = 0; i < countChildElements; i++){
			classNameList[i]=jQuery(".contentContainer .boxTopSadow").eq(i).parent().attr("class");
		}
		// Initialize few variables to store class names while iterating the elements
		var classNum = 0;
		var previousClassNum = 0;
		var lastClassNum = 0;
		var currClassNum = 0;
		// Iterate the princple elements and decide to add the class
		for(i = 0; i < countChildElements; i++)
		{
			if(classNameList[i] == "col3")
				classNum = 3;
			else if(classNameList[i] == "col2")
				classNum = 2;
			else if(classNameList[i] == "col1")
				classNum = 1;
			else if(classNameList[i] == "colOneHalf")
				classNum = 1.5;
			previousClassNum = lastClassNum;
			lastClassNum = currClassNum;
			currClassNum = classNum;			
			// when the variables above amount to 3, add the class and reset the vars.
			if((currClassNum + lastClassNum == 3) || (currClassNum + lastClassNum + previousClassNum == 3))
			{ 
				jQuery(".contentContainer .boxTopSadow").eq(i).parent().addClass("lastCol");
				currClassNum = lastClassNum = previousClassNum = 0;
			}			
		}
	}	
};
mordenFormElement = {
	/*error Class used for error validation*/
	Init: function(){
		jQuery('.modernCheckBoxContactUs:first').addClass('chkboxActive');
		jQuery('#selectState, #selectMonth, #selectDay, #selectYear, #communications, #stateRegisteration, #marital,#ProductLocator1,#ProductLocator2,#ProductLocator3,#ProductLocator4').sSelect();
		var objActRad= new mordenFormElement.ActiveDeactRadio();
		var objActChk1= new mordenFormElement.ActDectChkBoxCrossSign();
		var objActChk2= new mordenFormElement.ActDectChkBoxCrtSign();
		
	},	
	ActiveDeactRadio:function(){
		jQuery(".genderOption").click(function(){
			jQuery('.genderOption').removeClass('genderOptionActive');
			jQuery(this).addClass('genderOptionActive');
		});
	},
	ActDectChkBoxCrossSign:function(){
		jQuery(".modernCheckBoxContactUs").click(function(){
			jQuery(this).toggleClass('chkboxActive');
		});
	},
	ActDectChkBoxCrtSign:function() {
		jQuery(".registerationChkBox").click(function(){
			jQuery(this).toggleClass('registerationChkBoxActive');
		});
	},
	ActiveDeactRadioTp:function(){
		jQuery(".radioTakeYouPoll:first").addClass('radioTakeYouPollActive');
		jQuery(".radioTakeYouPoll").click(function(){
			jQuery('.radioTakeYouPoll').removeClass('radioTakeYouPollActive');
			jQuery(this).addClass('radioTakeYouPollActive');

		});
	}
	
	

};
/* Form Validation */

formValidation = {
	/*error Class used for error validation*/
	Init: function(){
		jQuery("#sumbitButtom").click ( function (){
		var count=jQuery("input.required").size();
		jQuery("#registeration div").removeClass("error");
		for(i=0;i<count;i++) {
			
			if(jQuery("input.required").eq(i).val()=="") {
				jQuery("input.required").eq(i).parent().addClass("error");
				jQuery(".errorMessage").show();
				//return false;
				
			} else {
				jQuery(".errorMessage").hide();
				//return true;
			}
		}
		});
	}
};
buttonOver = {
	/*error Class used for error validation*/
	Init: function(){
		$(".button a").hover(function(){
			if($.browser.msie && $.browser.version=="6.0") {
				$(this).next().addClass("over");
				$(this).next().next().next().addClass("over");
			} else {
				$(this).next().addClass("over");
			}
			
			},function(){
			if($.browser.msie && $.browser.version=="6.0") {
				$(this).next().removeClass("over");
				$(this).next().next().next().removeClass("over");
			} else {
				$(this).next().removeClass("over");
			}
			
		});
	}
};

MordernInit = {
	/*error Class used for error validation*/
	Init: function(){
	// jQuery("label[for='offersCheckbox-cbbtn1']").addClass('contactUsCheckBox');
	// jQuery("label[for='offersCheckbox-cbbtn2']").addClass('contactUsCheckBox');
	// jQuery("label[for='CheckBoxes_1-cbbtn1']").addClass('contactUsCheckBox');
	// jQuery("label[for='CheckBoxes_1-cbbtn2']").addClass('contactUsCheckBox');
	$("#CheckBoxes_1-cbbtn1, #CheckBoxes_1-cbbtn2").addClass("unique");
	
	
	jQuery("#state").removeClass('Field_standard');
	jQuery("#lastName.err").removeClass('Error_standard');
	jQuery("#lastName.err").addClass('lastNameError');
	jQuery("#state").next("div").addClass('stateError');
	jQuery("input[name='FinishBtn']").addClass('submitButton');
	// jQuery('.contactUsCheckBox:first').addClass('contactUsCheckBoxActive');
	jQuery("center h1").css({"display":"none"});
	jQuery("div[name='column_otherwise']").children("table").addClass('prefix');
	jQuery('.prefix td:even').addClass('customRadio');
	var CaptchatorTextField = $("input[name='Captchator_1']");
	jQuery(CaptchatorTextField).next("div").append(CaptchatorTextField);
	
	jQuery(".MandatoryMarker").html("*:");	
		
	// Button MouseOver Function 
	jQuery("#buttons").hover (function()
	{
		jQuery(this).css({"background-position": "left -28px"});
		jQuery(this).children("input").css({"background-position": "right -28px"});
		if(jQuery.browser.msie && jQuery.browser.version=="6.0") {
		//jQuery(this).css({"background-position": "left -29px"})
		//jQuery(this).children("input").css({"background-position": "right -29px"})

		}
	 }, function ()
	 {
		jQuery(this).css({"background-position": "left 1px"});
		jQuery(this).children("input").css({"background-position": "right 1px"});
	 })
	
	
	
// jQuery(".contactUsCheckBox").click ( function () {

	// $('.contactUsCheckBox').removeClass('contactUsCheckBoxActive')
	// $('.contactUsCheckBox').prev('input.unique:checked').not(this).removeAttr('checked');
	// $(this).toggleClass("contactUsCheckBoxActive")
	// jQuery(".contactUsCheckBox").dblclick(function() {
		// jQuery(this).removeClass('contactUsCheckBoxActive');
		// $(this).prev('input.unique').attr('checked', false);
	// });
// });
	

	
	jQuery(".customRadio").click ( function () {
		
		jQuery(this).children("input[type='radio']").val();
		jQuery('.prefix td:even').removeClass('customRadioActive');
		jQuery(this).addClass('customRadioActive');
		if(jQuery(this).hasClass('customRadioActive')) {
			jQuery('.prefix td:even').children("input[type='radio']").attr('checked', false);
			jQuery(this).children("input[type='radio']").attr('checked', true);
		} else {
			jQuery(this).children("input[type='radio']").attr('checked', false);
		}
		
	});
}
};
ShowError = {
	Init:function(ObjId){
	if($("select[id='"+ObjId+"']").attr("id")==ObjId) {
		$("select[id='"+ObjId+"']").next().addClass('error');
	} else {
		$("#"+ObjId).addClass('error');
	}
		$("label[for='"+ObjId+"']").addClass('errorlbl');
	}
}
HideError = {
	Init:function(ObjId){
	if($("select[id='"+ObjId+"']").attr("id")==ObjId) {
		$("select[id='"+ObjId+"']").next().removeClass('error');
	} else {
	$("#"+ObjId).removeClass('error');
	}
	$("label[for='"+ObjId+"']").removeClass('errorlbl');
	}
}
jQuery(document).ready(function() {
	//var ObsubMenu = new subMenu.Init();
	var OblastCall = lastCall.Init();
	var obbuttonOver= buttonOver.Init();
	$("#Espanol").hover(function(){
		$(this).attr('src','/Resources/Images/button_espanol_active.jpg');
	},function(){
		$(this).attr('src','/Resources/Images/button_espanol.jpg');
	});
	$(".englishImg img").hover(function(){
		$(this).attr('src','/Resources/images/button_english_active.jpg');
	},function(){
		$(this).attr('src','/Resources/images/button_english.jpg');
	});
	jQuery(".searchForm .button").hover (function()
		{
		jQuery(this).css({"background-position": "left -28px"})
		jQuery(this).children("input").css({"background-position": "right -28px"})

		
		
	 	}, function ()
	 	{
		jQuery(this).css({"background-position": "left 1px"})
		jQuery(this).children("input").css({"background-position": "right 1px"})
	 });
	 
	 var jQbrowser = navigator.userAgent.toLowerCase();
		jQuery.os = {
		mac: /mac/.test(jQbrowser),
		win: /win/.test(jQbrowser),
		linux: /linux/.test(jQbrowser)
		};
		if($.os.mac) {
			if($.browser.safari) {
				$("#buttons input, .searchForm .button input").css({"padding":"7px 23px 10px 0px"});
			}
		}
		
		var brandKitchenCarousal2 = $("#brandKitchenCarousal2 li").size();
		var brandKitchenCarousal3 = $("#brandKitchenCarousal3 li").size();
		if(brandKitchenCarousal2==5) {
			
			$(".jcarousel-prev, .jcarousel-next").hide();
		}
		
	
});


jQuery(document).ready(function() {

$(".searchForm .newListSelected:last").css({"position":"absolute !important"})
								
})

var DYNIFS = {
	
	// Storage for known IFrames.
	iframes: {},
	// Here we save any previously installed onresize handler.
	oldresize: null,
	// Flag that tell us if we have already installed our onresize handler.
	ready: false,
	// The document dimensions last time onresize was executed.
	dim: [-1,-1],
	// Timer ID used to defer the actual resize action.
	timerID: 0,
	// Obtain the dimensions (width,height) of the given document.
	getDim: function(d) {
		var w=200, h=200, scr_h, off_h;
		if( d.height ) { return [d.width,d.height]; }
		with( d.body ) {
			if( scrollHeight ) { h=scr_h=scrollHeight; w=scrollWidth; }
			if( offsetHeight ) { h=off_h=offsetHeight; w=offsetWidth; }
			if( scr_h && off_h ) h=Math.max(scr_h, off_h);
		}
		return [w,h];
	},
	// This is our window.onresize handler.
	onresize: function() {		
		// Invoke any previously installed onresize handler.
		if( typeof this.oldresize == 'function' ) { this.oldresize(); }
		// Check if the document dimensions really changed.
		var dim = this.getDim(document);
		if( this.dim[0] == dim[0] && this.dim[1] == dim[1] ) return;
		// Defer the resize action to prevent endless loop in quirksmode.
		if( this.timerID ) return;
		this.timerID = setTimeout('DYNIFS.deferred_resize();', 10);
	},
	// This is where the actual IFrame resize is invoked.
	deferred_resize: function() {
		// Walk the list of known IFrames to see if they need to be resized.
		for( var id in this.iframes ) this.resize(id);
		// Store resulting document dimensions.
		this.dim = this.getDim(document);
		// Clear the timer flag.
		this.timerID = 0;		
	},
	// This is invoked when the IFrame is loaded or when the main window is resized.
	resize: function(id) {		
		if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) 
		if (ffversion>=3) {
		
		var iframeEl = document.getElementById? document.getElementById(id): document.all? document.all[id]: null;
		  if (iframeEl) {
		  iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
		  var h = document.getElementById("frame1").contentWindow.document.documentElement.clientHeight;
		  var new_h=(h-124);
		  iframeEl.style.height = h + "px";
		  }
		  }
		}
		else {
		
		if( !window.frames || !window.frames[id] || !document.getElementById || !document.body )
			return;
		//alert("hi1");
		// Get references to the IFrame window and layer.
		var iframe = window.frames[id];
		var div = document.getElementById(id);
		if( !div ) return;
		// Save the IFrame id for later use in our onresize handler.
		if( !this.iframes[id] ) {
			this.iframes[id] = true;
		}
		// Should we inject our onresize event handler?
		if( !this.ready ) {
			this.ready = true;
			this.oldresize = window.onresize;
			window.onresize = new Function('DYNIFS.onresize();');
		}		
		// This appears to be necessary in MSIE to compute the height
		// when the IFrame'd document is in quirksmode.
		// OTOH, it doesn't seem to break anything in standards mode, so...
		if( document.all ) div.style.height = '0px';
		// Resize the IFrame container.
		var dim = this.getDim(iframe.document);
		div.style.height = (dim[1]) + 'px';		
		}
	}
};

var showing = false;

// phase 2 script 

jQuery(document).ready(function () {

	$(".SetRadio label").addClass("customRadio");
	$(".SetRadio input:checked").next().addClass("customRadioActive");
	
	
	//var inputValue = $(this).prev("input").val();
	// jQuery('.contactUsCheckBox').click(function () {
		// $(this).toggleClass("contactUsCheckBoxActive");
		// //alert(inputValue)
	// });

	$(".showPoup").click(function () {
		$(".displayInformation").show()
	})

	$(".popUpcloseButton").click(function () {
		$(".displayInformation").hide()
	});


	/* Genmder Radio Button */
	$(".customRadio").click(function () {

		$(".SetRadio label").removeClass("customRadioActive");
		$(this).addClass("customRadioActive");

	});

	window.setInterval("checkVisibility()", 100);

});/* 27-10-2010*/

function checkVisibility()
{
	if($('#dialog2').is(':visible'))
	{
		showing = true;
	}

	if($('#dialog2').is(':hidden') && showing)
	{
		showing = false;
		window.clearInterval("checkVisibility()");
		document.location.href = "/default.aspx";
	}
}

$(document).ready(function () {
    $("#heroModUl img, .boxContainer img").each(function () {
        $(this).attr("title", $(this).attr("title").replace(/(<.*?>)/ig, ""));
        $(this).attr("alt", $(this).attr("alt").replace(/(<.*?>)/ig, ""));
    });

    //Footer Logo Hover Zoom
	$('.footerImageCarousel li a img').hover(function() {
		$(this).css({'height':'86px', 'width':'99px', 'margin':'-10px 0 0 -10px', 'z-index':'9999'});
	},
	function() {
		$(this).css({'height':'68px', 'width':'77px', 'margin':'0', 'z-index':'0'});
	});

    // Hidden Field Functionality
    $('hiddenField').val("1");
    if ($('hiddenField').val == 1) {
        location.reload();
    }

    $('.TxtBoxEmail').focus(function () {
        var blanktext = "";
        var defaulttext = "Email Address";
        if ($(this).val() == defaulttext) {
            $(this).val(blanktext);
        }
    });

    $('.TxtBoxEmail').blur(function () {
        var defaulttext = "Email Address";
        if ($(this).val() == "") {
            $(this).val(defaulttext);
        }
    });
});


