$(document).ready(function() {
	$("#searchVal").focus(function() {
		$(this).val("");
	});
	$(".relatedProducts:last").addClass("last");
	$(".userReview:last").addClass("last");
	
	//subnav functionality
	var subNavVisible = false;
	//  subnav show overlay
	// $('#mainNavigation a').mouseover(function() {
	// 	subNavVisible = false;
	// 	$('#nav1').parent().removeClass('on');
	// 	$('#overlay').remove();
	// 	$('.subnav').css({left: "-1000px"});
	// 	$(this.hash).css({left: "0"});
	// 	$('#iframeCover').css({left: "-2000px"});
	// });
	function overlayDelayedShow() {
		var docHeight = $(document).height()-100;
		$('#container').append('<div id="overlay">&nbsp;</div>');
		if(subNavVisible){
			$('#overlay').height(docHeight);
			$('#overlay').show();
			// overlay remove and hide subnav on mouseout
			$('#overlay').mouseover(function() {
				$(this).remove();
				$('#mainNavigation li.on').removeClass('on');
				$('.subnav').css({top: "-1000px"});
				// $('#iframeCover').css({left: "-1000px"});
			});
		}
	}
	
	$('#mainNavigation li a').not($('#mainNavigation .subnav a')).mouseover(function() {
		// hide all subnavs
		subNavVisible = false;
		$('#mainNavigation li.on').removeClass('on');
		$('#overlay').remove();
		$('.subnav').css({top: "-1000px"});
		// show current subnav
		var target = $(this).attr('rel');
		$(target).css({top: "36px"});
		$('#iframeCover').css({left: "-2000px"});
		$(this).parent().addClass('on');
		subNavVisible = true;
		overlayDelayedShow();
		// var t=setTimeout(overlayDelayedShow,5);
	});
	
	
	$("input.addToCart").hover(function() {
		$(this).css("background-position","0 -24px");
	}, function() {
		$(this).css("background-position","0 0");
	});

});

// Tabs
$(function() {
	$('.tabLinks a').click(function() {
		$('div.tabContent').hide().filter(this.hash).fadeIn('normal');
		
		$('.tabLinks a').removeClass('on');
		$(this).addClass('on');
			
		return false;
	}).filter(':first').click();
});

// Tabs
$(function() {
		$('.tabLinks a').click(function() {
		$('div.tabContent').hide().filter(this.hash).fadeIn('normal');
		
		$('.tabLinks a').removeClass('TabOn');
		$(this).addClass('TabOn');
			
		return false;
	}).filter('.TabOn').click(); // Added By Nidhi Sharma on 12.08.2009
});

/*
// Solutions Landing Slide Expand/Collapse
$(function() {
	$('.solutionCatInfo').hide();
	$('.solutionCatInfo:first').show().parent().addClass('selected').end();
	$('.expandAll a').toggle(function() {
		$(this).text('Collapse All');
		$('.solutionCatInfo').slideDown(500).end();
		$('.solutionCatInfo').each(function() {
			$(this).parent().addClass('selected');
		});
		return false;
	}, function() {
		$(this).text('Expand All');
		$('.solutionCatInfo').slideUp(500).end();
		$('.solutionCatInfo').each(function() {
			$(this).parent().removeClass('selected');
		});	
		$('.solutionCatInfo:first').slideDown(600).parent().addClass('selected').end();	
		return false;
	}).end();
	
	$('.solutionCatLink').click(function() {
		var hClass = $(this).parent().parent().hasClass('selected');
		$('.solutionCatInfo').each(function() {			
			$(this).slideUp(500).parent().removeClass('selected').end();
		});
		if(hClass == false) {
			$(this.hash).slideDown(500).end();
			$(this).parent().parent().addClass('selected');			
		}
		else {
			$(this.hash).show();
		}
		return false;
	});
*/

