$(function() {
		   
	// png fix for IE6
	$(".png").supersleight();

	// return false when clicking a href="#"
	$("a").click(function(){
		var href = $(this).attr("href");
		if(href == "#"){
			return false;
		}
	});
	
	$('.virtual-tour').click(function(){
		popUp('http://www.realviewtv.com/online/stgeorge/index.html');
		//$('#virtual-tour-start').trigger('click');
	});
	
	$('#searchBox').submit(function(){
		var keyword2 = $('#keyword').val();
		if(keyword2 == 'Search this site'){
			alert('Please enter your keyword');
			$('#keyword').val('').focus();
			return false;
		}
	});
	
	// hide dropdown menu onclick
	$(document).click(function (evt) {
		$("div.dropdown").hide();
	});

	// replace default keyword
    $("#keyword").focus(function() {
		var keyword = $(this).val();
		if(keyword == "Search this site") $("#keyword").val("");
    });
    $("#keyword").blur(function() {
		var keyword = $(this).val();
		if(keyword == "") $("#keyword").val("Search this site");
    });
	
	// dropdown menu
    var menuHover = {
         sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)
         interval: 100, // number = milliseconds for onMouseOver polling interval
         over: hoverMenu, // function = onMouseOver callback (REQUIRED)
         timeout: 300, // number = milliseconds delay before onMouseOut
         out: hoveroutMenu // function = onMouseOut callback (REQUIRED)
    };
    $("li.parent").hoverIntent( menuHover ); 
	
	// Reset Font Size
  	var originalFontSize = $('html').css('font-size');
  	$(".resetFont").click(function(){
  		$('html').css('font-size', originalFontSize);
  	});
  	// Increase Font Size
  	$(".increaseFont").click(function(){
  		var currentFontSize = $('html').css('font-size');
		if(currentFontSize == "15px") { $('html').css('font-size', '16px'); }
		else if(currentFontSize == "16px") { $('html').css('font-size', '17px'); }
		else if(currentFontSize == "17px") { $('html').css('font-size', '18px'); }
		return false;
  	});
  	// Decrease Font Size
  	$(".decreaseFont").click(function(){
  		var currentFontSize = $('html').css('font-size');
		if(currentFontSize == "18px") { $('html').css('font-size', '17px'); }
		else if(currentFontSize == "17px") { $('html').css('font-size', '16px'); }
		else if(currentFontSize == "16px") { $('html').css('font-size', '15px'); }
		return false;
  	});
	
});

function hoverMenu(){
	$("div.dropdown").hide();
	$(this).find("div.dropdown").slideDown(250);
}
function hoveroutMenu(){
	$(this).find("div.dropdown").slideUp(250);
}
function popUp(url){
    playerW=1085
    playerH=599
    popupx = Math.round((screen.availWidth-playerW)/2);
    popupy = Math.round((screen.availHeight-playerH)/2);
    prop='width='+playerW+',height='+playerH+',scrollbars=no,left='+popupx+',top='+popupy+',resizable=no';
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "','"+ prop+"');");     
}

