var i1 = new Image();
i1.src = '/images/nav-understanding-on.jpg'
var i2 = new Image();
i2.src = '/images/nav-exploring-on.jpg'
var i3 = new Image();
i3.src = '/images/nav-living-on.jpg'
var i4 = new Image();
i4.src = '/images/nav-helping-on.jpg'
var i5 = new Image();
i5.src = '/images/nav-working-on.jpg'
var i6 = new Image();
i6.src = '/images/nav-learn-on.jpg'

function fieldBlur(field_id, default_value){
	if($('#'+field_id).attr("value") == ''){
		$('#'+field_id).attr("value", default_value);
	}
}

function fieldFocus(field_id, default_value){
	if($('#'+field_id).attr("value") == default_value){
		$('#'+field_id).attr("value", "");
	}
}

function contentDropdownOn(id, img_id, img_src, img_width){
	document.getElementById(id).style.display = '';
	change_image(img_src, img_id);
	document.getElementById(img_id).height = '58';
	document.getElementById(img_id).className = 'selected';
	document.getElementById(img_id).width = img_width;
	window.contentDropdownMouseIsOver = true;
	if(window.contentDrdopdownId && window.contentDrdopdownId != id){
		hideDropdown(true);
	}
	window.contentDrdopdownId = id;
}

function contentDropdownOff(id, img_id, img_src, img_width){
	window.contentDropdownMouseIsOver = false;
	window.contentDrdopdownImgId = img_id;
	window.contentDrdopdownImgSrc = img_src;
	window.contentDrdopdownImgWidth = img_width;
	setTimeout('hideDropdown(false)', 100);
}

function hideDropdown(force){
	if(!window.contentDropdownMouseIsOver || force){
		document.getElementById(window.contentDrdopdownImgId).height = '45';
		document.getElementById(window.contentDrdopdownImgId).className = '';
		document.getElementById(window.contentDrdopdownImgId).width = window.contentDrdopdownImgWidth;
		change_image(window.contentDrdopdownImgSrc, window.contentDrdopdownImgId);
		document.getElementById(contentDrdopdownId).style.display = 'none';
	}
}

function setupExternalLinks() {
	var links       = document.getElementsByTagName('a');
	var linkcount = 1;
	var setup_link;
	for (var i = links.length; i != 0; i--) {
		setup_link = false;
		var a = links[i-1];
		if (!a.href) continue;
		
		// Track external links
		if(a.href.indexOf('http') != -1 &&
            a.href.indexOf(window.location.hostname) == -1){
			url = a.href;
			if (url == 'http://www.sunovionmedical.com/') continue;
			a.onclick = function(){

				// select the overlay element - and "make it an overlay"
				$('#ok-continue').attr('href', this.href);
				$("#facebox").overlay({

					// custom top position
					top: 272,

					// some expose tweaks suitable for facebox-looking dialogs
					expose: {

						// you might also consider a "transparent" color for the mask
						color: '#000',

						// load mask a little faster
						loadSpeed: 200,

						// highly transparent
						opacity: 0.7
					},

					// disable this for modal dialog-type of overlays
					closeOnClick: false,

					// we want to use the programming API
					api: true

				// load it immediately after the construction
				}).load();
				
				return false;
			}

			linkcount++;
            
		}
	}
	
}


function change_image(src, id){
	document.getElementById(id).src = src;
}

function openStory(id, top){
	if(!top){
		top = 100
	}
	$("#"+id).overlay({

		// custom top position
		top: top,

		// some expose tweaks suitable for facebox-looking dialogs
		expose: {

			// you might also consider a "transparent" color for the mask
			color: '#000',

			// load mask a little faster
			loadSpeed: 200,

			// highly transparent
			opacity: 0.7
		},

		// disable this for modal dialog-type of overlays
		closeOnClick: false,

		// we want to use the programming API
		api: true

	// load it immediately after the construction
	}).load();
	
	return false;
}
