$(document).ready(function() {
	$(('#slider').length > 0)
	{
		$('#slider').cycle({ 
			fx:     'scrollHorz', 
			speed:  'fast', 
			timeout: 0, 
			next:   '#next2', 
			prev:   '#prev2',
			startingSlide: querySt("s")
		});
	}
	
	if ($("a.show-ans").length > 0)
	{
		$('a.show-ans').click(function(){
			if ($(this).parent().find('.ans').css('display') == "none")
			{
				$(this).parent().find('.ans').slideDown("slow", 
					 function () { $(this).parent().addClass("active"); }
				);
				$(this).find("img").attr("src","images/ico/up-arrow.png");
			}
			else
			{
				$(this).parent().find('.ans').slideUp("slow", 
					 function () { $(this).parent().removeClass("active");}
				);
				$(this).find("img").attr("src","images/ico/down-arrow.png");
			}
			
			return false;
		});
	}
	
	if ($("#btn-submit-entry").length > 0)
	{
		$("#btn-submit-entry").mouseover(function() {
			$(this).find("img").attr("src", "images/btn/btn-submit-entry-hover.png");
		}).mouseout(function(){
			$(this).find("img").attr("src", "images/btn/btn-submit-entry.png");
		});
	}
	
	if ($("#btn-download-application-form").length > 0)
	{
		$("#btn-download-application-form").mouseover(function() {
			$(this).find("img").attr("src", "images/btn/btn-download-application-form-hover.png");
		}).mouseout(function(){
			$(this).find("img").attr("src", "images/btn/btn-download-application-form.png");
		});
	}
	if ($("#btn-download-2011-winners-brochure").length > 0)
	{
		$("#btn-download-2011-winners-brochure").mouseover(function() {
			$(this).find("img").attr("src", "images/btn/btn-download-2011-winners-brochure-hover.png");
		}).mouseout(function(){
			$(this).find("img").attr("src", "images/btn/btn-download-2011-winners-brochure.png");
		});
	}	
	if ($("#prev2").length > 0)
	{
		$("#prev2").mouseover(function() {
			$(this).find("img").attr("src", "images/lArrow-hover.png");
		}).mouseout(function(){
			$(this).find("img").attr("src", "images/lArrow.png");
		});
	}
	
	if ($("#next2").length > 0)
	{
		$("#next2").mouseover(function() {
			$(this).find("img").attr("src", "images/rArrow-hover.png");
		}).mouseout(function(){
			$(this).find("img").attr("src", "images/rArrow.png");
		});
	}
	
	$("ul.submenu").mouseover(function() {
		$(this).parent().find("a.menu").addClass("sel");
		$(this).addClass("active");
	}).mouseout(function(){
		$(this).parent().find("a.menu").removeClass("sel");
		$(this).removeClass("active");
	});
	
	$("#top-menu ul li").mouseover(function() {
		$(this).find("ul.submenu:first").addClass("active");
	}).mouseout(function(){
		$(this).find("ul.submenu").removeClass("active");
	});
	$("#top-menu ul li ul.submenu3").mouseover(function() {
		$(this).find("submenu3-1").addClass("active");
	}).mouseout(function(){
		$(this).find("submenu3-1").removeClass("active");
	});
	
	setHeight();
	
});
function setBgHeight()
{
	if ($(".panel-grey-bg, img.grey-bg-line").length > 0)
	{
		if ($(".panel-grey-bg").height() > 375 )
			$("img.grey-bg-line").height($(".panel-grey-bg").height());
		
	}
}

function setHeight()
{
	if ($(".panel-grey-bg, img.grey-bg-line").length > 0)
	{
		if ($(".panel-grey-bg").height() > 375 )
		{
			$("img.grey-bg-line").height($(".panel-grey-bg").height());
		}
		
	}
}

function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
}

function printpage()
{
	window.print();
}
