// JavaScript Document

$(document).ready(function() {

	$('.rte1').rte({
		css: ['default.css'],
		width: 600,
		height: 300,
		controls_rte: rte_toolbar,
		controls_html: html_toolbar
	});
	
	$('.rte2').rte({
		css: ['default.css'],
		width: 520,
		height: 120,
		controls_rte: rte_toolbar,
		controls_html: html_toolbar
	});

	/* Hide Checkbox */
	$("#ckrememberresume").hide();
	$("#ckincludetel").hide();
	$("#ckincludemail").hide();
	$(".boxexperttips input[type=checkbox]").hide();
	$("#boxcodeother li input").hide();
	$(".boxcheckbox input[type=checkbox]").hide();
	$(".checkbox input[type=checkbox]").hide();
	
	/* Link Resume */
	$("#boxfiles").hide();
	$("#boxcodeother").hide();
	$("#boxcodeemail").hide();

	$("#host_input").hide();

	/* Hide Radio Button */
	$(".radiobutton input[type=radio]").hide();
	
	$("#ckeligibleus").hide();
	
	/* Various Checkbox replacement */
	
	$("#rememberresume").click(function() {
		if ( $(this).attr("class") == "active") {			
			$(this).removeClass("active").addClass("deactive");
			$("#ckrememberresume").attr("checked","");
		}
		else {
			$(this).removeClass("deactive").addClass("active");	
			$("#ckrememberresume").attr("checked","checked");
		}
	});
	
	$("p.checkbox a").click(function() {									 
		if ( $(this).attr("class") == "active") {			
			$(this).removeClass("active").addClass("deactive");			
			$(this).children().attr("checked","");
		}
		else {
			$(this).removeClass("deactive").addClass("active");	
			$(this).children().attr("checked","checked");
		}
	});
	
	$("#iresume .mid-content h3").click(function() {
		if ( $(this).attr("class") == "arrow") {	
			$(this).removeClass("arrow").addClass("arrowdown");	
			$(this).next().hide();
		}
		else {
			$(this).removeClass("arrowdown").addClass("arrow");	
			$(this).next().show();			
		}
	});

	$(".boxexperttips a").click(function() {
		if ( $(this).attr("class") == "active") {
			$(this).removeClass("active").addClass("deactive");
			$(this).children().attr("checked","");
		}
		else {
			$(this).removeClass("deactive").addClass("active");	
			$(this).children().attr("checked","checked");
		}
	});
	
	$("#boxcodeother ul li a").click(function() {
		if ( $(this).attr("class") == "active") {
			$(this).removeClass("active").addClass("deactive");
			$(this).children().attr("checked","");
		}
		else {
			$(this).removeClass("deactive").addClass("active");	
			$(this).children().attr("checked","checked");
		}
	});
	
	$(".boxcheckbox a").click(function() {
		if ( $(this).hasClass("active")) {
			$(this).removeClass("active").addClass("deactive");
			$(this).children().attr("checked","");
		}
		else {
			$(this).removeClass("deactive").addClass("active");	
			$(this).children().attr("checked","checked");
		}
	});
	
	/*$(".boxprofile .checkbox").click(function() {
		if ( $(this).hasClass("active")) {
			$(this).removeClass("active").addClass("deactive");
			$(this).children().attr("checked","");
		}
		else {
			$(this).removeClass("deactive").addClass("active");	
			$(this).children().attr("checked","checked");
		}
	});*/

	$(".checkbox").click(function() {
		if ( $(this).hasClass("active")) {
			$(this).removeClass("active").addClass("deactive");
			$(this).children().attr("checked","");
		}
		else {
			$(this).removeClass("deactive").addClass("active");	
			$(this).children().attr("checked","checked");
		}
	});

	/* Distribution Menu 2 */

	$("#menusendiresume li a").click(function() {
		$(".formsendiresume").hide();		
		$("#"+$(this).attr("class")).show();
		
		$("#menusendiresume li a").removeClass("selected");
		$(this).addClass("selected");		
	});
	
	$("a.mndist").click(function() {
		$("a.mndist").removeClass("selected");
		$(".boxmynetwork").hide();
		
		if ($(this).hasClass("boxsendiresume")) {
			$(".boxsendiresume").addClass("selected");
			$(".boxmynetwork").hide();
			$("#boxiresumehistory").hide();
			$("#boxsendiresume").show();			
		}
		else if ($(this).hasClass("boxiresumehistory")) {
			$(".boxiresumehistory").addClass("selected");
			$("#boxsendiresume").hide();
			$("#boxiresumehistory").show();
		}
		else if ($(this).hasClass("boximportcontact")) {
			$(".boximportcontact").addClass("selected");
			$(".boxmynetwork").hide();
			$("#boximportcontact").show();
		}
		else {
			$(".boxaddcontact").addClass("selected");
			$(".boxmynetwork").hide();
			$("#boxaddcontact").show();
		}
		
	});
	
	/* Your Profile Menu */
	
	$("#fields-profile .btn_next").click(function() {
		$(".boxprofile").hide();	
		$(".boxcontents").hide();	
		
		$("#menuprofile li a").removeClass("selected");
		$("#menucontents li a").removeClass("selected");

		switch ($(this).attr("class")) {
			case "btn_next btn_first type2":		
				$("#field-type2").show();
				$("li.type2 a").addClass("selected");					
			break;		
			case "btn_next type3":				
				$("#field-type3").show();
				$("li.type3 a").addClass("selected");	
			break;
			
			case "btn_next type4":
				$("#field-type4").show();
				$("li.type4 a").addClass("selected");	
			break;
			
			case "btn_next type5":
				$("#field-type5").show();
				$("li.type5 a").addClass("selected");	
			break;
			
			case "btn_next type6":
				$("#field-type6").show();
				$("li.type6 a").addClass("selected");	
			break;
			
			case "btn_next type7":
				$("#field-type7").show();
				$("li.type7 a").addClass("selected");	
			break;
			
			case "btn_next type8":
				$("#field-type8").show();
				$("li.type8 a").addClass("selected");	
			break;
		}
	
	});
	
	$("#fields-profile .btn_back").click(function() {
		$(".boxprofile").hide();
		$(".boxcontents").hide();
		$("#menuprofile li a").removeClass("selected");
		$("#menucontents li a").removeClass("selected");
				
		switch ($(this).attr("class")) {
			case "btn_back type2":		
				$("#field-type2").show();
				$("li.type2 a").addClass("selected");	
			break;		
			case "btn_back type3":				
				$("#field-type3").show();
				$("li.type3 a").addClass("selected");	
			break;
			
			case "btn_back type4":
				$("#field-type4").show();
				$("li.type4 a").addClass("selected");	
			break;
			
			case "btn_back type5":
				$("#field-type5").show();
				$("li.type5 a").addClass("selected");	
			break;
			
			case "btn_back type6":				
				$("#field-type6").show();				
				$("li.type6 a").addClass("selected");	
			break;
			
			case "btn_back type7":
				$("#field-type7").show();
				$("li.type7 a").addClass("selected");	
			break;
			
			case "btn_back type1":
				$("#field-type1").show();
				$("li.type1 a").addClass("selected");	
			break;
		}
	
	});
	
	$("#menuprofile li a").click(function() {
		$(".boxprofile").hide();		
		$("#field-"+$(this).parent().attr("class")).show();
		
		$("#menuprofile li a").removeClass("selected");
		$(this).addClass("selected");		
	});
	
	$("#menucontents li a").click(function() {
		$(".boxcontents").hide();		
		$("#field-"+$(this).parent().attr("class")).show();
		
		$("#menucontents li a").removeClass("selected");
		$(this).addClass("selected");		
	});
	
	$(".contents #submenu li.addnew a").click(function() {
		$("#boxpreview p.linet2").show();		
		$("#boxpreview p.linet1").hide();		
	});

	$(".contents #content-submenu li.mnresume a").click(function() {
		$("#boxpreview p.linet2").hide();		
		$("#boxpreview p.linet1").show();		
	});

	/*
	$(".tbldirectory a").click(function() {
		$(".boxpersonalinformation").show();		
	});
	*/
	$(".tbldirectory a").click(function() {
		$.post("ajaxphp.php?action=personalinfo", {fldval: this.id}, function(data){
			$(".boxpersonalinformation .innerdiv").html(data);
			$(".boxpersonalinformation").show();		
			$(".boxmynetwork").hide();
			$("#boxsendiresume").show();
			$("li.mnviewdirectory a").addClass("selected");	
			$("li.mnsearchdirectory a").removeClass("selected");	
			$("#boxsearchresults h3 a.boxsendiresume").addClass("selected");
			$("#boxsearchresults h3 a.boxiresumehistory").removeClass("selected");
		});
	});
	
	$(".tblresumehistory a").click(function() {
		$.post("ajaxphp.php?action=distinfo", {fldval: this.id}, function(data){
			$(".boxpersonalinformation .innerdiv .innerdiv2").html(data);
			$(".boxpersonalinformation").show();
		});
	});

	/*
	$(".lnk1").click(function() {
		$.post("ajaxphp.php?action=personalinfo", {fldval: this.id}, function(data){
			$("#personalInfoOut").html(data);
			$("#personalInfoOut").show();
		});
	});
	*/
	
	$(".boxpersonalinformation .btnclose").click(function() {
		$(".boxpersonalinformation").hide();
	});

	$(".startsearch .btnsubmit").click(function() {
		$(".startsearch").hide();		
		$(".boxsearch").show();						
	});
	
	$(".btnseeexample").click(function() {
		$("#boxlinkexamples").show();
		
		if ($(this).parent().hasClass("boxcodeother")) { 
			$(".img-blog").addClass("img-center");
			$(".img-email").removeClass("img-center");						
			$(".exampleboxblog a").addClass("selected");
			$(".exampleemail a").removeClass("selected");
		}
		else {
			$(".img-email").addClass("img-center");			
			$(".img-blog").removeClass("img-center");
			$(".exampleemail a").addClass("selected");
			$(".exampleboxblog a").removeClass("selected");
		}
	});
	
	$("#boxlinkexamples .btngoback").click(function() {
		$("#boxlinkexamples").hide();		
	});
	
	$("#boxlinkexamples ul li a").click(function() {
		if ($(this).parent().hasClass("exampleboxblog")) { 
			$(".img-blog").addClass("img-center");
			$(".img-email").removeClass("img-center");						
			$(".exampleboxblog a").addClass("selected");
			$(".exampleemail a").removeClass("selected");
		}
		else {
			$(".img-email").addClass("img-center");			
			$(".img-blog").removeClass("img-center");
			$(".exampleemail a").addClass("selected");
			$(".exampleboxblog a").removeClass("selected");
		}
	});
	
	$(".radiobutton a").click(function() {
		if ($(this).hasClass("unchecked")) {
			$(".radiobutton input").attr("checked","");
			$(".radiobutton a").removeClass("checked").addClass("unchecked");
			$(this).removeClass("unchecked").addClass("checked");
			$(this).children("input").attr("checked","checked");
		}

	});

	$("#resumestatus").click(function() {
		$.post("ajaxphp.php?action=resumestatus", {fldval: $("#resumestatus").val()}, function(data) {
			$("#cur_resumestatus").html(data);
		});
	});

	$("#profilestatus").click(function() {
		$.post("ajaxphp.php?action=profilestatus", {fldval: $("#profilestatus").val()}, function(data) {
			$("#cur_profilestatus").html(data);
		});
	});

	$("#txthostedurl").keyup(function() {
		$.post("ajaxphp.php?action=checkmyspace", {fldval: $("#txthostedurl").val()}, function(data){
			$("#myspace_msg").html(data);
		});
	});
	
	$("#txtmyspace").keyup(function() {
		$.post("ajaxphp.php?action=checkmyspace", {fldval: $("#txtmyspace").val()}, function(data){
			$("#verify_myspace").html(data);
		});
	});
	
	$("#linkiresumeselect").change(function() {
		$.post("ajaxphp.php?action=linkcode", {fldval: $("#linkiresumeselect").val()}, function(data){
			$("#samplebox").html(data);
			$("#boxothertxt").text(data);
			$("#boxcodeother").show();
		});

		$.post("ajaxphp.php?action=myspacelink", {fldval: $("#linkiresumeselect").val()}, function(data){
			$("#boxemailtxt").text(data);
			$("#boxcodeemail").show();
		});
	});
	
});
