//-- Go Go Leadform Submission
function validate_short_form() {
	var error_msg = '';
	if( document.getElementById('first_name').value == ''){
		error_msg += 'You must enter your First Name.\n';
		document.getElementById('lbl_first_name').style.color = '#f00';
	}else{
		document.getElementById('lbl_first_name').style.color = '#4D4D4D';
	}
	if( document.getElementById('company').value == ''){
		error_msg += 'You must enter your Company Name.\n';
		document.getElementById('lbl_company').style.color = '#f00';
	}else{
		document.getElementById('lbl_company').style.color = '#4D4D4D';
	}
	if( document.getElementById('phone').value == ''){
		error_msg += 'You must enter your Phone Number.\n';
		document.getElementById('lbl_phone').style.color = '#f00';
	}else{
		document.getElementById('lbl_phone').style.color = '#4D4D4D';
	}
	if( document.getElementById('email').value == ''){
		error_msg += 'You must enter your Email Address.\n';
		document.getElementById('lbl_email').style.color = '#f00';
	}else{
		document.getElementById('lbl_email').style.color = '#4D4D4D';
	}

	if( error_msg != '' ){
		alert(error_msg);
		return false;
	}else{
		// post to new shadowbox pg.
		var hxm_source = ( document.getElementById('hxm_source') ) ? document.getElementById('hxm_source').value : 'unknown-corp-page';
		var firstname  = document.getElementById('first_name').value;
		var company    = document.getElementById('company').value;
		var phone      = document.getElementById('phone').value;
		var email      = document.getElementById('email').value;
		var pdlid      = ( document.getElementById('pdlid') ) ? document.getElementById('pdlid').value : '';
		var url        = '';
		
		isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
		if( isIE6 ){
			url  = 'http://promo.advancedmd.com/lp_v4/landing_page.php?source=' + escape( hxm_source ) + '&process_step=1';
			url += '&firstname=' + escape( firstname );
			url += '&company=' + escape( company );
			url += '&phone=' + escape( phone );
			url += '&email=' + escape( email );
			
			// reset fields
			document.getElementById('first_name').value = '';
			document.getElementById('company').value = '';
			document.getElementById('phone').value = '';
			document.getElementById('email').value = '';
			
			//alert( 'URL: ' + url );
			
			// send user to form.
			location.href = url;
		}else{
			url  = '/hxm_v4/hxm_form_passthrough.php?process_step=1';
			url += '&hxm_source=' + escape( hxm_source );
			url += '&firstname=' + escape( firstname );
			url += '&company=' + escape( company );
			url += '&phone=' + escape( phone );
			url += '&email=' + escape( email );
			
			//alert( 'URL: ' + url );
			
			Shadowbox.init({ players: ["html","iframe"] });
			Shadowbox.open({player: "iframe", content: url, height: 500 , width: 934});
			
			// reset fields
			document.getElementById('first_name').value = '';
			document.getElementById('company').value = '';
			document.getElementById('phone').value = '';
			document.getElementById('email').value = '';
		}
	}
	return false;
}  
//-- Go Go Mini Refer-a-friend
function open_referral_form() {
	var url = '/hxm_v4/hxm_referral_passthrough.php';
	Shadowbox.init({ players: ["html","iframe"] });
	Shadowbox.open({player: "iframe", content: url, height: 500 , width: 934});
	return false;
}

//-- Go Go Pg1 Form
function open_lead_form() {
    var hxm_ehr_source = ( document.getElementById('hxm_ehr_source') ) ? document.getElementById('hxm_ehr_source').value : 'unknown-leadform-page';
    var url = '/hxm_v4/hxm_form_passthrough.php?hxm_source='+escape( hxm_ehr_source );
    Shadowbox.init({ players: ["html","iframe"] });
    Shadowbox.open({player: "iframe", content: url, height: 500 , width: 934});
    return false;
}

//-- Go Go Download Registration
function open_player ( url, file_type, height, width, title ) {
	if( height == 0 || width == 0 ){
		Shadowbox.open({content: url, player: file_type, title: title});
	}else{
		Shadowbox.open({content: url,	player: file_type, title: title, height: height, width: width});
	}
}
//-- Go Go Download Pardot Content
function open_asset( key, assetTitle ) {
	var aTitle = ((assetTitle == "") ? "" : assetTitle);
	var url = '/hxm_v4/hxm_asset_passthrough.php?pdlid=' + key;
	Shadowbox.init({ players: ["html","iframe", "flv", "img", "qt", "swf", "wmv"] });
	Shadowbox.open({player: "iframe", content: url, height: 500 , width: 934, title: aTitle});
}

//-- Go Go News Ticker on Homepage
var timer = null;

function setupTicker(duration) {
	
	if (duration == undefined) {
		duration = 6000;
	}
	
	clearTimeout(timer);
	
	timer = setTimeout('rotateTicker()', duration);
}

