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){
	document.getElementById(id).style.display = '';
//	change_image(img_src, img_id);
	window.contentDropdownMouseIsOver = true;
	if(window.contentDrdopdownId && window.contentDrdopdownId != id){
		hideDropdown(true);
	}
	window.contentDrdopdownId = id;
}

function contentDropdownOff(id){
	window.contentDropdownMouseIsOver = false;
//	window.contentDrdopdownImgId = img_id;
//	window.contentDrdopdownImgSrc = img_src;
	setTimeout('hideDropdown(false)', 100);
}

function hideDropdown(force){
	if(!window.contentDropdownMouseIsOver || force){
//		change_image(window.contentDrdopdownImgSrc, window.contentDrdopdownImgId);
		document.getElementById(contentDrdopdownId).style.display = 'none';
	}
}

var tabsStat = 'play';

function startStopSlider(){
	if(window.tabsStat == 'play'){
		$("div.tabs").tabs().stop();
		window.tabsStat = 'stop';
		$("#play-stop-img").attr("src", "/images/butt-stop-active.png");
	}else{
		$("div.tabs").tabs().play();
		window.tabsStat = 'play';
		$("#play-stop-img").attr("src", "/images/butt-stop.png");
	}
}

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;		
			
			start_pos = url.indexOf('.com');
			end_pos = start_pos + 5;
			domain = url.substring(0, end_pos);						
			
			if (start_pos == -1)
			{
			  start_pos2 = url.indexOf('.net');
			  end_pos2 = start_pos2 + 5;
			  domain2 = url.substring(0, end_pos2);				
			  if (domain2 == 'http://nuvola.coresecure.net/') continue;
			}

			if (domain == 'http://www.sunovionmedical.com/') continue;			
			if (domain == 'http://www.sepracormedical.com/') continue;
			if (domain == 'http://nuvola.coresecure.net/') continue;
			if (domain == 'http://www.caringforeverybreath.com/') continue;
			if (domain == 'http://www.sunovionprofile.com/') continue;
			if (domain == 'http://sunovion.force.com/') continue;				
			
			a.onclick = function(){

				// select the overlay element - and "make it an overlay"
				$('#ok-continue').attr('href', this.href);
				$('#ok-continue').attr('target', 'blank');
				$("#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: true,

					// we want to use the programming API
					api: true

				// load it immediately after the construction
				}).load();
				
				return false;
			}

			linkcount++;
            
		}
	}
	
}

function openHealthcare(){
	$("#popup-health").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;
}

function stripVowelAccent(str)
{
 var rExps=[
 {re:/[\xC0-\xC6]/g, ch:'A'},
 {re:/[\xE0-\xE6]/g, ch:'a'},
 {re:/[\xC8-\xCB]/g, ch:'E'},
 {re:/[\xE8-\xEB]/g, ch:'e'},
 {re:/[\xCC-\xCF]/g, ch:'I'},
 {re:/[\xEC-\xEF]/g, ch:'i'},
 {re:/[\xD2-\xD6]/g, ch:'O'},
 {re:/[\xF2-\xF6]/g, ch:'o'},
 {re:/[\xD9-\xDC]/g, ch:'U'},
 {re:/[\xF9-\xFC]/g, ch:'u'},
 {re:/[\xC7]/g, ch:'C'}, 
 {re:/[\xE7]/g, ch:'c'},   
 {re:/[\xD1]/g, ch:'N'},
 {re:/[\xF1]/g, ch:'n'},
 {re:/[\xA3]/g, ch:''},
 {re:/[\n]/g, ch:''},
 {re:/[\r\|\n]/g, ch:''} 
 ];

 for(var i=0, len=rExps.length; i<len; i++)
  str=str.replace(rExps[i].re, rExps[i].ch);

 return str;
}
