// Include Dependencies
require_jquery_if_needed('/_javascript/jquery.min.js');

$(document).ready(function () {
	
	$("div#nav").hover(
		function(){},
		function(){
		$("#navAbout").hide();
		$("#navPortfolio").hide();
	});

	$("li#contact,li#blog,li#sales,li#links").mouseover(function(){
		$("#navPortfolio").hide();
		$("#navAbout").hide();
	});

	$("li#about").mouseover(function(){
		$("#navPortfolio").hide();
		$("#navAbout").show();
	});
	
	$("li#portfolio").mouseover(function(){
		$("#navAbout").hide();
		$("#navPortfolio").show();
	});
	
	$("#navAbout").hover(function(){},
		function(){
			$("#navAbout").hide();
	});

	$("#navPortfolio").hover(function(){},
		function(){
			$("#navPortfolio").hide();
	});
});

/******************************************************************************
 **************************** Standard Functions ******************************
 *****************************************************************************/
/**
 * Requires jQuery if it isn't already loaded
 * This is handy because you can include the script without having to include jquery too
 */
function require_jquery_if_needed(filename){
	if (typeof jQuery == 'undefined'){
		require(filename);
	}
}

/**
 * original by: Legaev Andrey input by: Jani Hartikainen improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 * note 1: This function uses XmlHttpRequest and cannot retrieve resource from different domain.
 * note 2: Synchronous so may lock up browser, mainly here for study purposes. 
 * note 3: To avoid browser blocking issues's consider using jQuery's: $('#divId').load('http://url') instead.
 * example 1: file_get_contents('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm');
 * returns 1: '123'
 */ 
function file_get_contents( url ) {
    var req = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    if (!req) throw new Error('XMLHttpRequest not supported');
    
    req.open("GET", url, false);
    req.send(null);
    
    return req.responseText;
}

/**
 * original by: Michael White (http://getsprink.com) improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 * note 1: Force Javascript execution to pause until the file is loaded. Usually causes failure if the file never loads. ( Use sparingly! )
 * depends on: file_get_contents
 * example 1: require('http://www.phpjs.org/js/phpjs/_supporters/pj_test_supportfile_2.js');
 * returns 1: 2
 */
function require( filename ) {
 
    var js_code = file_get_contents(filename);
    var script_block = document.createElement('script');
    script_block.type = 'text/javascript';
    var client_pc = navigator.userAgent.toLowerCase();
    if((client_pc.indexOf("msie") != -1) && (client_pc.indexOf("opera") == -1)) {
        script_block.text = js_code;
    } else {
        script_block.appendChild(document.createTextNode(js_code));
    }
 
    if(typeof(script_block) != "undefined") {
        document.getElementsByTagName("head")[0].appendChild(script_block);
    }
}
