// Standard jQuery header
;(function($) {
	$(document).ready(function() {
	
		$("#wrapper").corner();
	    $("#top-nav-menu .w1").corner();
	    $("#content").corner();
	    $("#nav li ul").corner();
	    $("#nav li ul.w1").corner();

	    
	    var d = new Date();
	if($.browser.msie && $.browser.version.substr(0,1)<7) {
			$.ajax({
				url: "/themes/silverchain/scripts/DD_belatedPNG_0.0.8a-min.js",
				dataType: "script",
				async: false,
				success: function(js){eval(js);}
			});
		   DD_belatedPNG.fix('#top-nav, img');
		   
			$(function() {
				$('.text').focus();
				$('.text').blur();
				$('#header').focus();
//			   $('.text').val('Search');
/*				var zIndexNumber = 1000;
				$('div').each(function() {
					$(this).css('zIndex', zIndexNumber);
					zIndexNumber -= 10;
				});
			*/
			});
		}

	    /* top nav menu */
	    closetimer = 0;
		if($("#top-nav-menu")) {
			$("#top-nav-menu .b").mouseover(function() {
			clearTimeout(closetimer);
				if(this.className.indexOf("clicked") != -1) {
					$(this)/*.parent()*/.next().slideUp(500);
					$(this).removeClass("clicked");
				}
				else {
					$("#top-nav-menu .b").removeClass();
					$(this).addClass("clicked");
					$("#top-nav-menu ul:visible").slideUp(500);
					$(this)/*.parent()*/.next().slideDown(500);
				}
				return false;
			});
			$("#top-nav-menu").mouseover(function() {
			clearTimeout(closetimer);
			});
			$("#top-nav-menu").mouseout(function() {
				closetimer = window.setTimeout(function(){
				$("#top-nav-menu ul:visible").slideUp(500);
				$("#top-nav-menu .b").removeClass("clicked");
				}, 2000);
			}); 
		}

	    closetimer = 0;
		if($("#nav")) {
			$("#nav .b").mouseover(function() {
			clearTimeout(closetimer);
				if(this.className.indexOf("clicked") != -1) {
					$(this).parent().next().slideUp(500);
					$(this).removeClass("clicked");
				}
				else {
					$("#nav .b").removeClass();
					$(this).addClass("clicked");
					$("#nav ul:visible").slideUp(500);
					$(this).parent().next().slideDown(500);
				}
				return false;
			});
			$("#nav").mouseover(function() {
			clearTimeout(closetimer);
			});
			$("#nav").mouseout(function() {
				closetimer = window.setTimeout(function(){
				$("#nav ul:visible").slideUp(500);
				$("#nav .b").removeClass("clicked");
				}, 2000);
			}); 
		}
		
		$(".minus").click(function(){
			txtSize('-1');
		});
		$(".plus").click(function(){
			txtSize('+1');
		});
		
		 // JavaScript Document
		var defaultFontSize = 91;
		var currentFontSize = defaultFontSize;
		
		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);

		function setFontSize(currentFontSize){
			$("#content").css('font-size', currentFontSize + '%');
			$(".hp-r2-b1 p").css('font-size', currentFontSize + '%');
			$("#content").height($("#content-main").height());
		};
		
		function txtSize(sizeDifference){
			currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);
			setFontSize(currentFontSize);
		};

		function createCookie(name,value,days) {
		  if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		  }
		  else expires = "";
		  document.cookie = name+"="+value+expires+"; path=/";
		};
		
		function readCookie(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			 }
			return null;
		};
		
		window.onunload = saveSettings;
		
		function saveSettings()	{
			createCookie("fontSize", currentFontSize, 36500);
		}
		jQuery("#SearchForm_SearchForm_Search").focus(function(){
			if(jQuery("#SearchForm_SearchForm_Search").val() == "Search") {
				jQuery("#SearchForm_SearchForm_Search").val("");
			}
		});
		jQuery("#SearchForm_SearchForm_Search").blur(function(){
			 if(jQuery("#SearchForm_SearchForm_Search").val() == "") {
				jQuery("#SearchForm_SearchForm_Search").val("Search");
			}
 
		});

	// Standard jQuery footer
	});
})(jQuery);
