
function initCompareChecks() {
	$('p.compare input:checked').parents(".productItem").addClass("selected");
	$('p.compare input').bind(
		'change',
		function()
		{
			toggleAddToCompare(this);
		}
	)
}

var compareArr = new Array();
function toggleAddToCompare(target) {
	var productNum = $(target).val();
	var frame = $(target).parents(".productItem");
	
	if (jQuery.inArray(productNum, compareArr) < 0) {
		compareArr.push(productNum);
	}
	else {
		compareArr = jQuery.grep(compareArr, function(n){
						return (n != productNum);
    				});
	}
	$(target).attr("checked") == true ? $(frame).addClass("selected") : $(frame).removeClass("selected");
};

function verticallyCenterImages(targetClass)
{		
	$("img[@class='"+ targetClass +"']").each(
		function()
		{
			verticallyCenter($(this));
		}
	)
	
};

function verticallyCenter(element)
{
	$(element).css({
		visibility:"hidden"
	});
	
	if($(element).height() <= 0)
	{
		$(element).bind(
			'load',
			function()
			{
				centerThis();
			}
		)
	}else{	
		centerThis();
	}
	
	function centerThis()
	{		
		imgH = $(element).height();
		imgParentH = $(element).parent().height();
		var delta = (imgParentH/2) - (imgH/2);
		
		$(element).css
		(
			{
				position:"relative",
				visibility:"visible",
				top:delta
			}
		)
	}
}

function defineInputs() {	
	$('input[@type=text]').addClass("input_text");
	$('input[@type=radio]').addClass("input_radio");
	$('input[@type=checkbox]').addClass("input_checkbox");
}


//==================================================================
// on page load
//==================================================================
$('document').ready(
	function()
	{   
		//ADD INPUT TYPE CLASSES TO ALL INPUTS
		defineInputs();
		
		//VERTICALLY ALIGN ALL ELEMENTS WITH THE CLASS "vAlign" TO THEIR PARENT
		//verticallyCenterImages("vAlign");
		
		// APPLY PNG FIX TO ALL INLINE PNG IMAGES
		$('img[@src$=.png]').ifixpng();
		
		// initiate Compare Checkboxes
		initCompareChecks();
	}
);
//==================================================================
// on page unload
//==================================================================
$(window).unload( 
	function () 
	{ 
		 		
	} 
);



//==================================================================
// This is start
//==================================================================
//Added by Karthik On 04-08-2008
function selectAllCheckBox() {	
	var AllChkBox = $("input[@class='input_checkbox']");
	var AllChkBoxImg = $("img[@class='checkbox']");
	for(var i=0; i<AllChkBox.length; i++)
	{
		AllChkBox[i].checked=true;
		AllChkBoxImg[i].src = "images/boxCC.gif"
	}   		
}

//==================================================================
// Highlight the left navigation link. 
// @param: Index of the link starts from 1
//==================================================================
function HighlightLeftNav(lnkIndex) {
	$('ul.list2').children('.selected').removeClass('selected');
	$('ul.list2').children('li:nth-child('+lnkIndex+')').addClass('selected');		
}



