﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
var playerStatus = 0;
var $j = jQuery.noConflict();

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$j("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup").fadeIn("slow");
		$j("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){

	if(playerStatus==1) {
		$j("#video_player").html('');	
		playerStatus = 0;
	}

	//disables popup only if it is enabled	
	if(popupStatus==1){
		$j("#backgroundPopup").fadeOut("slow");
		$j("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}	
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#popupContact").height();
	var popupWidth = $j("#popupContact").width();
	//centering
	$j("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$j("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$j(document).ready(function(){

	if($j("#expand_container").length > 0){
		$j('#expand_container').hide();
	}	

	//LOADING POPUP
	//Click the button event!
	$j("#button").click(function(){		
		if($j("#investor_message_section").length > 0){
			$j("#investor_message_section").hide();
			$j("#investor_name").attr("value", "");
			$j("#investor_company").attr("value", "");
			$j("#investor_email").attr("value", "");			
			/*$j("#become_a_client").hide();
			$j("#institutional_investor").show();
			$j("#popupContact").attr("style", "width:700px;");*/
		}
		if($j("#whatsnew_message_section").length > 0){
			$j("#whatsnew_message_section").hide();
			$j("#general_comments").attr("value", "");
			$j("#like_best_dcaf").attr("value", "");
			$j("#improve_dcaf").attr("value", "");
			$j("#problem_found").attr("value", "");
			$j("#followup_name").attr("value", "");
			$j("#followup_company").attr("value", "");
			$j("#followup_email").attr("value", "");
			$j("#followup_phone").attr("value", "");
			$j("#whatsnew_yes").hide();
			$j("#whatsnew_no").show();
			$('feedback_check_no').checked = true;
			$j("#follow_up_main_container").hide();
			$('follow_up_no').checked = true;
			/*$j("#become_a_client").hide();
			$j("#popup_container").show();
			$j("#popupContact").attr("style", "width:700px;");*/
		}
		if($j("#support_message_section").length > 0){
			$j("#support_message_section").hide();
			$j("#general_comments").attr("value", "");
			$j("#like_best_dcaf").attr("value", "");
			$j("#improve_dcaf").attr("value", "");
			$j("#problem_found").attr("value", "");
			$j("#followup_name").attr("value", "");
			$j("#followup_company").attr("value", "");
			$j("#followup_email").attr("value", "");
			$j("#followup_phone").attr("value", "");
			$j("#support_yes").hide();
			$j("#support_no").show();
			$('feedback_check_no').checked = true;
			$j("#follow_up_main_container").hide();
			$('follow_up_no').checked = true;
			/*$j("#become_a_client").hide();
			$j("#popup_container").show();
			$j("#popupContact").attr("style", "width:700px;");*/
		}
		if($j("#sitefeedback_message_section").length > 0){
			$j("#sitefeedback_message_section").hide();
			$j("#general_comments").attr("value", "");
			$j("#like_best_dcaf").attr("value", "");
			$j("#improve_dcaf").attr("value", "");
			$j("#problem_found").attr("value", "");
			$j("#followup_name").attr("value", "");
			$j("#followup_company").attr("value", "");
			$j("#followup_email").attr("value", "");
			$j("#followup_phone").attr("value", "");
			$j("#sitefeedback_yes").hide();
			$j("#sitefeedback_no").show();
			$('feedback_check_no').checked = true;
			$j("#follow_up_main_container").hide();
			$('follow_up_no').checked = true;
			/*$j("#become_a_client").hide();
			$j("#popup_container").show();
			$j("#popupContact").attr("style", "width:700px;");*/
		}
		if($j("#view_demo_popup").length > 0){
			$j("#popupContact").attr("style", "width:700px;");
			$j("#view_demo_message_section").hide();
			$j("#forgot_password").hide();
			$j("#other").hide();
			$j("#view_demo_popup").show();
			$j("#first_name").attr("value", "");
			$j("#last_name").attr("value", "");
			$j("#email_address").attr("value", "");
			$j("#company").attr("value", "");
			$j("#phone").attr("value", "");
			$j("#address1").attr("value", "");
			$j("#address2").attr("value", "");
			$j("#city").attr("value", "");
			$j("#state").attr("value", "");
			$j("#postal_code").attr("value", "");
			$j("#other").attr("value", "");
			$('reporting_company').checked = true;
			$('single_registrant').checked = true;
		}
		/*if($j("#fee_schedule").length > 0){
			$j("#popupContact").attr("style", "width:700px;");
			$j("#fee_schedule").show();
			$j("#become_a_client").hide();
		}
		if($j("#md_and_a").length > 0){
			$j("#popupContact").attr("style", "width:700px;");
			$j("#md_and_a").show();
			$j("#become_a_client").hide();
		}*/
		if($j("#news_and_events").length > 0){
			$j("#popupContact").attr("style", "width:800px;");
			$j("#news_and_events").show();
			$j("#press_releases").hide();
		}

		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});

	//Click the button event!
	$j("#button1").click(function(){
		
		if($j("#forgot_password").length > 0){
			$j("#popupContact").attr("style", "width:400px;");
			$j("#popup_trial").hide();
			$j("#popup_demo").hide();
			$j("#forgot_message_section").hide();
			$j("#email").attr("value", "");
			$j("#email").attr("style", "border:1px solid #c5c5c5;width:250px;");
			$j("#email_label").attr("style", "color:#636363;");
			$j("#forgot_password").show();
			
			/*$j("#become_a_client").hide();*/
		}

		if($j("#news_and_events").length > 0){
			$j("#popupContact").attr("style", "width:800px;");
			$j("#news_and_events").hide();
			$j("#press_releases").show();
		}

		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});

	//Click the button event!
	$j("#button2").click(function(){
		$j("#popupContact").attr("style", "width:700px;");
		$j("#forgot_password").hide();
		$j("#become_a_client").hide();
		$j("#popup_demo").hide();		
		$j("#popup_trial").show();
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});

	//Click the button event!
	$j("#button3").click(function(){
		$j("#popupContact").attr("style", "width:700px;");
		$j("#forgot_password").hide();
		$j("#become_a_client").hide();
		$j("#popup_trial").hide();
		$j("#popup_demo").show();
		$j("#video_player").html('<object width="510" height="344"><param name="movie" value="http://www.youtube.com/v/zsx0OpBcUWk?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/zsx0OpBcUWk?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="510" height="344"></embed></object>');			
		playerStatus = 1;
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
	
	$j("#popup_free_trial_btn").click(function(){
		disablePopup();
		$j("#popupContact").attr("style", "width:700px;");
		$j("#forgot_password").hide();
		$j("#become_a_client").hide();
		$j("#popup_demo").hide();		
		$j("#popup_trial").show();
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
	
	$j("#popup_fee_schedule").click(function() {
		$j("#fee_multiple_reporting").hide();
		$j("#become_a_client").hide();
		$j("#fee_schedule").show();
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	 });
	
	$j("#popup_multiple_reporting").click(function(){
		$j("#fee_schedule").hide();
		$j("#become_a_client").hide();
		$j("#fee_multiple_reporting").show();
		//centering with css
		centerPopup();
		//load popup
		loadPopup();		
	});
				
	//CLOSING POPUP
	//Click the x event!
	$j("#popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$j("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$j(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});

function newsletter_expand(elm){
	if(elm == 'e'){
		$j('#expand_container').show();
		$j('#expand_e').hide();
		$j('#close_c').show();
	} else {
		$j('#expand_container').hide();
		$j('#expand_e').show();
		$j('#close_c').hide();
	}
}

