$(document).ready(init);

function init()
{
	var pageURL = $.cookie("pageURL") ? $.cookie("pageURL") : "home.html";
	$('#content').loadJFrame(pageURL);
	
	if ($("#menu a[@href='" + pageURL + "']").parent().is("li")) {
		$("#menu a[@href='" + pageURL + "']").parent().parent().parent().slideDown("def");
		$("#menu a[@href='" + pageURL + "']").parent().parent().parent().fadeTo("def", 1);
		$("#menu a[@href='" + pageURL + "']").parent().parent().parent().prev().addClass("selected");
	} else {
		$("#menu a[@href='" + pageURL + "']").parent().next().slideDown("def");
		$("#menu a[@href='" + pageURL + "']").parent().next().fadeTo("def", 1);
	}
	$("#menu a[@href='" + pageURL + "']").parent().addClass("selected");
}

jQuery.fn.waitingJFrame = function () {
	$(this).html("<b>loading...</b>");
}

function onContentUnload()
{
	$("#content").css('left', 2000);
}

function onContentLoad()
{
	$("#content").animate( {left: 0}, 2000, 'linear');
	
	var page = $("#content").attr("src");
	
	if (page == "home.html" || page == "pro_services.html" || page == "design.html" || 
		page == "equipment.html" || page == "wire.html"|| page == "special.html" ||
		page == "portfolio.html" || page == "contact.html") {
		$("#footer").animate( {top: 590} );
		$("#footer").attr("width", 946);
	} else if (page == "profile.html") {
		$("#footer").animate( {top: 630} );
		$("#footer").attr("width", 946);
	} else if (page == "pro_profiles.html") {
		$("#footer").animate( {top: 690} );
		$("#footer").attr("width", 946);
	} else {
		$("#footer").animate( {top: 650} );
		$("#footer").attr("width", 1030);
	}
	
	var pageTitle;
	if (page == "home.html")				pageTitle = "Home Page";
	else if (page == "pro_services.html")	pageTitle = "Professional Services";
	else if (page == "design.html")			pageTitle = "Design and Specification";
	else if (page == "equipment.html")		pageTitle = "Planning and Procurement";
	else if (page == "wire.html")			pageTitle = "Building Wiring Systems";
	else if (page == "special.html")		pageTitle = "Special Services";
	else if (page == "portfolio.html")		pageTitle = "Project Portfolio";
	else if (page == "contact.html")		pageTitle = "Contact Us";
	else if (page == "profile.html")		pageTitle = "Company Profile";
	else if (page == "pro_profiles.html")	pageTitle = "Professional Profile";
	else if (page == "alaska.html")			pageTitle = "ANMC";
	else if (page == "samaritan.html")		pageTitle = "HGS";
	else if (page == "presbyterian.html")	pageTitle = "PIH";
	else if (page == "saint.html")			pageTitle = "SRMC";
	else if (page == "sutter.html")			pageTitle = "SRMC";
	else if (page == "white.html")			pageTitle = "WMMC";

	document.title = "GenEnCon - " + pageTitle;
	
	$.cookie("pageURL", page);
}

function contentAnimate_complete()
{
	$('#content img').css('display', 'block');
}

function projectPortfolio_select(cBox)
{
	if (cBox.selectedIndex > 0) {
		var url = cBox.options[cBox.selectedIndex].value;
		$("a[@href='" + url + "']").click();
	}
}

function showGalleryImage(imgSrc)
{
	$("#galleryImageContainer").append("<img src='" + imgSrc + "' style='display:none' />");
	$("#galleryImageContainer img").fadeIn(1000);
}

function setProfile(index)
{
	$('div.prof_item').hide();
	$('#prof_item_' + index).show();

	if (index == 1) {
		$('#proLeftBtn').removeClass('pro_left_name2');
		$('#proLeftBtn').addClass('pro_left_name');
		$('#proRightBtn').removeClass('pro_right_name2');
		$('#proRightBtn').addClass('pro_right_name');
	} else {
		$('#proLeftBtn').removeClass('pro_left_name');
		$('#proLeftBtn').addClass('pro_left_name2');
		$('#proRightBtn').removeClass('pro_right_name');
		$('#proRightBtn').addClass('pro_right_name2');
	}
}
