// JavaScript Document
var welcomeContentDiv, employerContentDiv, candidateContentDiv, recruiterContentDiv;
var employerBtn, candidateBtn, recruiterBtn, videographerBtn, showSampleBtn, registerNowBtn;
var employerLearnMoreBtn, candidateLearnMoreBtn, recruiterLearnMoreBtn;

function initPage(){
	welcomeContentDiv 		= getElement("contentWelcome");	
	employerContentDiv 		= getElement("contentEmployer");	
	candidateContentDiv 	= getElement("contentCandidate");		
	recruiterContentDiv 	= getElement("contentRecruiter");	
	
	employerBtn 	= document.getElementById("employerButton");
	candidateBtn 	= document.getElementById("candidateButton");
	recruiterBtn 	= document.getElementById("recruiterButton");
	
	employerLearnMoreBtn 	= document.getElementById("employerLearnMoreButton");
	candidateLearnMoreBtn 	= document.getElementById("candidateLearnMoreButton");
	recruiterLearnMoreBtn 	= document.getElementById("recruiterLearnMoreButton");
	
	showSampleBtn = document.getElementById("showSampleButton");
	//registerNowBtn = document.getElementById("registerNowButton");
	
	//initAuthApp();  
	setHomeButtons();
	//setLearnMoreButtonActions();
	
	var initContent = getQueryValue("initContent");
	showContent(initContent);
}


function initLearnMore(learnmorePage){	
	
	employerBtn 	= document.getElementById("employerButton");
	candidateBtn 	= document.getElementById("candidateButton");
	recruiterBtn 	= document.getElementById("recruiterButton");
	
	registerNowBtn 	= document.getElementById("registerNowButton");
	
	showSampleBtn = document.getElementById("showSampleButton");

	setButtonActions();
	
	switch(learnmorePage){
		case "employer":
			employerBtn.src = "/images/home_for_employers_btn_on.jpg";
			registerNowBtn.onclick = function(){		
				window.location.href = "/employer_registration.html";	
			};
			break;
		case "candidate":
			candidateBtn.src = "/images/home_for_job_seekers_btn_on.jpg";
			registerNowBtn.onclick = function(){		
				window.location.href = "/candidate_registration.html";	
			};
			break;
		case "recruiter":
			recruiterBtn.src = "/images/home_for_recruiters_btn_on.jpg";
			registerNowBtn.onclick = function(){		
				window.location.href = "/recruiter_registration.html";	
			};
			break;			
	}
}


function setHomeButtons(){
	
	//registerNowBtn.onclick = gotoRegistrationPage;
	
	if(showSampleBtn != null) showSampleBtn.onclick = showSampleShow;
	
	employerBtn.onclick = function(){
		showContent("employer");
	};
	candidateBtn.onclick = function(){
		showContent("candidate");
	};
	
	recruiterBtn.onclick = function(){
		showContent("recruiter");
	};
}

function setLearnMoreButtonActions(){
	employerLearnMoreBtn.onclick = function(){		
		window.location.href = "/learn_more_employer.html";	
	};
	candidateLearnMoreBtn.onclick = function(){
		window.location.href = "/learn_more_candidate.html";	
	};
	recruiterLearnMoreBtn.onclick = function(){
		window.location.href = "/learn_more_recruiter.html";	
	};
}

function setButtonActions(){
	
	//registerNowBtn.onclick = gotoRegistrationPage;
	
	if(showSampleBtn != null) showSampleBtn.onclick = showSampleShow;
	
	employerBtn.onclick = function(){
		showHomeContent("employer");
	};
	candidateBtn.onclick = function(){
		showHomeContent("candidate");
	};
	
	recruiterBtn.onclick = function(){
		showHomeContent("recruiter");
	};
}

function showContent(content){
	
	welcomeContentDiv.style.display = 
	employerContentDiv.style.display = 
	candidateContentDiv.style.display = 
	recruiterContentDiv.style.display = "none";
	
	
	employerBtn.src = "/images/home_for_employers_btn_off.jpg";
	candidateBtn.src = "/images/home_for_job_seekers_btn_off.jpg";
	recruiterBtn.src = "/images/home_for_recruiters_btn_off.jpg";
	
	
	switch(content){
		case "employer":
			employerContentDiv.style.display = "block";
			employerBtn.src = "/images/home_for_employers_btn_on.jpg";
			break;
		case "candidate":
			candidateContentDiv.style.display = "block";
			candidateBtn.src = "/images/home_for_job_seekers_btn_on.jpg";
			break;
		case "recruiter":
			recruiterContentDiv.style.display = "block";
			recruiterBtn.src = "/images/home_for_recruiters_btn_on.jpg";
			break;
		default:
			welcomeContentDiv.style.display = "block";
			break;
			
	}
	
}

function buttonRollOver(){
	
}
function buttonRollOut(){
	
}
function gotoRegistrationPage(){
	window.location.href = "/register.html";	
}

function getQueryValue(queryParam){ //Retrieves Query value of query parameter specified in "queryParam"
	var queryString = document.location.search.split("&"); //Array of query variables
	queryString[0] = queryString[0].slice(1, queryString[0].length);
	for(var i=0; i<queryString.length; i++){
		if(queryParam == queryString[i].split("=")[0]){
			var varValue = queryString[i].split("=")[1];
			return varValue;
		}
	}
}

function showHomeContent(content){
	document.location.href = "/?initContent="+content;	
}
function showSampleShow(){	
}