
// Client Login

function initClientLogin(){

	$(".clientLoginBtn").click(function(){
		$("#clientLogin").slideToggle(300);
		$(this).toggleClass("active");
		return false;
	});
	
	$(".closeBox").click(function(){
		$("#clientLogin").slideToggle(300);
		$(this).toggleClass("active"); return false;
	});
	
	 
}


//------------------------------------------------------------------------------------------------//	
			
// Input Field
function initInputFields() {
	$('input[type="text"]').addClass("idleField");
	$('input[type="text"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
}	


//------------------------------------------------------------------------------------------------//


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 40;
		yOffset = 0;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn(400);		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


//------------------------------------------------------------------------------------------------//

function getURLParam(strParamName) {
	var paramValue = "";
	var strHref = window.location.href;
	
	if ( strHref.indexOf("?") > -1 ){
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ) {
			if ( 
				aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
				var aParam = aQueryString[iParam].split("=");
				paramValue = aParam[1];
				break;
			}
		}
	}
	
	return unescape(paramValue);
}


//------------------------------------------------------------------------------------------------//	

$(document).ready(function() {
	// Collapsable Menu
	$('#nav .main').collapsor({sublevelElement:'ul:not(.selected)', speed: 300});
	
	$('#fadeInDelay1').hide().fadeIn(2000); // Fade In Image 1
	$("#fadeInDelay2").hide().fadeTo(500, 1).fadeIn(2000); // Fade In Image 2
	$("#fadeInDelay3").hide().fadeTo(1000, 1).fadeIn(2000); // Fade In Image 3

	initClientLogin();
	initInputFields();
	tooltip();

});


//------------------------------------------------------------------------------------------------//	

$(function () {
		var tabs = [];
		var tabContainers = [];
		
		var isAnimating = false
		
		$('ul.tabNavigation a').each(function () {
			tabs.push(this);
			tabContainers.push($(this.hash).get(0));
		});
		
		$(tabContainers).filter(':not(:first)').hide();
		
		$(tabs).click(function () {
			
			if (isAnimating == false){
			
				isAnimating = true;
				
				$this = $(this);
				$newTab = $(tabContainers).filter(this.hash);
			
				// hide all tabs
				$(tabContainers).filter('.selected').fadeOut(500, function(){
					$(tabContainers).hide();
					$newTab.fadeIn(1000);
					isAnimating = false;
				});
				
				// set up the selected class
				$(tabs).removeClass('selected');
				$(tabContainers).removeClass('selected');
				$(this).addClass('selected');
				$newTab.addClass('selected');
			}
			
			return false;
		});
	});



//------------------------------------------------------------------------------------------------//	


$(function() {
		
			$('#mainRollovers img').animate( {
			"opacity" : 1
			});
			
			$('#mainRollovers img').hover(function() {
				$(this).stop().animate({ "opacity" : .6 });
				}, function() {
				$(this).stop().animate({ "opacity" : 1});
			});
		
		});



