$(document).ready(function() {

	var rootpath = '/';
	$('.table_user_form input[type=text]').mouseover(function(){
		$(this).focus();
		$(this).val($(this).val());
	});
	$('.table_user_form textarea').mouseover(function(){
		$(this).focus();
		$(this).val($(this).val());
	});



	$('#ploginform').submit(function(){
		//begin
		$('#ploingresult').html('loading...');
		//get var
		var str_form_name = $('#form_name').val();
		var str_form_pwd = $('#form_pwd').val();
		var str_login_type = $('#login_type').val();
		var str_continu = $('#continu').val();
		var str_pageself = $('#pageself').val();
		var oform = $('#ploginform');
		//check var
		if(str_form_name == '' || str_form_pwd == '' || str_login_type == '' ){
			$('#ploingresult').html('录入不完整。');
			return false;
		}else if(!(str_login_type=='1' ||str_login_type=='2' ||str_login_type=='3')  ){
			$('#ploingresult').html('请选择登陆类型。');
			return false;
		}



		//post
		$.getJSON(rootpath+"u_login.php",{form_name:str_form_name,form_pwd:str_form_pwd,login_type:str_login_type,continu:str_continu,pageself:str_pageself,r:Math.random()},function(json){
			//			$.each(data, function(i,item){
			//				alert(item);
			//			});
			//		alert("JSON Data: " + data.url);


			if(json.result_code == '1'){
				alert(json.result);
//				window.location.href = json.url;
				window.location.href = str_pageself;
			}else{
				//$('#ploingresult').html(json.result);
				alert(json.result);
			}
			$('#ploingresult').html('');

		});
		
		return false;
		//
	});

	$('#resume_educational_background_zh_clone').click(function(){
		//		$('.resume_educational_background_table:last').clone().insertBefore($('#resume_educational_background_table_more'));
		$('#resume_educational_background_table_more').before('<table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"><tr><td bgcolor="#EFEFEF">时间段：<input name="resume_educational_background[time][]" type="text" id="resume_educational_background[time][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">学&nbsp;&nbsp;校：<input name="resume_educational_background[school][]" type="text" id="resume_educational_background[school][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">专&nbsp;&nbsp;业：<input name="resume_educational_background[major][]" type="text" id="resume_educational_background[major][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td></tr><tr><td bgcolor="#EFEFEF">学&nbsp;&nbsp;历：<input name="resume_educational_background[education][]" type="text" id="resume_educational_background[education][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td colspan="2" bgcolor="#EFEFEF">在校成就：<input name="resume_educational_background[accomplish][]" type="text" id="resume_educational_background[accomplish][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="58"></td></tr></table><table width="95%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>');
	});
	$('#resume_educational_background_zh_clone').click();

	$('#resume_project_experience_zh_clone').click(function(){
		var str = '<table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"><tr><td bgcolor="#EFEFEF">时&nbsp;间&nbsp;段：<input name="resume_project_experience[time][]" type="text" id="resume_project_experience[time][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">项目名称：<input name="resume_project_experience[name][]" type="text" id="resume_project_experience[name][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="30"></td></tr><tr><td colspan="2" bgcolor="#EFEFEF">项目成就：<input name="resume_project_experience[accomplish][]" type="text" id="resume_project_experience[accomplish][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="90"></td></tr></table><table width="95%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>';
		$('#resume_project_experience_clone_table_more').before(str);
	});
	$('#resume_project_experience_zh_clone').click();
	//
	$('#resume_work_experienc_zh_clone').click(function(){
		var str = '<table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"><tr><td bgcolor="#EFEFEF">时间段：<input name="resume_work_experienc[time][]" type="text" id="resume_work_experienc[time][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">公司：<input name="resume_work_experienc[company][]" type="text" id="resume_work_experienc[company][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">职位：<input name="resume_work_experienc[office][]" type="text" id="resume_work_experienc[office][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td></tr><tr><td colspan="3" bgcolor="#EFEFEF">工作职责/工作成就：</td></tr><tr><td colspan="3" bgcolor="#EFEFEF"><textarea  name=resume_work_experienc[accomplish][] cols=80 rows=2 wrap=VIRTUAL id="resume_work_experienc[accomplish][]"></textarea></td></tr></table><table width="95%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>';
		$('#resume_work_experienc_clone_more').before(str);
	});
	$('#resume_work_experienc_zh_clone').click();


	$('#resume_train_zh_clone').click(function(){
		var str = '<table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td bgcolor="#EFEFEF">时间段： <input name="resume_train[time][]" type="text" id="resume_train[time][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td> <td bgcolor="#EFEFEF">证书名称： <input name="resume_train[name][]" type="text" id="resume_train[name][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td> <td bgcolor="#EFEFEF">发证机构： <input name="resume_train[org][]" type="text" id="resume_train[org][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td> </tr> </table> <table width="95%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>&nbsp;</td> </tr> </table>';
		$('#resume_train_clone_more').before(str);
	});
	$('#resume_train_zh_clone').click();
	//
	$('#resume_educational_background_en_clone').click(function(){
		//		$('.resume_educational_background_table:last').clone().insertBefore($('#resume_educational_background_table_more'));
		$('#resume_educational_background_table_more').before('<table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"><tr><td bgcolor="#EFEFEF">时间段：<input name="resume_educational_background[time][]" type="text" id="resume_educational_background[time][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">学&nbsp;&nbsp;校：<input name="resume_educational_background[school][]" type="text" id="resume_educational_background[school][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">专&nbsp;&nbsp;业：<input name="resume_educational_background[major][]" type="text" id="resume_educational_background[major][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td></tr><tr><td bgcolor="#EFEFEF">学&nbsp;&nbsp;历：<input name="resume_educational_background[education][]" type="text" id="resume_educational_background[education][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td colspan="2" bgcolor="#EFEFEF">在校成就：<input name="resume_educational_background[accomplish][]" type="text" id="resume_educational_background[accomplish][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="58"></td></tr></table><table width="95%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>');
	});
	$('#resume_educational_background_en_clone').click();

	$('#resume_project_experience_en_clone').click(function(){
		var str = '<table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"><tr><td bgcolor="#EFEFEF">时&nbsp;间&nbsp;段：<input name="resume_project_experience[time][]" type="text" id="resume_project_experience[time][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">项目名称：<input name="resume_project_experience[name][]" type="text" id="resume_project_experience[name][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="30"></td></tr><tr><td colspan="2" bgcolor="#EFEFEF">项目成就：<input name="resume_project_experience[accomplish][]" type="text" id="resume_project_experience[accomplish][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="90"></td></tr></table><table width="95%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>';
		$('#resume_project_experience_clone_table_more').before(str);
	});
	$('#resume_project_experience_en_clone').click();
	//
	$('#resume_work_experienc_en_clone').click(function(){
		var str = '<table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"><tr><td bgcolor="#EFEFEF">时间段：<input name="resume_work_experienc[time][]" type="text" id="resume_work_experienc[time][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">公司：<input name="resume_work_experienc[company][]" type="text" id="resume_work_experienc[company][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td><td bgcolor="#EFEFEF">职位：<input name="resume_work_experienc[office][]" type="text" id="resume_work_experienc[office][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td></tr><tr><td colspan="3" bgcolor="#EFEFEF">工作职责/工作成就：</td></tr><tr><td colspan="3" bgcolor="#EFEFEF"><textarea  name=resume_work_experienc[accomplish][] cols=80 rows=2 wrap=VIRTUAL id="resume_work_experienc[accomplish][]"></textarea></td></tr></table><table width="95%" border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;</td></tr></table>';
		$('#resume_work_experienc_clone_more').before(str);
	});
	$('#resume_work_experienc_en_clone').click();


	$('#resume_train_en_clone').click(function(){
		var str = '<table width="95%" border="0" cellpadding="5" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td bgcolor="#EFEFEF">时间段： <input name="resume_train[time][]" type="text" id="resume_train[time][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td> <td bgcolor="#EFEFEF">证书名称： <input name="resume_train[name][]" type="text" id="resume_train[name][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td> <td bgcolor="#EFEFEF">发证机构： <input name="resume_train[org][]" type="text" id="resume_train[org][]" style="background-color: #ffffff; border: 1px solid #CACBCD" size="17"></td> </tr> </table> <table width="95%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>&nbsp;</td> </tr> </table>';
		$('#resume_train_clone_more').before(str);
	});
	$('#resume_train_en_clone').click();


	$('#pregistersubmit').click(function(){
		var str_login_type = $('#login_type').val();
		switch (str_login_type) {

			case '1':
			alert('学生不提供注册，谢谢。');
			break;
			case '2':
			window.location.href=rootpath+'u_enterprise_register.php';
			break;
			case '3':
			window.location.href=rootpath+'u_instructor_register.php';
			break;
			default :
			alert('请选择注册的类型。');
			break;
		}
	});

	$('.more_subject_intro').click(function(){
		$('.sji').toggle();
	});
	
	$('#keyword').mouseover(function(){
		var v = $(this).val();
		if(v == '请输入关键字'){
			$(this).val('');
			$(this).focus();
		}

	});
});