/**
 * @author Preetham
 */

var loginPageForCandidate = "canLogin.html";

$(document).ready(function(){
	var candId = getQueryVariable("key");
	
	if(candId) {
		$("#accAgreeBtnCont").show();

		$("#accAgreeBtn").click(function(){
			candId = getQueryVariable("key");
			JOPTDWRGateway.activateAccount(candId,
			{ 	callback:function(data){
					if(data == true) {
						alert("Successfully activated the account. Please enter your id and password in the login page to enter the site.");			
						document.location = loginPageForCandidate;
					}else {
						alert("Sorry. We could not locate your profile to activate the account.Please see the email for instructions.");			
					}
					
					
				},errorHandler:function(errorString, exception){
					alert("Sorry An error has occurred. Please contact us with the error message for assitance." + errorString);
				}
			});
	
		});

	}//end of if

	
});

function getQueryVariable(variable){
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
}


