// JavaScript Document
function menuHighlight(pgId) {
	var addOnClass	= 'navOn';
	
	if (pgId == 'contactUs') {
		addOnClass	= 'navEndOn';
	}
	
	jQuery('#' + pgId).addClass(addOnClass);
}

function initQTip(tipId, tipTitle, tipText, tipWidth) {
	jQuery('.' + tipId).qtip({
		content: {
			text: tipText,
			title: tipTitle
		},
		
		show: 'mouseover',
		hide: 'mouseout',
		
		style: { 
			width: tipWidth,
			color: 'black',
			border: {
				width: 3,
				radius: 5,
				color: '#D9B900'
			},
			tip: 'topLeft',
			name: 'light' // Inherit from preset style
		},
		
		position: {
			corner: { 
				target: 'bottomMiddle'
			} 
		}
	})
}

function init() {
	jQuery().ready(function() {
		menuHighlight(pgId);
		
		jQuery('.toolTip').each(function(){
			var lastClassName	= jQuery(this).attr('class').split(' ').slice(-1);
			
			initQTip(lastClassName, toolTips[lastClassName][0], toolTips[lastClassName][1], toolTips[lastClassName][2]);
		});
		
		jQuery('#q').example('Search');			
		
		if (qSearch) {
			jQuery('.content').highlight(qSearch);
		}
		
		jQuery("input[@name='srchType']").change(function() {
			jQuery("#frmSearch").attr("action", jQuery(this).val()); 
				
			if (jQuery(this).val() == 'search.php') {
				jQuery('#frmSearch').attr('target', '_self'); 
				jQuery('#frmSearch').attr('method', 'post');
			} else {
				jQuery('#frmSearch').attr('target', '_blank'); 
				jQuery('#frmSearch').attr('method', 'get');
			}
		});
	});
}

function initHome() {
	jQuery().ready(function() {
		jQuery('#p1-more').click(function() {
			jQuery('#span1').show();
			
			jQuery(this).hide();
			return false;
		});
		
		jQuery('#p2-more').click(function() {
			jQuery('#span2').show();
			
			jQuery(this).hide();
			return false;
		});
		
		jQuery('#p3-more').click(function() {
			jQuery('#span3').show();
			
			jQuery(this).hide();
			return false;
		});
		
		jQuery('#p4-more').click(function() {
			jQuery('#span4').show();
			
			jQuery(this).hide();
			return false;
		});
		
		jQuery('#p5-more').click(function() {
			jQuery('#span5').show();
			
			jQuery(this).hide();
			return false;
		});
		
		jQuery('#p6-more').click(function() {
			jQuery('#span6').show();
			
			jQuery(this).hide();
			return false;
		});
	
/*		//LOADING POPUP
		//Click the button event!
		centerPopup();
		//load popup
		loadPopup();
					
		//CLOSING POPUP
		//Click out event!
		jQuery("#backgroundPopup").click(function(){
			disablePopup();
		});
		
		//Press Escape event!
		jQuery(document).keypress(function(e){
			if(e.keyCode==27 && popupStatus==1){
				disablePopup();
			}
		});*/
	});
}

function resetFrm(frmId) {
	var frm	= document.getElementById(frmId);
	
	frm.reset();
	
	initFields();
}

function validSearch() {
	var frm	= document.getElementById('frmSearch');

	if ((frm.q.value == "") || (frm.q.value == "Search") || (frm.q.value.length < 3)) {
		if (frm.q.value == "Search") {
			frm.q.value = "";
		}
		
		alert('Your search criteria must be at least 3 characters.');
		frm.q.focus();
		return;
	} else {
		frm.submit();
	}
}