function rotateTicker() {
	
	if ($('#ticker .tick').length > 1) {
		$('#ticker .tick.select').fadeOut(
			250,
			function() {
				
				$(this).removeClass('select');
				
				if ($(this).attr('id') == $('#ticker .tick:last').attr('id')) {
					$('#ticker .tick:first').fadeIn(250).addClass('select');
				}
				else {
					$(this).next().fadeIn(250).addClass('select');
				}
			}
		);
		
		setupTicker();
	}
}

//-- Go Go Shadowbox
Shadowbox.init({
	players: ['swf', 'img', 'html', 'flv', 'iframe', 'qt', 'wmp'],
	overlayOpacity: '0.5',
	displayNav: true
});

//-- Go Go jQuery
$(document).ready(function() {

		$("table tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
		$("table tr:odd").addClass("odd");
		$("ul.tabs").tabs("div.panes > div.section");
		$(".tooltip[title]").tooltip({
			tip: "#tip", 
			position:"top center", 
			offset:[0, 65],
			onShow: function(){ $("#tip").append("<div class=\"top\"></div>");},
			events: {
				def: "mouseover, mouseout",
				tooltip: ""
			}	
		});
	
		$("div.section-collapse").expandAll({trigger:".expand"});
		$(".section-collapse .expand").toggler({method:"slideToggle",speed:300});

		if ($('#ticker').length > 0) {
			setupTicker();
		}
		// Shadowbox CSS warning fix
		$('#sb-overlay').css({
			height: document.documentElement.clientHeight + 'px'
		});
		//
		$('#med-soft .ex').hide();
		$('#med-soft a:not(.ex a)').click(
			function() {
				var span = $(this).children('span');
				//
				if ($(span).html() == '+') {
					$(this).siblings('.ex').slideDown(250);
					$(span).html('-');
				}
				else {
					$(this).siblings('.ex').slideUp(250);
					$(span).html('+');
				}
				return false;
			}
		);
		// Homepage Tabs
		if ($('#tabs').length > 0) {
			// Tabs
			$('#tabs #tab-links .tab-link a').click(
				function() {
					
					var element = $(this);
					
					/*
if ($('#tabs #tab-boxes .tab-box .tab-content.select').hasClass('select')) {
						
						$('#tabs #tab-boxes .tab-box .tab-intro').find('.more').fadeIn(250);
						$('#tabs #tab-boxes .tab-box .tab-intro').find('.less').fadeOut(250);
						
						$('#tabs #tab-boxes .tab-box .tab-content.select').slideUp(
							250,
							function() {
								$(this).removeClass('select');
								
								$('#tabs #tab-links').find('.tab-link').removeClass('select');
								$(element).parent('.tab-link').addClass('select');
								
								$('#tabs #tab-boxes').find('.tab-box').removeClass('select');
								$($(element).attr('href')).addClass('select');
							}
						);
					}
					else {
*/
						
						$('#tabs #tab-links').find('.tab-link').removeClass('select');
						$(element).parent('.tab-link').addClass('select');
						
						$('#tabs #tab-boxes').find('.tab-box').removeClass('select');
						$($(element).attr('href')).addClass('select');
					/* } */
					
					return false;
				}
			);
			// More/Less
			$('#tabs #tab-boxes .tab-box .tab-intro a').click(
				function() {
					if ($(this).hasClass('more')) {
						$('#tabs #tab-boxes .tab-box .tab-intro a.more').hide();
						$('#tabs #tab-boxes .tab-box .tab-intro a.less').show();
						$(this).closest('#tab-boxes').find('.tab-content').slideToggle(
							250,
							function() {
								$(this).closest('#tab-boxes').find('.tab-content').css("display", "block");
							}
						);
					} else {
						$('#tabs #tab-boxes .tab-box .tab-intro a.more').show();
						$('#tabs #tab-boxes .tab-box .tab-intro a.less').hide();
						$(this).closest('#tab-boxes').find('.tab-content').slideToggle(
							250,
							function() {
								$(this).closest('#tab-boxes').find('.tab-content').css("display", "none");
							}
						);
					}
					return false;
				}
			);
		}
		// Show/Hide
		$('.show-hide').hide();
		$('a.more').click(function() {
		
				$(this).parent().next('.show-hide').slideToggle('fast');
				
				if ($(this).text().match(/\-/g)) {
					$(this).text($(this).text().replace('-', '+'));
				}
				else {
					$(this).text($(this).text().replace('+', '-'));
				}
	
		
		});
		// Navigation
		$('#navigation > li').hover(
			function() {
				var items = $('#navigation > li');
				for (var i = 0; i < $(items).length; i++) {
					if ($(items[i]).hasClass($(this).attr('class'))) {
						break;
					}
					else {
						$(items[i]).addClass('before');
					}
				}
				$(this).addClass('select');
			},
			function() {
				$('#navigation').find('li').removeClass('select').removeClass('before');
			}
		);
		//
		$('#site-map div').hover(
			function() {
				$(this).addClass('select');
			},
			function() {
				$('#site-map').find('div').removeClass('select');
			}
		);
						
});