﻿//Begin jquery
$(document).ready(function () {

	$('body').append(
		'<div id="footerbg"><img src="images/footerbg.png" alt="" /></div><div id="footertext">201 Dartmouth SE, Albuquerque, NM  87106<br />phone: (505) 265-9656<br />fax: (505) 265-2096<br /></div>'
	);
	
	$('table').attr({
		'cellpadding' : '0',
		'cellspacing' : '0'
	});


	//Resizing
	$.resize = function () {
	
		var screenWidth = $(window).width();
		var screenHeight = $(window).height();
	
		//Define bottom BG height
		var bottombgheight = screenHeight - 768;
		if(bottombgheight > 0){
			$("#bottombg td").css("height",bottombgheight + "px");
		}
		
		//News panel
		var newsLeft = screenWidth / 2 + 72 + "px";
		$("#newspanel div").css({
			'position' : 'absolute',
			'left' : newsLeft,
			'z-index' : '2',
			'font-size' : '10pt',
			'width' : '280px',
			'height' : '115px',
			'overflow' : 'hidden',
			'color' : '#ffdccd'
		});
			
		//News panel 1
		var news1Top = "432px";
		$("#news1").css({
			'top' : news1Top
		});
		
		//News panel 2
		var news2Top = "516px";
		$("#news2").css({
			'top' : news2Top
		});
		
		//News head 1
		var newsHead1Top = "416px";
		$("#newshead1").css({
			'top' : newsHead1Top,
			'font-size' : '11pt',
			'color' : 'white'
		});
		
		//News head 2
		var newsHead2Top = "500px";
		$("#newshead2").css({
			'top' : newsHead2Top,
			'font-size' : '11pt',
			'color' : 'white'
		});
		
		//More Buttons
		var moreButtonsLeft = screenWidth / 2 + 300 + 'px';
		$("#more1,#more2").css({
			'position' : 'absolute',
			'z-index' : '3',
			'left' : moreButtonsLeft,
			'cursor' : 'pointer'
		});
		$('#more1').css({
			'top' : '562px'
		});
		$('#more2').css({
			'top' : '562px'
		});
		$('#more1,#more2').click(function(){
			location.href = 'mission.html';
		});
	
		//Buttons
		var buttonsLeft = screenWidth / 2 - 300 + "px";
		$("#buttons img").css({
			'left' : buttonsLeft,
			'position' : 'absolute',
			'z-index' : '3'
		});
		
		//Button1
		var buttonTop1 = "428px";
		$("#imgbutton1").css({
			'top' : buttonTop1
		});
		
		//Button2
		var buttonTop2 = "454px";
		$("#imgbutton2").css({
			'top' : buttonTop2
		});
		
		//Button3
		var buttonTop3 = "482px";
		$("#imgbutton3").css({
			'top' : buttonTop3
		});
	
		//Button4
		var buttonTop4 = "509px";
		$("#imgbutton4").css({
			'top' : buttonTop4
		});
		
		//Button5
		var buttonTop5 = "536px";
		$("#imgbutton5").css({
			'top' : buttonTop5
		});
		
		//Button6
		var buttonTop6 = "564px";
		$("#imgbutton6").css({
			'top' : buttonTop6
		});
		
		//Divs
		var divLeft = screenWidth / 2 - 365 + "px";
		$("#buttons div").css({
			'left' : divLeft,
			'position' : 'absolute',
			'z-index' : '4',
			'width' : '128px',
			'height' : '28px',
			'background-image' : 'url(images/iefix.png)'
		});
		$("#buttons div:eq(0)").css({
			'top' : '416px'
		});
		$("#buttons div:eq(1)").css({
			'top' : '444px'
		});	
		$("#buttons div:eq(2)").css({
			'top' : '472px'
		});
		$("#buttons div:eq(3)").css({
			'top' : '500px'
		});
		$("#buttons div:eq(4)").css({
			'top' : '528px'
		});
		$("#buttons div:eq(5)").css({
			'top' : '556px'
		});
		
		//Click
		$("#buttons div:eq(0)").click(function() {
			location.href = 'default.html';
		});
		$("#buttons div:eq(1)").click(function() {
			location.href = 'wellness.html';
		});
		$("#buttons div:eq(2)").click(function() {
			location.href = 'services.html';
		});
		$("#buttons div:eq(3)").click(function() {
			location.href = 'newpatients.html';
		});	
		$("#buttons div:eq(4)").click(function() {
			location.href = 'directions.html';
		});
		$("#buttons div:eq(5)").click(function() {
			location.href = 'contact.html';
		});

			
	
		//Orb
		$('#orb').css({
			'left' : screenWidth / 2 - 378 + 'px'
		});
		
		//Mouseover
		$("#buttons div").mouseenter(function(){
			buttonid = $(this).attr('id');
			var buttonsrc = "images/" + $(this).attr('id') + "o.png";
			var orbTop = $('#img' + buttonid).attr('alt') * 1;
			orbTop = orbTop - 13 + 'px';
			$('#img' + buttonid).attr('src', buttonsrc);
			$('#orb').css({
				'visibility' : 'visible',
				'top' : orbTop
			});
		});
		$("#buttons div").mouseleave(function(){
			var buttonsrc = "images/" + $(this).attr('id') + ".png";
			$('#img' + buttonid).attr('src', buttonsrc);
			$('#orb').css({
				'visibility' : 'hidden'
			});
		});
		
		//Scroll pane
		var specialtiesContentLeft = screenWidth / 2 - 152;
		$('#specialtiescontent').jScrollPane({
			scrollbarWidth : 10,
			showArrows : true
		});
		$('#holder').css({
			'position' : 'absolute',
			'top' : '445px',
			'left' : specialtiesContentLeft + 'px',
			'z-index' : '4'
		});
		$('#specialtieshead').css({
			'left' : specialtiesContentLeft + 6 + 'px'
		});
		
		//Content
		var contentLeft = screenWidth / 2 - 152;
		$('#content').jScrollPane({
			scrollbarWidth : 10,
			showArrows : true
		});
		$('#contentholder').css({
			'left' : contentLeft + 'px',
			'position' : 'absolute',
			'z-index' : '3'
		});		
		
		//Set scroll
		if(screenHeight < 768){
			$(window).scrollTop(208);
		}
		
		//Set footer
		var footerBgTop = screenHeight - 91;
		var footerBgLeft = screenWidth / 2 - 254;
		var footerTextTop = screenHeight - 47;
		var footerTextLeft = screenWidth / 2 - 227;
		
		if(screenHeight < 768){
			var footerBgTop = 677;
			var footerTextTop = 721;
		}
		
		$('#footerbg').css({
			'top' : footerBgTop + 'px',
			'left' : footerBgLeft + 'px'			
		});
		$('#footertext').css({
			'top' : footerTextTop + 'px',
			'left' : footerTextLeft + 'px'
		});

	};
	
	$.resize();
	
	$(window).resize(function() {
		$.resize();
	});
});