$(document).ready(function(){

	init_biz_pop();

	init_biz_box();

	init_page();

});

function init_biz_box(){
	
	$(".biz_box_heading").bind("mouseenter", function(){
		$(this).children(".biz_box_heading_bg").children(".biz_box_heading_bg_off").css("display", "none");
	});
	
	$(".biz_box_heading").bind("mouseleave", function(){
		$(this).children(".biz_box_heading_bg").children(".biz_box_heading_bg_off").css("display", "block");
	});	
	
	$(".biz_box_heading").bind("click", handle_biz_box_clicks);
}

function handle_biz_box_clicks(){
	
	var parent_page = $(this).parents(".sp_page_wrapper").attr("id");												 
	var current_content = $(this).siblings(".biz_box_content");
	var all_content = $("#" + parent_page + " .biz_box_content");
	
	var speed = 200;

	all_content.not(current_content).slideUp(speed);

	current_content.slideDown(speed);	
	
}

function init_page(){
	
	var location_hash = document.location.hash;
	
	if (location_hash == "" ){
		location_hash = null;
	}

	var page_options = new Array("1",
								 "2",
								 "3",
								 "4",								 
								 "5");

	var page_default = "1";

	var page = false;

	if (!location_hash){
		page = page_default;
	} else {
		location_hash = location_hash.substr(1, location_hash.length);
		for (var i = 0; i < page_options.length; i++){
			if (location_hash == page_options[i]){
				page = location_hash;
			}
		}
		if (!page) {
			page = page_default;
		}
	}	
	
	$("#biz_item_" + page).click();

	$(".biz_box_content").css("display", "none");
	
	$("#content_sp").css("display", "block");

}


function init_biz_pop(){
	
	$("#biz_right_hover_box").css({
		"position":"absolute",
		"z-index": "200",
		"width": "576px",
		//"height": "495px",
		//"top": "194px",
		//"left": "210px",
		"visibility": "hidden"
	});
	
	//$("#biz_right_hover_box").offset({ top: 184, left: 425 });
	
	$("#biz_more_details_btn").bind("click", function(e){
		
		//var biz_pop_ypos =  e.pageY - $("#biz_right_hover_box").height();

		//$("#biz_right_hover_box").css("top", biz_pop_ypos+"px");
		$("#biz_right_hover_box").css("visibility", "visible");
		
	});
	
	$("#close a").bind("click", function(e){

		$("#biz_right_hover_box").css("visibility", "hidden");		
		
	});

}
