$(document).ready(function() {
	$('.yesonly input:radio').click(function(){
		if($(this).attr('value') == 0) {
			displayPopup($(this).parent().attr('id'));
		}
		if($(this).attr('value') == 1) {
			$("#"+$(this).parent().attr('id')+'-popup').remove();
		}
	})
	$('.noonly input:radio').click(function(){
		if($(this).attr('value') == 1) {
			displayPopup($(this).parent().attr('id'));
		}
		if($(this).attr('value') == 0) {
			$("#"+$(this).parent().attr('id')+'-popup').remove();
		}
	})
	$('.both input:radio').click(function(){
		if($(this).attr('value') == 1) {
			displayPopup($(this).parent().attr('id')+'yes');
		}
		if($(this).attr('value') == 0) {
			displayPopup($(this).parent().attr('id')+'no');
		}
	})
	$('#define-link').click(function(){
		$('#define-popup').remove();
		defineUnemployed();
	})
	$('#public-link').click(function(){
		$('#public-popup').remove();
		definePublic();
	})
	$('#number-link').click(function(){
		$('#number-popup').remove();
		defineNumber();
	})
	$('p.closer').livequery(function() {
		$(this).children('a').click(function(){
			$(this).parent().parent().remove();
			$('#margin').css('margin', "0 auto")
			return false;
		});
	});
	
});


function displayPopup(id) {
	var cssObj = {
		backgroundColor: "#2EA443",
		border: "1px solid #000000",
		color: "#FFFFFF",
	    left: 300,
		padding: "10px",
		position: "absolute",
		textAlign: "center",
        top: 350,
		width: "300px",
		zIndex: 9999
    }
	var messageObj = new Array();
		messageObj['unemployed'] = "<p>You must be unemployed to qualify for Be Work Ready. However, a Work Ready Certificate can still be a valuable tool for moving your career ahead. <a href='/pages/view/how-do-i-get-certified'>Click here</a> for more information.</p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['assessment'] = "<p>You must have earned a Work Ready Certificate to qualify for Be Work Ready. The Work Ready Certificate is a valuable employment tool. <a href='/pages/view/how-do-i-get-certified'>Click here</a> for more information.</p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['reassessment'] = "<p>In order to be eligible for re-assessment incentive you need to have improved your Certificate level.</p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['account'] = "<p>You will need to have an online Work Ready account to qualify for Be Work Ready, and be sure to make it public. This allows employers to verify your Work Ready status. <a target='blank' href='http://www.act.org/myworkkeys/georgia/'>Click here</a> to create your account. You may also download instructions through the link on the right side of this page.</p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['public'] = "<p>In order to be eligible for Be Work Ready, you must share your Work Ready Certificate electronically by clicking on the &ldquo;P&rdquo; circle. This will enable a potential employer to verify results only when you provide your unique Work Ready Certificate number.</p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['number'] = "<p>If your Work Ready Certificate does not include a certificate number on the front, contact ACT at 1-800-WORKKEY (1-800-967-5539) to obtain your certificate number and online username and password.</p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['student'] = "<p>Congratulations on furthering your education. You can still earn a Work Ready Certificate, which is a valuable tool for any job search. To learn more, <a href='/pages/view/how-do-i-get-certified'>click here</a></p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['mail'] = "<p>Please allow four to six weeks to receive your Work Ready Certificate in the mail. If has been longer than that, please visit <a href='http://www.gaworkready.org'>www.gaworkready.org</a> to find your missing certificate.</p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['jobsearch'] = "<p>You must be unemployed and actively looking for work to be eligible for Be Work Ready.</p><p class='closer'><a href='#'>Close</a></p>";
		// these messages are for the reassassment page...
		messageObj['numberyes'] = "<p>You will need your improved Certificate number for the reassessment application.</p><p class='closer'><a href='#'>Close</a></p>";
		messageObj['numberno'] = "<p>If your Work Ready Certificate does not include a certificate number on the front, contact ACT at 1-800-WORKKEY (1-800-967-5539) to obtain your certificate number and online username and password.</p><p class='closer'><a href='#'>Close</a></p>";
	if($('#'+id+'-popup').length == 0) { 
		$('<div>'+ messageObj[id] +'</div>').attr('id', id+'-popup').addClass('popup').css(cssObj).appendTo('.form');
	}
}

function defineUnemployed() {
	var message = "<p>Persons are classified as unemployed if they do not have a job, have actively looked for work in the prior four weeks and are currently available for work. Actively looking for work may consist of any of the following activities:</p>"+
		"<ul><li>Contacting an employer directly or having a job interview</li>"+
			"<li>Contacting a public or private employment agency</li>"+
			"<li>Communicating with friends and/or relatives about job opportunities</li>"+
			"<li>Contacting a school or university employment center</li>"+
			"<li>Sending out resumes or filling out applications</li>"+
			"<li>Placing or answering advertisements</li>"+
			"<li>Checking union or professional registers</li><li>Some other means of active job search</li></ul><p><i>Defined by the U.S. Bureau of Labor Statistics</i></p><p class='closer'><a href='#'>Close</a></p>";
	if($('#define-popup').length == 0) { 
		$('<div class="popup" id="define-popup">'+ message +'</div>').appendTo('.form');
	}
}

function definePublic() {
	var message = "<p>Making your Work Ready account public enables employers to verify your Work Ready Certificate online. To create an online account and make it public, <a target='blank' href='http://www.act.org/myworkkeys/georgia/'>click here</a> and follow the instructions.</p><p class='closer'><a href='#'>Close</a></p>";
	if($('#public-popup').length == 0) { 
		$('<div class="popup" id="public-popup">'+ message +'</div>').appendTo('.form');
	}
}

function defineNumber() {
	var message = "<p>If you earned your Work Ready Certificate prior to Jan. 1, 2009, you receive your certificate number when you create your e-certificate at <a target='blank' href='http://www.act.org/myworkkeys/georgia'>www.act.org/myworkkeys/georgia</a>. If you earned your certificate after Jan. 1, 2009, you certificate number is listed on the front of the cetificate.</p><p class='closer'><a href='#'>Close</a></p>";
	if($('#number-popup').length == 0) { 
		$('<div class="popup" id="number-popup">'+ message +'</div>').appendTo('.form');
	}
}
