$(document).ready(function(){
						   
	function phoneInsert() {
		$('#cpm_phone_insert').text(GetOfficePhoneText(CPMPhoneNumber, "1.NNN.NNN.NNNN"));
	}
	
	$('.overlay').click(function(){
		Boxy.load(this.href, {
			modal: true,
			title: $(this).attr('title'), // add title= attribute to a tag to get the title bar
			closeable: true, 
			closeText: 'CLOSE [ X ]', // close button will only appear if there’s a title attribute
			unloadOnHide: true,
			//y: '0px' // optional, I only have this here to deal with some sporadic placement issues
			center: true,
			fixed: false,
			afterShow: phoneInsert
		});
		return false;
	});
	
	$('.server-section-box').click(function(){
		var osType = $('#osType').val();
		Boxy.load('/dedicated-servers/overlays/dedicated-quote-form.php?ostype=' + osType +'&productInterest=' + $(this).attr('id'), {
			modal: true,
			title: $(this).attr('title'), // add title= attribute to a tag to get the title bar
			closeable: true, 
			closeText: 'CLOSE [ X ]', // close button will only appear if there’s a title attribute
			unloadOnHide: true,
			//y: '0px' // optional, I only have this here to deal with some sporadic placement issues
			center: true,
			fixed: false,
			afterShow: phoneInsert
		});
		return false;

	});
	
// activates hover state on contact-sales tab via server-table mouseover
	$(".server-section-box").mouseover(function(){
		$("a.overlay", this).toggleClass("serverBoxHover");
	}).mouseout(function(){
		$("a.overlay", this).toggleClass("serverBoxHover");
	});
	
// controls for upgrades sliders
	$("#BusinessPath-upgrades-trigger").click(function(){
		if ($("#BusinessPath-upgrades").is(":hidden")) {
			$("#BusinessPath-upgrades").slideDown(250);
			$(this).toggleClass("upgradeOpen");
		}
		else {
			$("#BusinessPath-upgrades").slideUp(250);
			$(this).toggleClass("upgradeOpen");
		}
	});
	
	$("#AdvancedPath-upgrades-trigger").click(function(){
		if ($("#AdvancedPath-upgrades").is(":hidden")) {
			$("#AdvancedPath-upgrades").slideDown(250);
			$(this).toggleClass("upgradeOpen");
		}
		else {
			$("#AdvancedPath-upgrades").slideUp(250);
			$(this).toggleClass("upgradeOpen");
		}
	});

	$("#UltraPath-upgrades-trigger").click(function(){
		if ($("#UltraPath-upgrades").is(":hidden")) {
			$("#UltraPath-upgrades").slideDown(250);
			$(this).toggleClass("upgradeOpen");
		}
		else {
			$("#UltraPath-upgrades").slideUp(250);
			$(this).toggleClass("upgradeOpen");
		}
	});

	$("#EnterprisePath-upgrades-trigger").click(function(){
		if ($("#EnterprisePath-upgrades").is(":hidden")) {
			$("#EnterprisePath-upgrades").slideDown(250);
			$(this).toggleClass("upgradeOpen");
		}
		else {
			$("#EnterprisePath-upgrades").slideUp(250);
			$(this).toggleClass("upgradeOpen");
		}
	});
	
	$("#StoragePath-upgrades-trigger").click(function(){
		if ($("#StoragePath-upgrades").is(":hidden")) {
			$("#StoragePath-upgrades").slideDown(250);
			$(this).toggleClass("upgradeOpen");
		}
		else {
			$("#StoragePath-upgrades").slideUp(250);
			$(this).toggleClass("upgradeOpen");
		}
	});
	
	//Control for Services slider
	$("#services-trigger").click(function(){
		if ($("#more-services").is(":hidden")) {
			$("#more-services").slideDown(250);
			$(this).toggleClass("servicesOpen");
		}
		else {
			$("#more-services").slideUp(250);
			$(this).toggleClass("servicesOpen");
		}
	});
});
