// empty form value function
function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

// tooltip2 script written by Alen Grakalic
 this.tooltip3 = function(){	
	/* CONFIG */		
		xOffset = 0;
		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.tooltip3").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip3'>"+ this.t +"</p>");
		$("#tooltip3")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip3").remove();
    });	
	$("a.tooltip3").mousemove(function(e){
		$("#tooltip3")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

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

	this.tooltip = function(){	
		/* CONFIG */		
			xOffset = 10;
			yOffset = 20;		
			// 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("fast");		
	    },
		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");
		});			
	};

	$(document).ready(function() {
	
	//initiate tooltips
		tooltip();
		tooltip2();
			tooltip3();
//bind mouseover/mouseout events to buttons
		$('IMG.more-square').mouseover(function() { this.src= "/wp-content/themes/cc-wp-theme/images/orange.jpg"; }).mouseout(function() { this.src= "/wp-content/themes/cc-wp-theme/images/red.jpg"; });

// case study fade
		$('div.homepage-cs-item').each(function() {
	        $(this).hover(function() {
	  $('img', this).stop().animate({ opacity: 0.5 }, 100);
				$(this).css({'background' : 'url(/wp-content/themes/cc-wp-theme/images/khaki.jpg)', 'color' : '#cc0000!important'}).fadeTo(100, 0.8);
	       	},
	       function() {
	           $('img', this).stop().animate({ opacity: 1.0 }, 100);
		$(this).css("background", "url(/wp-content/themes/cc-wp-theme/images/yel.jpg)").fadeTo(100, 1.0);
	       });
	    });

//home picks fade
	    $('div.canright-pick').each(function() {
	        $(this).hover(function() {

	            $('img', this).stop().animate({ opacity: .5 }, 0);
	        },
	       function() {
	           $('img', this).stop().animate({ opacity: 1.0 }, 0);
	       });
	    });

//Hide (Collapse) the toggle containers on load - used on Our Process page
		$(".toggle_container").hide(); 

//Slide up and down on click
		$("div.trigger").click(function(){
			$(this).next(".toggle_container").slideToggle("slow");
		});
		$("div.triggerc").click(function(){
			$(this).parent(".toggle_container").slideToggle("slow");
		});	
	});




// main newsletter sign up validatation

	function validate() {
	test=document.signupform.email.value;
	if (test=='Enter Email Address') {
	alert('Oops, looks like we didn\'t get your email. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!');
	return false;
	}
	else if(test==''){alert('Oops, looks like we didn\'t get your email. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!'); return false;}
	alert('Thanks for Signing Up!');
	document.signupform.submit();

	}
// full newsletter sign up validatation
	function validatefull() {
	test=document.signupform.first_name.value;

	if (test=='') {
	alert('Oops, looks like we didn\'t get your first name. \n\nPlease write your first name in the box and click the \"Sign Up\" button, thanks!');
	return false;
	}

	test=document.signupform.last_name.value;
	if (test=='') {
	alert('Oops, looks like we didn\'t get your last name. \n\nPlease write your last name in the box and click the \"Sign Up\" button, thanks!');
	return false;
	}

	test=document.signupform.email.value;
	if (test=='') {
	alert('Oops, looks like we didn\'t get your email. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!');
	return false;
	}

	alert('Thanks for Signing Up!');
	document.signupform.submit();
	}

// white paper download validatation
	function validatefullwp() {

		test=document.signupform.first_name.value;

		if (test=='') {
		alert('Oops, looks like we didn\'t get your first name. \n\nPlease write your first name in the box and click the \"Sign Up\" button, thanks!');
		return false;
		}

		test=document.signupform.last_name.value;
		if (test=='') {
		alert('Oops, looks like we didn\'t get your last name. \n\nPlease write your last name in the box and click the \"Sign Up\" button, thanks!');
		return false;
		}

		test=document.signupform.email.value;
		if (test=='') {
		alert('Oops, looks like we didn\'t get your email. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!');
		return false;
		}


	test=document.signupform.company.value;
	if (test=='') {
	alert('Oops, looks like we didn\'t get your company name. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!');
	return false;
	}



	test=document.signupform.phone.value;
	if (test=='') {
	alert('Oops, looks like we didn\'t get your phone number. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!');
	return false;
	}
	alert('Thanks, you should receive the link to download in your inbox shortly.');
	this.signupform.submit();
	}


// Treasury Contact validatation
	function validatetreasury() {

		/*test=document.signupform.first_name.value;

		if (test=='') {
		alert('Oops, looks like we didn\'t get your first name. \n\nPlease write your first name in the box and click the \"Sign Up\" button, thanks!');
		return false;
		}

		test=document.signupform.last_name.value;
		if (test=='') {
		alert('Oops, looks like we didn\'t get your last name. \n\nPlease write your last name in the box and click the \"Sign Up\" button, thanks!');
		return false;
		}

		test=document.signupform.email.value;
		if (test=='') {
		alert('Oops, looks like we didn\'t get your email. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!');
		return false;
		}*/


	/*test=document.signupform.company.value;
	if (test=='') {
	alert('Oops, looks like we didn\'t get your company name. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!');
	return false;
	}



	test=document.signupform.phone.value;
	if (test=='') {
	alert('Oops, looks like we didn\'t get your phone number. \n\nPlease write your email address in the box and click the \"Sign Up\" button, thanks!');
	return false;
	}*/
	alert('Thanks, you should receive the link to download in your inbox shortly.');
	this.signupform.submit();
	}