// Solutions Landing Slide Expand/Collapse
$(function() {
	//$('.solutionCatInfo').hide();
	//$('.solutionCatInfo:first').show().parent().addClass('selected').end();
	$('.expandAll a').toggle(function() {
		
		$(this).text('Expand All');
		$('.solutionCatInfo').slideUp(500).end();
		$('.solutionCatInfo').each(function() {
			$(this).parent().addClass('visible');
		});	
		$('.solutionCatInfo:first').slideDown(600).parent().removeClass('visible').end();	
		return false;
	}, function() {
		$(this).text('Collapse All');
		$('.solutionCatInfo').slideDown(500).end();
		$('.solutionCatInfo').each(function() {
			$(this).parent().removeClass('visible');
		});
		return false;
	}).end();
	
	$('.solutionCatLink').click(function() {
		var hClass = $(this).parent().parent().hasClass('visible');
		
		/*
		$('.solutionCatInfo').each(function() {			
			$(this).parent().removeClass('selected').end();
		});
		*/
		/*			
		if(hClass == false) {
			$(this.hash).slideDown(500).end();
			$(this).removeClass('selected');
		}
		else {
			$(this.hash).show();
		}
		*/

		if(hClass == false) {		
			$(this.hash).slideUp(500).end();
//			$(this).parent().parent().addClass('selected');
			$(this).parent().parent().addClass('visible');	
//			$(this).slideUp(500).parent().parent().addClass('selected').end();

		}
		else {
			$(this.hash).slideDown(500).end();
			$(this).parent().parent().removeClass('visible');
		}

		
		return false;
	});

	
	// footer image carousel
	$(".ftTopLinks a span").unbind( "mouseover" );

	$('.ftTopLinks a').hover(
      function () {
        $('.ftTopLinks a').removeClass('active');
		$(this).addClass('active');
		$(this.hash).css({top: '0',display: 'block'});
		
		$('.jcarousel-container-horizontal').not(this.hash).hide();
		$('.jcarousel-container-horizontal').not(this.hash).find('.jcarousel-clip-horizontal').css({opacity: 0, top: '80px'});

		// only animate if not current carousel
		if($(this.hash).hasClass('active')){
			$(this.hash).find('.jcarousel-clip-horizontal').css({opacity: 1, top: 0});
		}else{
			$(this.hash).addClass('active');
			$(this.hash).find('.jcarousel-clip-horizontal').css({top: 0});
			$(this.hash).find('.jcarousel-clip-horizontal').css({opacity: 0, left: '20px'});
			$(this.hash).find('.jcarousel-clip-horizontal').animate({ 
		        left: 0,
				opacity: 1
		      }, 500 );
		}
		$('.jcarousel-container-horizontal').not(this.hash).removeClass('active');
      }, 
      function () {
        // do nothing
      }
    );	
});

$(function() {
	$('.moreOptions').hide();
	$('.optionsToggle').toggle(function() {
		$('.moreOptions').slideDown(500).end();
		$(this).text("Less Options");
	}, function () {
		$('.moreOptions').slideUp(500).end();
		$(this).text("More Options");		
	});

});

function PrintSummary(controlDiv, divClassName, printTitle)
{
	var tbl = document.getElementById(controlDiv);
	var 
		strPrintContent = "<LINK href=/Assets/css/global.css type=text/css rel=stylesheet>";
		strPrintContent += "<html>";
		strPrintContent += "<body style='background-color:#FFFFFF;padding:20px;'>";
		strPrintContent += "<div><img src='/Assets/images/logo_dymo.gif' border='0' alt='DYMO'/></div>";
		strPrintContent += "<div style='width:952px;' >";
		strPrintContent += "<div class='" + divClassName + "'>";
		strPrintContent += tbl.innerHTML;
		strPrintContent += "</div></div>";
		strPrintContent += "</body>";
		strPrintContent += "</html>";
	var printWin = window.open("print.html",printTitle);
		printWin.document.open();
		printWin.document.write(strPrintContent);
		printWin.document.close();
		printWin.print();
}

function PrintPage(PageUrl, pageTitle)
{
 	//var PageUrl = 'ProductDetailsPrint.aspx?prod=' + ProdId;
 	//window.open(PageUrl,'Product Details');
 	//alert(PageUrl);
 	var printWin = window.open(PageUrl,'Print');
 	printWin.print();	

}

