/*---------------------------Design by Digital Marketing Solution------------------------
Author: Mr Dung Phan
Email: info@digitalmarketingsolution.com
----------------------------------------------------------------------------------------*/
/*----------------------------Define message--------------------------------------------*/
//form login
var req_user = "Username must be defined!";
var req_pass = "Password must be defined!";
var err_user = "invalid username! Please try again";
var err_pass = "invalid password! Please try again";
//form customer or admin account
var req_fname = "First name must be defined!";
var req_lname = "Lirst name must be defined!";
var err_cmppwd = "Password and Confirm password is false! Please try again";
var req_comname = "Company name must be defined!";
var req_comindustry = "Company industy must be defined!";
var req_address = "Address must be defined!";
var req_city = "City must be defined!";
var req_state = "State must be defined!";
var req_country = "Country must be defined!";
var req_phone = "Phone must be defined!";
var req_email = "E-mail address must be defined!";
var err_email = "Invalid e-mail address must be defined!";
var req_group = "Category name must be defined!";
var req_skillgroup = "Group name must be defined!";
//from Skill
var req_skill = "Skill name must be defined!"
var req_skilldesc = "Skill description must be defined!"
var req_question = "Action must be defined!"
var err_question = "Action list is empty.  Please try again"
var err_removequestion = "Action list is empty! You can't delete it";
//from Table Skill
var req_tabcode = "Survey code must be defined!"
var req_tabname = "Survey name must be defined!"
var req_tabcustomer = "Please select manager account!"
var err_tabcode = "Please select survey name!"
var req_surveycode = "Survey code must be defined!"
/*General util function*/
function pop_err(fieldname,err_msg)
{
	fieldname.focus();
	alert(err_msg);
}
/*Login from*/
function doLogin()
{
	var doc = document.frm;
	if(doc.username.value == "")
	{
		pop_err(doc.username,req_user)
		return false;
	}
	if(doc.password.value == "")
	{
		pop_err(doc.password,req_pass)
		return false;
	}
	var szPW = calculateValue();
	doc.strpassword.value=szPW;
	doc.password.value="";
	return;
}
//set MD5 for password
function calculateValue() {
	var doc = document.frm;
	var szPW = doc.password.value;
	szPW +=sharedValue;
	return calcValue(szPW);
}
/*Create customer account*/
function addeditaccount()
{	
	var doc = document.frm;
	if(doc.fname.value == "")
	{
		pop_err(doc.fname,req_fname)
		return false;
	}
	if(doc.lname.value == "")
	{
		pop_err(doc.lname,req_lname)
		return false;
	}	
	if(doc.username.value == "")
	{
		pop_err(doc.username,req_user)
		return false;
	}
	if(doc.password.value == "")
	{
		pop_err(doc.password,req_pass)
		return false;
	}
	if(doc.password.value != doc.con_password.value)
	{
		pop_err(doc.con_password,err_cmppwd)
		return false;
	}
	if(doc.survey_code.value == "")
	{
		pop_err(doc.survey_code,req_surveycode)
		return false;
	}	
	szemail = doc.email.value;
	if(szemail == "")
	{
		pop_err(doc.email,req_email)
		return false;
	}
	if(szemail.indexOf('@') == -1)
	{
		pop_err(doc.email,err_email)
		return false;
	}else{
		var arr_email = szemail.split('@')
		var strdomain = arr_email[1];
		if(strdomain.indexOf('.') == -1)
		{
			pop_err(doc.email,err_email)
			return false;
		}else{
			var arr_data = strdomain.split('.')
			var define_name = arr_data[1];
			if(define_name == "")
			{
				pop_err(doc.email,err_email)
				return false;
			}
		}
	}	
	return;
}
function useraddeditaccount()
{
	var doc = document.frm;
	if(doc.fname.value == "")
	{
		pop_err(doc.fname,req_fname)
		return false;
	}
	if(doc.lname.value == "")
	{
		pop_err(doc.lname,req_lname)
		return false;
	}	
	if(doc.username.value == "")
	{
		pop_err(doc.username,req_user)
		return false;
	}
	if(doc.password.value == "")
	{
		pop_err(doc.password,req_pass)
		return false;
	}
	if(doc.password.value != doc.con_password.value)
	{
		pop_err(doc.con_password,err_cmppwd)
		return false;
	}	
	szemail = doc.email.value;
	if(szemail == "")
	{
		pop_err(doc.email,req_email)
		return false;
	}
	if(szemail.indexOf('@') == -1)
	{
		pop_err(doc.email,err_email)
		return false;
	}else{
		var arr_email = szemail.split('@')
		var strdomain = arr_email[1];
		if(strdomain.indexOf('.') == -1)
		{
			pop_err(doc.email,err_email)
			return false;
		}else{
			var arr_data = strdomain.split('.')
			var define_name = arr_data[1];
			if(define_name == "")
			{
				pop_err(doc.email,err_email)
				return false;
			}
		}
	}	
	return;
}
/*Reset data*/
function reset_data()
{
	document.frm.reset()	
}
/*Create or Update Group*/
function addeditgroup()
{
	var doc = document.frm;
	if(doc.groupname.value=="")
	{
		pop_err(doc.groupname,req_group)
		return false;
	}
	return;
}
/*Create or Update Skill's Group*/
function addeditskillgroup()
{
	var doc = document.frm;
	if(doc.groupname.value=="")
	{
		pop_err(doc.groupname,req_skillgroup)
		return false;
	}
	return;
}
/*Create or Update Skill*/
function addquestion()
{
	var doc = document.frm;
	doc.status_question.value = 1
	if(doc.anwser.value == "")
	{
		pop_err(doc.anwser,req_question)
		return false;
	}else{
		document.frm.submit();
	}
}
function add_update_question()
{
	var doc = document.frm;
	doc.status_add_question.value = 1
	if(doc.anwser.value == "")
	{
		pop_err(doc.anwser,req_question)
		return false;
	}else{
		document.frm.submit();
	}
}
function updatequestion()
{
	var doc = document.frm;
	doc.status_question.value = 1
	if(doc.anwser.value == "")
	{
		pop_err(doc.anwser,req_question)
		return false;
	}else{
		document.frm.submit();
	}
}
function doeditskill(id)
{
	var doc = document.frm;
	doc.idanwser.value = id
	document.frm.submit();
}
function addeditskill()
{
	var doc = document.frm;
	if(doc.skillname.value == "")
	{
		pop_err(doc.skillname,req_skill)
		return false;
	}
	if(doc.skilldetail.value == "")
	{
		pop_err(doc.skilldetail,req_skilldesc)
		return false;
	}	
	if(doc.numquestion.value <= 0)
	{
		alert(err_question)
		return false;
	}
	return;
}
function removequestion()
{
	var doc = document.frm;
	if(doc.numquestion.value <= 0)
	{
		alert(err_removequestion)
	}else{
		doc.status_remove.value = 1
		document.frm.submit();
	}
}
//Function Add/Update/Remove Table skill
function addedittabskill()
{
	var doc = document.frm;
	/*if(doc.tabcode.value == "")
	{
		pop_err(doc.tabcode,req_tabcode)
		return false;
	}*/
	if(doc.tabname.value == "")
	{
		pop_err(doc.tabname,req_tabname)
		return false;
	}
	var sztarget_begin = doc.target.value
	if(sztarget_begin == "")
	{
		pop_err(doc.target,"Begin target must be defined!")
		return false;
	}
	if((parseFloat(sztarget_begin) < 0.5) || (parseFloat(sztarget_begin) > 10) || (sztarget_begin.indexOf(',') == 1))
	{
		pop_err(doc.target,"Begin target must be <= 10 and >=1")
		return false;
	}
	var sztarget = doc.target_range.value
	if(doc.target_range.value == "")
	{
		pop_err(doc.target_range,"End target must be defined!")
		return false;
	}
	if((parseFloat(sztarget) < 0.5) || (parseFloat(sztarget) > 10) || (sztarget.indexOf(',') == 1))
	{
		pop_err(doc.target_range,"End target must be <= 10 and >=1")
		return false;
	}
	if(parseFloat(sztarget) < parseFloat(sztarget_begin))
	{
		pop_err(doc.target_range,"End target must be >= Begin target")
		return false;
	}
	doc.accept_add.value = "OK"
	doc.submit()
	return;
}
/*function add/update user account*/
function addedituser()
{
	var doc = document.frm;
	if(doc.fname.value == "")
	{
		pop_err(doc.fname,req_fname)
		return false;
	}
	if(doc.lname.value == "")
	{
		pop_err(doc.lname,req_lname)
		return false;
	}
	szemail = doc.email.value;
	if(szemail == "")
	{
		pop_err(doc.email,req_email)
		return false;
	}
	if(szemail.indexOf('@') == -1)
	{
		pop_err(doc.email,err_email)
		return false;
	}else{
		var arr_email = szemail.split('@')
		var strdomain = arr_email[1];
		if(strdomain.indexOf('.') == -1)
		{
			pop_err(doc.email,err_email)
			return false;
		}else{
			var arr_data = strdomain.split('.')
			var define_name = arr_data[1];
			if(define_name == "")
			{
				pop_err(doc.email,err_email)
				return false;
			}
		}
	}
	if(doc.groupname.value=="")
	{
		pop_err(doc.groupname,req_group)
		return false;
	}
	return;
}
function sendstatus()
{
	var doc = document.frm;	
	if(doc.tabcode.value == "")
	{
		pop_err(doc.tabcode,err_tabcode)
		return false;
	}
	return;
}
function send_survey_status()
{
	var doc = document.frm;	
	if(doc.tabcode.value == "")
	{
		pop_err(doc.tabcode,err_tabcode)
		return false;
	}
	return;
}
function viewstatus_skill()
{
	if(document.frm.tabcode.value!="")
	{
		document.frm.expire_survey_date.value = ""
	}
	document.frm.action = "manager_status.asp"
	document.frm.submit();
}
function usadmin_viewstatus_participant_skill()
{
	if(document.frm.tabcode.value!="")
	{
		document.frm.expire_survey_date.value = ""
	}
	document.frm.action = "usadmin_participant_status.asp"
	document.frm.submit();
}
function send_viewstatus_skill()
{
	document.frm.action = "manager_status.asp"
	document.frm.submit();
}
function send_viewstatus_participant_skill()
{
	document.frm.action = "usadmin_participant_status.asp"
	document.frm.submit();
}
function useradmin_viewstatus_skill()
{
	document.frm.action = "usadmin_status.asp"
	document.frm.submit();
}
function select_partipant()
{
	document.frm.action = "usadmin_status.asp"
	document.frm.submit()
}
function do_next()
{
	var doc = document.frm;
	document.frm.submit();	
}
function send_data(type)
{
	var doc = document.frm;
	var j = 0;
	var totalrows = doc.numrows.value
	for(var i=0; i<doc.length;i++)
	{
		if(doc.elements[i].type=="radio" && doc.elements[i].checked==true && doc.elements[i].value != "0")
		{
			j = j + 1
		}
	}
	if(j <= 0)
	{
		alert("Please enter your ratings by clicking on the cells, then review your ratings. Click OK to begin.")
		return false;
	}else{		
		if(confirm("You are about to submit your ratings. Click cancel to return and review your ratings, or click OK to submit your ratings.") == true)
		{
			doc.acceptdata.value = 1;
			if(type == "public"){
				doc.action = "user_public_rating.asp"
			}else{
				doc.action = "user_rating.asp"
			}
			doc.submit()
		}		
	}
}
function review_data(type)
{
	var doc = document.frm;
	var j = 0;
	var totalrows = doc.numrows.value
	for(var i=0; i<doc.length;i++)
	{
		if(doc.elements[i].type=="radio" && doc.elements[i].checked==true && doc.elements[i].value != "0")
		{
			j = j + 1
		}
	}
	if(j <= 0)
	{
		alert("Please enter your ratings by clicking on the cells, then review your ratings. Click OK to begin.")
		return false;
	}else
	{
		if(type == "public"){
			doc.action = "user_public_rating_review.asp"
		}else{
			doc.action = "user_rating_review.asp"
		}
		doc.submit()
	}
}
function clear_data()
{
	var doc = document.frm;
	doc.chkall.value = 0;
	doc.reset()
}
function exit_system()
{
	if(confirm("Warning: You are about to leave without submitting your ratings. Click cancel to return to your survey or click OK to close without submitting your ratings.")==true)
	{			
		document.location.replace("http://www.360plusfeedback.com")
	}	
}
function exit_system_final()
{
	if(confirm("Click OK to learn more about 360Plus Feedback, Cancel to close this window")==true)
	{
		document.location.replace("http://www.360plusfeedback.com")
	}else{
		window.close()
	}	
}
function do_check()
{
	var doc = document.frm;
	doc.chkall.value = 1;
}
function select_useradmin_manager()
{
	if(document.frm.manager.value!="")
	{
		document.frm.tabcode.value=""
		document.frm.expire_date.value=""
	}
	document.frm.print_num.value = ""
	document.frm.submit()
}
function change_select_skill()
{
	document.frm.print_num.value = ""
	document.frm.submit()
}
function selectmanager()
{	
	if(document.frm.manager.value!="")
	{
		document.frm.tabcode.value=""
		document.frm.expire_date.value=""
	}
	document.frm.print_num.value = ""
	document.frm.submit()
}
function views_expire_date()
{	
	document.frm.action = "manager_status.asp"
	document.frm.submit();
}
function views_participant_expire_date()
{
	document.frm.action = "usadmin_participant_status.asp"
	document.frm.submit();
}
function validation_summary()
{
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		if(doc.public_tabcode.value == "")
		{
			pop_err(doc.public_tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 6
	doc.validationreport.value = 1
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function quantum_validation_summary()
{
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	if(doc.user_admin.value != "")
	{
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 6
	doc.validationreport.value = 1
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function show_summary()
{	
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		if(doc.public_tabcode.value == "")
		{
			pop_err(doc.public_tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 1
	doc.summary.value = 1
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function quantum_show_summary()
{	
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	if(doc.user_admin.value != "")
	{
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 1
	doc.summary.value = 1
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function show_employee()
{
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		if(doc.public_tabcode.value == "")
		{
			pop_err(doc.public_tabcode,'Survey name must be defined')
			return false;
		}
	}
	
	doc.print_num.value = 2
	doc.summary.value = ""
	doc.emp.value = 1
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function quantum_show_employee()
{
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	if(doc.user_admin.value != "")
	{
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 2
	doc.summary.value = ""
	doc.emp.value = 1
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function show_company()
{
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		alert("This report is not relevant to Public Survey");
		return false;
	}
	
	doc.print_num.value = 3
	doc.summary.value = ""
	doc.emp.value = ""
	doc.survey.value = ""
	doc.com.value = 1
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function quantum_show_company()
{
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	if(doc.user_admin.value != "")
	{
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 3
	doc.summary.value = ""
	doc.emp.value = ""
	doc.survey.value = ""
	doc.com.value = 1
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function show_survey_analysis()
{
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		if(doc.public_tabcode.value == "")
		{
			pop_err(doc.public_tabcode,'Survey name must be defined')
			return false;
		}
	}
	
	doc.print_num.value = 5
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.recomment.value= ""
	doc.survey.value= 1
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function quantum_show_survey_analysis()
{
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	if(doc.user_admin.value != "")
	{
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 5
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.survey.value= 1
	doc.comment.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function show_recommemt()
{
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		if(doc.public_tabcode.value == "")
		{
			pop_err(doc.public_tabcode,'Survey name must be defined')
			return false;
		}
	}
	
	doc.print_num.value = 4
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value = 1
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function quantum_show_recommemt()
{
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	if(doc.user_admin.value != "")
	{
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 4
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= 1
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function show_heatchart()
{
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		alert("This report is not relevant to Public Survey");
		return false;
	}
	
	doc.print_num.value = 8
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value = ""
	doc.heatchart.value = 1
	doc.comment.value = ""
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function quantum_show_heatchart()
{
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	
	if(doc.manager.value == "")
	{
		pop_err(doc.manager,'Please select participant name')
		return false;
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	
	doc.print_num.value = 8
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= ""
	doc.heatchart.value= 1
	doc.comment.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function show_comment()
{
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		if(doc.public_tabcode.value == "")
		{
			pop_err(doc.public_tabcode,'Survey name must be defined')
			return false;
		}
	}
	
	doc.print_num.value = 9
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value = ""
	doc.heatchart.value = ""
	doc.comment.value = 1
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}

function show_commentbycat(){
	var doc = document.frm;
	if(doc.is_public.checked == true){
		if(doc.public_tabcode.value == ""){
			pop_err(doc.public_tabcode,'Survey name must be defined')
			return false;
		}
	}else{
		alert("This report is not relevant to Private Survey");
		return false;
	}
	
	doc.print_num.value = 10
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value = ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.commentbycat.value = 1
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}

// type = 0: show condition for user to select to review report
// type = 1: get data and show report
function show_trendanalysis(type){
	var doc = document.frm;
	if(type == 0){
		if(doc.is_public.checked == true){
			if(doc.public_tabcode.value == ""){
				pop_err(doc.public_tabcode,'Survey name must be defined')
				return false;
			}
		}else{
			alert("This report is not relevant to Private Survey");
			return false;
		}
		
		doc.print_num.value = 11
		doc.summary.value = ""
		doc.emp.value = ""
		doc.com.value = ""
		doc.survey.value = ""
		doc.recomment.value = ""
		doc.heatchart.value = ""
		doc.comment.value = ""
		doc.commentbycat.value = ""
		doc.trendanalysis.value = 1
		doc.validationreport.value = ""
		doc.cosummary.value = ""
	}else{
		if(doc.type_compare[0].checked == true){
			if(doc.date_from1.value == ""){
				pop_err(doc.date_from1,'Please select date from for period 1!');
				return false;
			}
			if(doc.date_to1.value == ""){
				pop_err(doc.date_to1,'Please select date to for period 1!');
				return false;
			}
			if(doc.date_from2.value == ""){
				pop_err(doc.date_from2,'Please select date from for period 2!');
				return false;
			}
			if(doc.date_to2.value == ""){
				pop_err(doc.date_to2,'Please select date to for period 2!');
				return false;
			}
		}else{
			if(doc.year1.value == doc.year2.value){
				if(parseInt(doc.month1.value) > parseInt(doc.month2.value)){
					pop_err(doc.month1,'Month of To must be later than Month of From!');
					return false;
				}
			}else if(parseInt(doc.year1.value) > parseInt(doc.year2.value)){
				pop_err(doc.year1,'Year of To must be later than Year of From!');
				return false;
			}else{
				var total_month = (12 - parseInt(doc.month1.value)) + parseInt(doc.month2.value);
				if(total_month > 11){
					pop_err(doc.year2,'The time period must not be over 12 months!');
					return false;
				}
			}
		}
		doc.act.value = "show_data";
	}
	doc.submit()
}

function quantum_show_comment()
{
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	
	if(doc.manager.value == "")
	{
		pop_err(doc.manager,'Please select participant name')
		return false;
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	
	doc.print_num.value = 9
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value= ""
	doc.heatchart.value = ""
	doc.comment.value = 1
	doc.validationreport.value = ""
	doc.cosummary.value = ""
	doc.submit()
}
function company_summary_report()
{
	var doc = document.frm;
	if(doc.is_public.checked == false){
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
		if(doc.manager.value != "")
		{
			if(doc.tabcode.value == "")
			{
				pop_err(doc.tabcode,'Survey name must be defined')
				return false;
			}
		}
	}else{
		alert("This report is not relevant to Public Survey");
		return false;
	}
	
	doc.print_num.value = 7
	doc.cosummary.value = 1
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value = ""
	doc.heatchart.value = ""
	doc.comment.value = ""
	doc.commentbycat.value = ""
	doc.trendanalysis.value = ""
	doc.validationreport.value = ""
	doc.submit()
}
function quantum_company_summary_report()
{
	var doc = document.frm;
	if(doc.user_admin.value == "")
	{
		pop_err(doc.user_admin,'Please select user admin name')
		return false;
	}
	if(doc.user_admin.value != "")
	{
		if(doc.manager.value == "")
		{
			pop_err(doc.manager,'Please select participant name')
			return false;
		}
	}
	if(doc.manager.value != "")
	{
		if(doc.tabcode.value == "")
		{
			pop_err(doc.tabcode,'Survey name must be defined')
			return false;
		}
	}
	doc.print_num.value = 7
	doc.cosummary.value = 1
	doc.summary.value = ""
	doc.emp.value = ""
	doc.com.value = ""
	doc.survey.value = ""
	doc.recomment.value = ""
	doc.validationreport.value = ""
	doc.submit()
}
function print_report(id)
{
	var szpage = ""
	var extraparam = ""
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	var is_public = document.frm.is_public.checked;
	var is_reverse = "";
	if(is_public == true){
		var manager = "";
		var tabskill = document.frm.public_tabcode.value;
		var expiredate = document.frm.public_expire_date.value;
		if(document.frm.is_reverse.checked == true)
			is_reverse = document.frm.is_reverse.value;
	}else{
		var manager = document.frm.manager.value;
		var tabskill = document.frm.tabcode.value;
		var expiredate = document.frm.expire_date.value;
	}
	if(id == 1){
		if(manager != "" && tabskill != "" && expiredate != "" && is_public == false){
			szpage = "print_sum_report.asp?";
		}else{
			szpage = "print_sum_report.asp?is_public=Y&";	
		}
	}
	if(id == 2){
		var sztype_report = document.frm.target_print.value;
		var szoption = document.frm.select_option.value;
		if (sztype_report != "" && szoption != ""){
			if(szoption == 3){
				var szdepartment =  document.frm.select_dept.value;
				extraparam = "&style_report=" + sztype_report + "&rdshow=" + szoption + "&chkitems=" + szdepartment
			}else{
				extraparam = "&style_report=" + sztype_report + "&rdshow=" + szoption
			}
		}
			
		if(manager != "" && tabskill != "" && expiredate != "" && is_public == false){
			szpage = "print_employee_report.asp?";
		}else{
			szpage = "print_employee_report.asp?is_public=Y&";	
		}
	}
	if(id == 3){
		if(manager != "" && tabskill != "" && expiredate != "" && is_public == false){
			szpage = "print_company_report.asp?";
		}
	}
	if(id == 4){
		var sztype_report = document.frm.stype_report.value;
		if(sztype_report != ""){
			extraparam = "&type_report=" + sztype_report
		}
		if(manager != "" && tabskill != "" && expiredate != "" && is_public == false){
			szpage = "print_developer_report.asp?";
		}else{
			szpage = "print_developer_report.asp?is_public=Y&";	
		}
	}
	if(id == 5){
		if(manager != "" && tabskill != "" && expiredate != "" && is_public == false){
			szpage = "print_survey_report.asp?";
		}else{
			szpage = "print_survey_report.asp?is_public=Y&";	
		}
	}
	if(id == 6){
		if(manager != "" && tabskill != "" && expiredate != "" && is_public == false){
			szpage = "print_validation_report.asp?";
		}else{
			szpage = "print_validation_report.asp?is_public=Y&";	
		}
	}
	if(id == 7){
		var returndate = document.frm.b_month.value + "/" + document.frm.b_day.value + "/" + document.frm.b_year.value
		if(manager != "" && tabskill != "" && expiredate != ""){
			if (returndate != ""){
				szpage = "print_360summary_report.asp?zdate=" + returndate + "&"
			}else{
				szpage = "print_360summary_report.asp?"
			}
		}
	}
	if(id == 8){
		if(tabskill != "" && expiredate != "" && is_public == false){
			szpage = "print_heatchart_report.asp?"
		}
	}
	if(id == 9){
		if(manager != "" && tabskill != "" && expiredate != "" && is_public == false){
			szpage = "print_comment_summary.asp?";
		}else{
			szpage = "print_comment_summary.asp?is_public=Y&";	
		}
	}
	if(id == 10){
		szpage = "print_comment_summary_bycat.asp?is_public=Y&";	
	}
	if(id == 11){
		for(var i = 0; i < 4; i++){
			if(doc.report[i].checked == true){
				var report = doc.report[i].value;
				i = 4;
			}
		}
		if(doc.type_compare[0].checked == true)
			var type_compare = doc.type_compare[0].value;
		else
			var type_compare = doc.type_compare[1].value;	
		szpage = "print_trend_analysis.asp?is_public=Y&report=" + report + "&type_compare=" + type_compare + "&";
		if(type_compare == "d"){
			var date_from1 = doc.date_from1.value;
			var date_to1 = doc.date_to1.value;
			var date_from2 = doc.date_from2.value;
			var date_to1 = doc.date_to1.value;
			szpage = szpage + "date_from1=" + date_from1 + "&date_to1=" + date_to1 + "&date_from2=" + date_from2 + "&date_to2=" + date_to2 + "&";
		}else{
			var month1 = doc.month1.value;
			var year1 = doc.year1.value;
			var month2 = doc.month2.value;
			var year2 = doc.year2.value;
			szpage = szpage + "month1=" + month1 + "&year1=" + year1 + "&month2=" + month2 + "&year2=" + year2 + "&";
		}
	}
	if(szpage != ""){
		param = "manager=" + manager + "&tabcode=" + tabskill + "&expire_date=" + expiredate + "&is_reverse=" + is_reverse;
		if (extraparam != ""){
			param = param + extraparam
		}
		szpage = szpage + param
		sPro = "WIDTH=800,HEIGHT=600,scrollbars=yes,resize=yes,menubar=yes,resizable=yes,left=" + winLeft + ",top=" + winTop
		window.open(szpage,"printing",sPro,true)
	}else{
		alert("Report can't printing")
	}
}
function print_cover_page(id)
{	
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight
	winTop = 0
	winLeft = 0	
	if(document.frm.is_public.checked == true){
		var manager = "";
		var tabskill = document.frm.public_tabcode.value;
		var expiredate = document.frm.public_expire_date.value;
	}else{
		var manager = document.frm.manager.value;
		var tabskill = document.frm.tabcode.value;
		var expiredate = document.frm.expire_date.value;
	}
	param = "style_id=" + id + "&manager=" + manager + "&tabcode=" + tabskill + "&expire_date=" + expiredate
	szpage = "page_cover.asp?" + param
	sPro = "WIDTH=800,HEIGHT=600,scrollbars=yes,resize=yes,menubar=yes,resizable=yes,left=" + winLeft + ",top=" + winTop
	window.open(szpage,"cover",sPro,true)
	
}
function export_report(id)
{
	var szpage = ""
	var extraparam = ""
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	var manager = document.frm.manager.value;
	var tabskill = document.frm.tabcode.value;
	var expiredate = document.frm.expire_date.value;	
	if(id == 8){
		if(tabskill != "" && expiredate != ""){
			szpage = "export_heatchart_report.asp?"
		}
	}
	if(szpage != ""){
		param = "manager=" + manager + "&tabcode=" + tabskill + "&expire_date=" + expiredate;
		if (extraparam != ""){
			param = param + extraparam;
		}
		szpage = szpage + param;
		window.open(szpage);		
	}else{
		alert("Can not export report!");
	}
}

function export_raw_data(){
	var szpage = ""
	var extraparam = ""
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	var is_public = document.frm.is_public.checked;
	var is_reverse = "";
	if(is_public == true){
		var manager = "";
		var tabskill = document.frm.public_tabcode.value;
		var expiredate = document.frm.public_expire_date.value;
		if(document.frm.is_reverse.checked == true)
			is_reverse = document.frm.is_reverse.value;
	}else{
		var manager = document.frm.manager.value;
		var tabskill = document.frm.tabcode.value;
		var expiredate = document.frm.expire_date.value;
	}
	
	if(tabskill != "" && expiredate != ""){
		szpage = "export_raw_data.asp?"
		param = "manager=" + manager + "&tabcode=" + tabskill + "&expire_date=" + expiredate + "&is_public=" + is_public + "&is_reverse=" + is_reverse;
		if (extraparam != ""){
			param = param + extraparam;
		}
		szpage = szpage + param;
		window.open(szpage);
	}else{
		alert("Can not export report!");
	}
}

function export_quantum_report(id)
{
	var szpage = ""
	var extraparam = ""
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	var user_admin = document.frm.user_admin.value;
	var manager = document.frm.manager.value;
	var tabskill = document.frm.tabcode.value;
	var expiredate = document.frm.expire_date.value;	
	if(id == 8){
		if(tabskill != "" && expiredate != ""){
			szpage = "export_heatchart_report.asp?"
		}
	}
	if(szpage != ""){
		param = "manager=" + manager + "&tabcode=" + tabskill + "&expire_date=" + expiredate + "&user_admin=" + user_admin;
		if (extraparam != ""){
			param = param + extraparam;
		}
		szpage = szpage + param;
		window.open(szpage);		
	}else{
		alert("Can not export report!");
	}
}

function print_quantum_report(id)
{
	var szpage = ""
	var extraparam = ""
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	var user_admin = document.frm.user_admin.value;
	var manager = document.frm.manager.value;
	var tabskill = document.frm.tabcode.value;
	var expiredate = document.frm.expire_date.value;	
	if(id == 1)
	{
		if(manager != "" && tabskill != "" && expiredate != "" && user_admin!="")
		{
			szpage = "print_sum_report.asp?"
		}
	}
	if(id == 2)
	{
		if(manager != "" && tabskill != "" && expiredate != "")
		{
			var sztype_report = document.frm.target_print.value;
			var szoption = document.frm.select_option.value;
			if (sztype_report != "" && szoption != "")
			{
				if(szoption == 3)
				{
					var szdepartment =  document.frm.select_dept.value;
					extraparam = "&style_report=" + sztype_report + "&rdshow=" + szoption + "&chkitems=" + szdepartment
				}else{
					extraparam = "&style_report=" + sztype_report + "&rdshow=" + szoption
				}
			}
			szpage = "print_employee_report.asp?"
		}
	}
	if(id == 3)
	{
		if(manager != "" && tabskill != "" && expiredate != "")
		{
			szpage = "print_company_report.asp?"
		}
	}
	if(id == 4)
	{
		if(manager != "" && tabskill != "" && expiredate != "")
		{
			var sztype_report = document.frm.stype_report.value;
			if(sztype_report != "")
			{
				extraparam = "&type_report=" + sztype_report
			}
			szpage = "print_developer_report.asp?"
		}
	}
	if(id == 5)
	{
		if(manager != "" && tabskill != "" && expiredate != "")
		{
			szpage = "print_survey_report.asp?"
		}
	}
	if(id == 6)
	{
		if(manager != "" && tabskill != "" && expiredate != "")
		{
			szpage = "print_validation_report.asp?"
		}
	}
	if(id == 7)
	{
		var returndate = document.frm.b_month.value + "/" + document.frm.b_day.value + "/" + document.frm.b_year.value
		if(manager != "" && tabskill != "" && expiredate != "")
		{
			if (returndate != "")
			{
				szpage = "print_360summary_report.asp?zdate=" + returndate + "&"
			}else
			{
				szpage = "print_360summary_report.asp?"				
			}
		}
	}
	if(id == 8)
	{
		if(tabskill != "" && expiredate != "")
		{
			szpage = "print_heatchart_report.asp?"
		}
	}
	if(id == 9)
	{
		if(manager != "" && tabskill != "" && expiredate != "")
		{
			szpage = "print_comment_summary.asp?"
		}
	}
	if(szpage != "")
	{
		param = "manager=" + manager + "&tabcode=" + tabskill + "&expire_date=" + expiredate + "&user_admin=" + user_admin
		if (extraparam != "")
		{
			param = param + extraparam
		}
		szpage = szpage + param
		sPro = "WIDTH=800,HEIGHT=600,scrollbars=yes,resize=yes,menubar=yes,resizable=yes,left=" + winLeft + ",top=" + winTop
		window.open(szpage,"printing",sPro,true)
	}else{
		alert("Report can't printing")
	}
}
function select_skill()
{
	document.frm.action = "admin_skill.asp"
	document.frm.submit();
}
function select_useradmin_skill()
{
	document.frm.action = "usadmin_skill.asp"
	document.frm.submit();
}
function select_category()
{	
	document.frm.action = "admin_group.asp"
	document.frm.submit()
}
function select_survey()
{
	document.frm.submit()
}
function select_useradmin()
{
	var doc = document.frm;
	if(doc.user_admin.value != "")
	{
		doc.manager.value =""
	}
	document.frm.print_num.value = ""
	document.frm.submit()
}
function select_useradmin_error()
{
	var doc = document.frm;
	if(doc.user_admin.value != "")
	{
		doc.manager.value =""
	}
	document.frm.submit()
}
function select_manager_respondent()
{
	var doc = document.frm;
	document.frm.submit()
}
function change_select_respondent_skill()
{
	var doc = document.frm;
	document.frm.submit()
}
function do_click_error()
{
	var doc = document.frm;
	var j = 0;
	for(var i=0; i<doc.length;i++)
	{
		if(doc.elements[i].type=="checkbox" && doc.elements[i].checked==true && doc.elements[i].value != "0")
		{
			j = j + 1
		}
	}
	if(j > 0)
	{
		doc.delete_respondent.disabled = false;
	}else{
		doc.delete_respondent.disabled = true;
	}
}
function do_find_respondent()
{
	var doc = document.frm;
	doc.accept_find.value = "OK"
	document.frm.submit()
}
function do_delete_error()
{
	var doc = document.frm;
	doc.accept_find.value = "OK"
	doc.accept_delete.value = "OK"
	document.frm.submit()
}
function useradmin_select_reviewdate(adminid,tabid,expiredate)
{
	var strparam = "tabskill=" + tabid + "&adminid=" + adminid + "&expiredate=" + expiredate;
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight
	
	winTop = 5
	winLeft = 5
	sPro = "WIDTH=280,HEIGHT=265,scrollbars=no,resize=no,menubar=no,resizable=yes,left=" + winLeft + ",top=" + winTop
	window.open("calenda/default.asp?" + strparam,"calenda",sPro,true)
}
function printsurvey(tabid)
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight
	
	winTop = 0
	winLeft = 0
	sPro = "WIDTH=800,HEIGHT=600,scrollbars=yes,resize=yes,menubar=yes,resizable=yes,left=" + winLeft + ",top=" + winTop
	window.open("printsurvey.asp?tabid=" + tabid,"printsurvey",sPro,true)
}
function setinfoadmin()
{
	var doc = document.frm;	
	if(doc.chkinfo.checked == true)
	{
		doc.comname.value = doc.info_comname.value
		doc.industry.value = doc.info_industry.value
		doc.address.value = doc.info_address.value
		doc.city.value = doc.info_city.value
		szState = doc.info_state.value
		for(var i=0;i<doc.state.length;i++)
		{
			if(doc.state.options[i].value==szState)
			{
				doc.state.options[i].selected = true
			}
		}		
		doc.zipcode.value = doc.info_zipcode.value
		szCountry = doc.info_country.value
		for(var i=0;i<doc.country.length;i++)
		{
			if(doc.country.options[i].value==szCountry)
			{
				doc.country.options[i].selected = true
			}
		}
		doc.phone.value = doc.info_phone.value
		doc.fax.value = doc.info_fax.value
	}else{
		doc.comname.value = ""
		doc.industry.value = ""
		doc.address.value = ""
		doc.city.value = ""
		doc.state.value = ""
		doc.zipcode.value = ""
		for(var i=0;i<doc.country.length;i++)
		{
			if(doc.country.options[i].value=='U.S.A.')
			{
				doc.country.options[i].selected = true
			}
		}
		doc.phone.value = ""
		doc.fax.value = ""
	}	
}
function print_quantum_report_top()
{
	var doc = document.frm;
	var szpage = ""
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	
	if(doc.print_num.value != "")
	{
		var extraparam = ""
		var id = doc.print_num.value
		var user_admin = document.frm.user_admin.value;
		var manager = document.frm.manager.value;
		var tabskill = document.frm.tabcode.value;
		var expiredate = document.frm.expire_date.value;
		if(id == 1)
		{
			if(manager != "" && tabskill != "" && expiredate != "" && user_admin!="")
			{
				szpage = "print_sum_report.asp?"
			}
		}
		if(id == 2)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				var sztype_report = document.frm.target_print.value;
				var szoption = document.frm.select_option.value;
				if (sztype_report != "" && szoption != "")
				{
					if(szoption == 3)
					{
						var szdepartment =  document.frm.select_dept.value;
						extraparam = "&style_report=" + sztype_report + "&rdshow=" + szoption + "&chkitems=" + szdepartment
					}else{
						extraparam = "&style_report=" + sztype_report + "&rdshow=" + szoption
					}
				}
				szpage = "print_employee_report.asp?"
			}
		}
		if(id == 3)
		{
			if(manager != "" && tabskill != "" && expiredate != "" && user_admin!="")
			{
				szpage = "print_company_report.asp?"
			}
		}
		if(id == 4)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				var sztype_report = document.frm.stype_report.value;
				if(sztype_report != "")
				{
					extraparam = "&type_report=" + sztype_report
				}
				szpage = "print_developer_report.asp?"
			}
		}
		if(id == 5)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				szpage = "print_survey_report.asp?"
			}
		}
		if(id == 6)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				szpage = "print_validation_report.asp?"
			}
		}
		if(szpage != "")
		{
			param = "manager=" + manager + "&tabcode=" + tabskill + "&expire_date=" + expiredate + "&user_admin=" + user_admin
			if (extraparam != "")
			{
				param = param + extraparam
			}
			szpage = szpage + param
			sPro = "WIDTH=800,HEIGHT=600,scrollbars=yes,resize=yes,menubar=yes,resizable=yes,left=" + winLeft + ",top=" + winTop
			window.open(szpage,"printing",sPro,true)
		}else{
			alert("Report can't printing")
		}
	}else
	{
		alert("Please review report before print report.")
	}
}

function print_report_top()
{
	var doc = document.frm;
	var szpage = ""
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	
	if(doc.print_num.value != "")
	{
		var extraparam = ""
		var id = doc.print_num.value
		var manager = document.frm.manager.value;
		var tabskill = document.frm.tabcode.value;
		var expiredate = document.frm.expire_date.value;
		if(id == 1)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				szpage = "print_sum_report.asp?"
			}
		}
		if(id == 2)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				var sztype_report = document.frm.target_print.value;
				var szoption = document.frm.select_option.value;
				if (sztype_report != "" && szoption != "")
				{
					if(szoption == 3)
					{
						var szdepartment =  document.frm.select_dept.value;
						extraparam = "&style_report=" + sztype_report + "&rdshow=" + szoption + "&chkitems=" + szdepartment
					}else{
						extraparam = "&style_report=" + sztype_report + "&rdshow=" + szoption
					}
				}
				szpage = "print_employee_report.asp?"
			}
		}
		if(id == 3)
		{			
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				szpage = "print_company_report.asp?"
			}
		}
		if(id == 4)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				var sztype_report = document.frm.stype_report.value;
				if(sztype_report != "")
				{
					extraparam = "&type_report=" + sztype_report
				}
				szpage = "print_developer_report.asp?"
			}
		}
		if(id == 5)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				szpage = "print_survey_report.asp?"
			}
		}
		if(id == 6)
		{
			if(manager != "" && tabskill != "" && expiredate != "")
			{
				szpage = "print_validation_report.asp?"
			}
		}
		if(szpage != "")
		{
			param = "manager=" + manager + "&tabcode=" + tabskill + "&expire_date=" + expiredate
			if (extraparam != "")
			{
				param = param + extraparam
			}
			szpage = szpage + param
			sPro = "WIDTH=800,HEIGHT=600,scrollbars=yes,resize=yes,menubar=yes,resizable=yes,left=" + winLeft + ",top=" + winTop
			window.open(szpage,"printing",sPro,true)
		}else{
			alert("Report can't printing")
		}
	}else
	{
		alert("Please review report before print report.")
	}
}
function update_email_template()
{
	var tabid = "";
	var manager = document.frm.manager_id.value;
	for(var i=0; i<document.frm.tabcode.length;i++)
	{
		if(document.frm.tabcode[i].selected == true)
		{
			tabid = document.frm.tabcode[i].value
		}
	}
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	if(tabid != "")
	{
		param = "manid=" + manager + "&tabid=" + tabid
		szpage = "manager_email_temp.asp?" + param
		sPro = "WIDTH=590,HEIGHT=410,scrollbars=yes,resize=no,menubar=no,resizable=no,left=" + winLeft + ",top=" + winTop
		window.open(szpage,"email_temp",sPro,true)
	}else{
		alert("Please select survey before customize e-mail template!")
	}
}
function edit_email_template()
{
	document.frm.update_mail.value = "Y";
	document.frm.submit()
}
function accept_update_email_template()
{
	document.frm.accept_update.value = "Y";
	document.frm.submit()
}
function douploadimg()
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 0
	winLeft = 0
	szpage = "templates/upload_logo.htm"
	sPro = "WIDTH=350,HEIGHT=150,scrollbars=no,resize=no,menubar=no,resizable=yes,left=" + winLeft + ",top=" + winTop
	window.open(szpage,"comlogo",sPro,true)
}
function doregister()
{
	var doc = document.frm;
	if(doc.fname.value=="")
	{
		pop_err(doc.fname,'First name must be defined')
		return false;
	}
	if(doc.email.value=="")
	{
		pop_err(doc.email,'E-mail must be defined')
		return false;
	}
	doc.acceptregister.value="OK"
	doc.submit()
	return;
}
function doagreement()
{
	var doc = document.frm;	
	doc.agreement.value="OK"
	doc.submit()
	return;
}
function checkupload()
{
	szfilename = document.frm.blob.value
	szlen = szfilename.length
	szbegin = szlen - 3
	extrafile = szfilename.substr(szbegin,szlen)
	if(extrafile != "jpg" &&  extrafile != "gif")
	{
		alert("File images must be JPG or GIF")
		return false;
	}
}
function enternum(event)
{
	var re = /^[0-9.]+$/;
	var browser = navigator.appName;
	if(browser == "Netscape")
	{
		var keycode = event.which;
	}
	else{
		var keycode = window.event.keyCode;
	}
	if(keycode != 13){
		strKeyCode = String.fromCharCode(keycode);
		if((!strKeyCode.search(re)) || (keycode==8) || (keycode==0))
		{
			return true;
		}else
		{
			return false;
		}
	}
	return true;
}
//function user data
function modifydatauser()
{
	var szcusid = document.frm.cusid.value
	var szpages = "admin_datauser.asp?cusid=" + szcusid
	document.location.replace(szpages)
}
function createcnewdataus()
{
	var doc = document.frm;
	doc.action = "admin_create_datauser.asp"
	doc.submit();
}
function docheckadddatauser()
{
	var doc = document.frm;
	if(doc.fname.value == "")
	{
		pop_err(doc.fname,req_fname)
		return false;
	}
	if(doc.lname.value == "")
	{
		pop_err(doc.lname,req_lname)
		return false;
	}
	szemail = doc.email.value;
	if(szemail == "")
	{
		pop_err(doc.email,req_email)
		return false;
	}
	if(szemail.indexOf('@') == -1)
	{
		pop_err(doc.email,err_email)
		return false;
	}else{
		var arr_email = szemail.split('@')
		var strdomain = arr_email[1];
		if(strdomain.indexOf('.') == -1)
		{
			pop_err(doc.email,err_email)
			return false;
		}else{
			var arr_data = strdomain.split('.')
			var define_name = arr_data[1];
			if(define_name == "")
			{
				pop_err(doc.email,err_email)
				return false;
			}
		}
	}
	doc.checksubmit.value = "OK"
	doc.submit();
}
function docanceldatauser()
{
	var doc = document.frm;
	doc.action = "admin_datauser.asp"
	doc.submit();
}
function dodeletedatauser()
{
	var doc = document.frm;
	if(confirm("Are you sure delete this record?") == true)
	{
		doc.accept_delete.value = "OK";
		doc.submit();
	}	
}
//function data user for useradmin
function usadmin_modifydatauser()
{
	var szcusid = document.frm.cusid.value
	var szpages = "usadmin_datauser.asp?cusid=" + szcusid
	document.location.replace(szpages)
}
function usadmin_createcnewdataus()
{
	var doc = document.frm;
	doc.action = "usadmin_create_datauser.asp"
	doc.submit();
}
function usadmin_docanceldatauser()
{
	var doc = document.frm;
	doc.action = "usadmin_datauser.asp"
	doc.submit();
}
function usadmin_dodeletedatauser()
{
	var doc = document.frm;
	if(confirm("Are you sure delete this record?") == true)
	{
		doc.accept_delete.value = "OK";
		doc.submit();
	}
}
function doimportexcel()
{
	var doc = document.frm;	
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = winW/2 - 260
	winLeft = winH/2 - 180
	szid = doc.cusid.value;
	szpage = "importform_datauser.asp?cusid=" + szid
	sPro = "WIDTH=420,HEIGHT=110,scrollbars=no,resize=no,menubar=no,resizable=yes,left=" + winLeft + ",top=" + winTop
	window.open(szpage,"importdata",sPro,true)
}
function checkimportdata()
{
	var szValue = "";
	if (document.frm.maxrecord.value=="")
	{
		alert("Please enter value for Total Record!")
		document.frm.maxrecord.focus()
		return false;
	}
	if(document.frm.fileimport.value=="")
	{
		alert("Please select file import address!")
		document.frm.fileimport.focus()
		return false;
	}
	szValue = document.frm.fileimport.value;
	if(szValue.indexOf('.xls')==-1)
	{
		alert("File import is false. Please select again!")
		document.frm.fileimport.focus()
		return false;
	}
	document.frm.submit();
	return;
}
//function useradmin load data user
function openlistdatauser()
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 50
	winLeft = 50
	szpage = "usadmin_loaddatauser.asp"
	sPro = "WIDTH=780,HEIGHT=412,scrollbars=no,resize=no,menubar=no,resizable=yes,left=" + winLeft + ",top=" + winTop
	window.open(szpage,"importdata",sPro,true)
}
function usadmin_doclickchooseuser()
{
	var doc = document.frm;
	doc.chkdatauser.value = 1
}
function usadmin_chooseuser()
{
	if(document.frm.chkdatauser.value=="")
	{
		alert("Please select user loading.")
	}else{
		szcusid = document.frm.cusid.value;
		for(var i=0; i< document.frm.chkuser.length;i++)
		{
			if(document.frm.chkuser[i].checked==true)
			{
				szuserid = document.frm.chkuser[i].value;
			}
		}
		szpages = "usadmin_create_customer.asp?cusid=" + szcusid + "&datauserid=" + szuserid
		window.opener.document.location.replace(szpages)
		window.close()
	}
	
}
function manager_openlistdatauser()
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 50
	winLeft = 50
	var szcusid = document.frm.cusid.value
	szpage = "manager_loaddatauser.asp?cusid=" + szcusid
	sPro = "WIDTH=780,HEIGHT=412,scrollbars=no,resize=no,menubar=no,resizable=yes,left=" + winLeft + ",top=" + winTop
	window.open(szpage,"importdata",sPro,true)
}
function manager_chooseuser()
{
	if(document.frm.chkdatauser.value=="")
	{
		alert("Please select user loading.")
	}else{
		szcusid = document.frm.cusid.value;
		for(var i=0; i< document.frm.chkuser.length;i++)
		{
			if(document.frm.chkuser[i].checked==true)
			{
				szuserid = document.frm.chkuser[i].value;
			}
		}
		szpages = "manager_user.asp?datauserid=" + szuserid
		window.opener.document.location.replace(szpages)
		window.close()
	}
	
}
function dosupportsend()
{
	var doc = document.frm;
	if(doc.supname.value=="")
	{
		pop_err(doc.supname,"Please enter your name")
		return false;
	}
	if(doc.supcompany.value=="")
	{
		pop_err(doc.supcompany,"Please enter your company")
		return false;
	}
	if(doc.supphone.value=="")
	{
		pop_err(doc.supphone,"Please enter your phone number")
		return false;
	}	
	szemail = doc.supemail.value;
	if(szemail == "")
	{
		pop_err(doc.supemail,req_email)
		return false;
	}
	if(szemail.indexOf('@') == -1)
	{
		pop_err(doc.supemail,err_email)
		return false;
	}else{
		var arr_email = szemail.split('@')
		var strdomain = arr_email[1];
		if(strdomain.indexOf('.') == -1)
		{
			pop_err(doc.supemail,err_email)
			return false;
		}else{
			var arr_data = strdomain.split('.')
			var define_name = arr_data[1];
			if(define_name == "")
			{
				pop_err(doc.supemail,err_email)
				return false;
			}
		}
	}
	if(doc.description.value=="")
	{
		pop_err(doc.description,"Please enter your description of support request")
		return false;
	}
	doc.accept_send.value = "OK"
	var szpagesubmit = doc.pagesubmit.value
	doc.action = szpagesubmit
	doc.submit()
	return
}
function docheckall_status()
{
	for(var i=0; i<document.frm.chkstatus.length; i++)
	{
		if(document.frm.chkstatus[i].disabled == false)
		{
			document.frm.chkstatus[i].checked = true
		}
	}
}
function douncheckall_status()
{
	for(var i=0; i<document.frm.chkstatus.length; i++)
	{
		if(document.frm.chkstatus[i].disabled == false)
		{
			document.frm.chkstatus[i].checked = false
		}
	}
}
function open_group(id)
{
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 50
	winLeft = 50
	
	if(document.frm.is_public.checked == true){
		var is_public = 1;
	}else{
		var is_public = 0;
	}
	szpage = "group_report.asp?userid=" + id + "&is_public=" + is_public;
	sPro = "WIDTH=600,HEIGHT=229,scrollbars=no,resize=no,menubar=no,resizable=no,left=" + winLeft + ",top=" + winTop
	window.open(szpage,"groupdata",sPro,true)
}
function admin_open_group()
{
	var doc = document.frm;
	var manager = "";	
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight
	winTop = 50
	winLeft = 50
		
	for (var i=0; i<doc.user_admin.length;i++)
	{
		if(doc.user_admin.options[i].selected == true)
		{
			manager = doc.user_admin[i].value
		}
	}
	if(manager != "")
	{
		szpage = "group_report.asp?userid=" + manager
		sPro = "WIDTH=600,HEIGHT=229,scrollbars=no,resize=no,menubar=no,resizable=no,left=" + winLeft + ",top=" + winTop
		window.open(szpage,"groupdata",sPro,true)
	}else{
		pop_err(doc.user_admin,"Please select user admin before customize group report.")
		return false;
	}
}
function customize_group()
{
	var doc = document.frm;
	doc.accept_save.value = "OK"
	doc.submit()
}
function do_resend_mail()
{
	var doc = document.frm;
	doc.accept_resend.value = "OK"
	doc.submit();
}
function sendforgotpass()
{
	var doc = document.frm;
	if(doc.userid.value=="")
	{
		pop_err(doc.userid,"Please enter value username login")
		return false;
	}
	szemail = doc.email.value;
	if(szemail == "")
	{
		pop_err(doc.email,req_email)
		return false;
	}
	if(szemail.indexOf('@') == -1)
	{
		pop_err(doc.email,err_email)
		return false;
	}else{
		var arr_email = szemail.split('@')
		var strdomain = arr_email[1];
		if(strdomain.indexOf('.') == -1)
		{
			pop_err(doc.email,err_email)
			return false;
		}else{
			var arr_data = strdomain.split('.')
			var define_name = arr_data[1];
			if(define_name == "")
			{
				pop_err(doc.email,err_email)
				return false;
			}
		}
	}
	doc.AcceptSend.value = "Y"
	doc.submit();
	return;
}
function print_option()
{
	var doc = document.frm;
	doc.action = "usadmin_print_option.asp"
	doc.submit()
}
function admin_print_option()
{
	var doc = document.frm;
	doc.action = "admin_print_option.asp"
	doc.submit()
}
function GetPrintUrl()
{	
	var obj = window.document.getElementById('CPrintingScriptX');				
	//nho disable button print nha khi nao in xong rui enable lai nho vao viec query result demoi khi nao in xong (o phan duoi)
	var bResult = false;
	
	//Set property to receive result
	var objResult = window.document.getElementById('FlagResult');
	obj.SetResultName(objResult);
	
	obj.StartPrint();
		if(document.frm.URL.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL').value);
		}
		if(document.frm.URL1.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL1').value);
		}
		if(document.frm.URL2.checked == true)
		{			
			obj.SetStringURL(window.document.getElementById('URL2').value);
		}
		if(document.frm.URL3.checked == true)
		{			
			obj.SetStringURL(window.document.getElementById('URL3').value);
		}
		if(document.frm.URL4.checked == true)
		{			
			obj.SetStringURL(window.document.getElementById('URL4').value);
		}
		if(document.frm.URL5.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL5').value);
		}
		if(document.frm.URL6.checked == true)
		{
			obj.SetStringURL(window.document.getElementById('URL6').value);
		}
		if(document.frm.URL7.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL7').value);
		}
		if(document.frm.URL8.checked == true)
		{			
			obj.SetStringURL(window.document.getElementById('URL8').value);
		}
		if(document.frm.URL9.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL9').value);
		}
		if(document.frm.URL10.checked == true)
		{			
			obj.SetStringURL(window.document.getElementById('URL10').value);
		}
		if(document.frm.URL11.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL11').value);
		}
		if(document.frm.URL12.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL12').value);
		}
		if(document.frm.URL13.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL13').value);
		}	
		if(document.frm.URL14.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL14').value);
		}
		if(document.frm.URL15.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL15').value);
		}	
		if(document.frm.URL16.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL16').value);
		}
		if(document.frm.URL17.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL17').value);
		}	
		if(document.frm.URL18.checked == true)
		{		
			obj.SetStringURL(window.document.getElementById('URL18').value);
		}
	obj.EndPrint();	
}
function downsoftware()
{
	alert("Please copy software to your computer. After that you need unzip software by winzip software and setup this software PrintSystemSetupProject.exe on your computer. Thank you.")
	document.location.replace("printsoft/PrintSoftware.zip")
}
function OptionScale(szid)
{
	var doc = document.frm;
	for(k=0; k<doc.maxrating.length; k++)
	{
		if(doc.maxrating.options[k].selected == true)
		{
			var szlevel = doc.maxrating.options[k].value
		}
	}
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	winW = (ns4)? window.innerWidth-16 : document.body.offsetWidth-20
	winH = (ns4)? window.innerHeight : document.body.offsetHeight

	winTop = 50
	winLeft = 50
	szpage = "ratingscale.asp?ratid=" + szid + "&szlevel=" + szlevel
	sPro = "WIDTH=760,HEIGHT=400,scrollbars=yes,resize=no,menubar=no,resizable=no,left=" + winLeft + ",top=" + winTop
	window.open(szpage,"rating",sPro,true)
}
function do_cancel_rating()
{
	var doc = document.frm;
	var chkid = doc.selectid.value
	var szle = doc.szlevel.value
	var szpage = "ratingscale.asp?ratid=" + chkid + "&szlevel=" + szle
	document.location.replace(szpage)
}
function do_addnew_rating()
{
	var doc = document.frm;
	var szlev = doc.szlevel.value
	if(doc.onedesc.value == "")
	{
		pop_err(doc.onedesc,"Please input your 1 description!")
		return false;
	}
	if(doc.twodesc.value == "")
	{
		pop_err(doc.twodesc,"Please input your 2 description!")
		return false;
	}
	if(doc.treedesc.value == "")
	{
		pop_err(doc.treedesc,"Please input your 3 description!")
		return false;
	}
	if(doc.fourdesc.value == "")
	{
		pop_err(doc.fourdesc,"Please input your 4 description!")
		return false;
	}
	if(doc.fivedesc.value == "")
	{
		pop_err(doc.fivedesc,"Please input your 5 description!")
		return false;
	}
	if(szlev >= 6)
	{
		if(doc.sixdesc.value == "")
		{
			pop_err(doc.sixdesc,"Please input your 6 description!")
			return false;
		}
	}
	if(szlev >= 7)
	{	
		if(doc.sevendesc.value == "")
		{
			pop_err(doc.sevendesc,"Please input your 7 description!")
			return false;
		}	
	}
	if(szlev >= 8)
	{
		if(doc.eightdesc.value == "")
		{
			pop_err(doc.eightdesc,"Please input your 8 description!")
			return false;
		}
	}
	if(szlev >= 9)
	{
		if(doc.ninedesc.value == "")
		{
			pop_err(doc.ninedesc,"Please input your 9 description!")
			return false;
		}
	}
	if(szlev >= 10)
	{
		if(doc.tendesc.value == "")
		{
			pop_err(doc.tendesc,"Please input your 10 description!")
			return false;
		}
	}		
	doc.accept_save.value = "OK"
	doc.submit()
	return;
}
function select_rating()
{
	var doc = document.frm;
	doc.accept_select.value = "OK"	
	doc.submit()
}
function do_delete_rating()
{
	var doc = document.frm;
	doc.accept_delete.value = "OK"	
	doc.submit()	
}

function checkComment(obj, skillid){
	var doc = document.frm;
	if(obj.checked == false){
		for(var i=0; i<doc.chkuserskill_comment.length; i++){
			if(doc.chkuserskill_comment[i].value == skillid){
				doc.chkuserskill_comment[i].checked = false;
				doc.chkuserskill_comment[i].disabled = true;
			}
		}
		for(var i=0; i<doc.chkadminskill_comment.length; i++){
			if(doc.chkadminskill_comment[i].value == skillid){
				doc.chkadminskill_comment[i].checked = false;
				doc.chkadminskill_comment[i].disabled = true;
			}
		}
		if(obj.name == "chkuserskill"){
			doc.chkuserall.checked = false;
		}else{
			doc.chkadminall.checked = false;
		}
		// find to uncheck associated group
		if(typeof(doc.chkskillgroup) == "object"){
			for(var i=0; i<doc.chkskillgroup.length; i++){
				var str_id_in_group = "," + doc.chkskillgroup[i].value + ",";
				var search_value = "," + obj.value + ",";
				if(str_id_in_group.indexOf(search_value) != -1){
					doc.chkskillgroup[i].checked = false;
				}
			}
		}
	}else{
		for(var i=0; i<doc.chkuserskill_comment.length; i++){
			if(doc.chkuserskill_comment[i].value == skillid){
				doc.chkuserskill_comment[i].disabled = false;
			}
		}
		for(var i=0; i<doc.chkadminskill_comment.length; i++){
			if(doc.chkadminskill_comment[i].value == skillid){
				doc.chkadminskill_comment[i].disabled = false;
			}
		}
	}
}

function firstloadComment(){
	for(var i=0; i<document.frm.chkuserskill.length; i++){
		if(document.frm.chkuserskill[i].checked == true){
			document.frm.chkuserskill_comment[i].disabled = false;
		}else{
			document.frm.chkuserskill_comment[i].disabled = true;
		}
	}
	for(var i=0; i<document.frm.chkadminskill.length; i++){
		if(document.frm.chkadminskill[i].checked == true)
			document.frm.chkadminskill_comment[i].disabled = false;
		else
			document.frm.chkadminskill_comment[i].disabled = true;
	}
}

function remove_last_expiredate(){
	if(!confirm("Are you sure you want to remove this expire date?")){
		return false;
	}else{	
		document.frm.act.value = "remove_expiredate";
		document.frm.submit();
	}
}

function show_public_div(){
	if(document.frm.ispublic.checked == true){
		document.getElementById("div_cate_public").style.display = "block";
	}else{
		document.getElementById("div_cate_public").style.display = "none";	
	}
}

// time_type = d: Date range, time_type = d: Month
function show_selection(time_type){
	if(time_type == "d"){
		document.getElementById("div_daterange").style.display = "block";
		document.getElementById("div_month").style.display = "none";
	}else{
		document.getElementById("div_daterange").style.display = "none";
		document.getElementById("div_month").style.display = "block";
	}
}

function update_contact(id){
	document.frm.update_id.value = id;
	document.frm.submit();
}

function confirmDelete(){
	var doc = document.frm;
	var is_check = 0;
	for(var i=0; i<doc.length; i++){
		if(doc.elements[i].type == "checkbox" && doc.elements[i].checked == true && doc.elements[i].name == "chkid"){
			is_check = is_check + 1;
			i = doc.length;
		}
	}
	if(is_check == 0){
		alert("Please select contact(s) you want to detele!");
		return false;
	}else{
		if(!confirm("Are you sure you want to delete selected contact(s)?")){
			return false;
		}else{
			return true;	
		}
	}
}

// type = 1: checkbox name = chkid		type = 2: checkbox name = chkid_report
function docheckall(type){
	var doc = document.frm;
	if(type == 1){
		var is_check = doc.chkall.checked;
		for(var i=0; i<doc.length; i++){
			if(doc.elements[i].name == "chkid" && doc.elements[i].disabled == false)
				doc.elements[i].checked = is_check;
		}
	}else if(type == 2){
		var is_check = doc.chkall_report.checked;
		for(var i=0; i<doc.length; i++){
			if(doc.elements[i].name == "chkid_report" && doc.elements[i].disabled == false)
				doc.elements[i].checked = is_check;
		}
	}
}

// type = 1: checkbox name = chkid		type = 2: checkbox name = chkid_report
function docheckitem(type){
	var doc = document.frm;
	if(type == 1){
		var is_check = 0;
		for(var i=0; i<doc.length; i++){
			if(doc.elements[i].type == "checkbox" && doc.elements[i].checked == true && doc.elements[i].name == "chkid")
				is_check = is_check + 1;
		}
		if(is_check == doc.total_item.value)
			doc.chkall.checked = true;
		else
			doc.chkall.checked = false;
	}else{
		var is_check = 0;
		for(var i=0; i<doc.length; i++){
			if(doc.elements[i].type == "checkbox" && doc.elements[i].checked == true && doc.elements[i].name == "chkid_report")
				is_check = is_check + 1;
		}
		if(is_check == doc.total_item_report.value)
			doc.chkall_report.checked = true;
		else
			doc.chkall_report.checked = false;
	}
	
}

function check_public_report(){
	var doc = document.frm;
	if(doc.is_public.checked == true){
		document.getElementById("div_not_public").style.display = "none";
		document.getElementById("div_public").style.display = "block";
	}else{
		document.getElementById("div_not_public").style.display = "block";
		document.getElementById("div_public").style.display = "none";
	}
	doc.tabcode.value = "";
	doc.public_tabcode.value = "";
	doc.expire_date.value = ""
	//doc.submit();
}

function view_new_report(){
	var doc = document.frm;
	var is_check_participant = 0;
	var is_check_report = 0;
	for(var i=0; i<doc.length; i++){
		if(doc.elements[i].type == "checkbox" && doc.elements[i].checked == true && doc.elements[i].name == "chkid"){
			is_check_participant = is_check_participant + 1;
		}
		if(doc.elements[i].type == "checkbox" && doc.elements[i].checked == true && doc.elements[i].name == "chkid_report"){
			is_check_report = is_check_report + 1;
		}
	}
	if(is_check_participant == 0){
		alert("Please select participant!");
		return false;
	}else	if(is_check_report == 0){
		alert("Please select report or cover page!");
		return false;
	}
	doc.act.value = "view_report";
	doc.action = "usadmin_report_new.asp";
	doc.target = "_self";
	doc.submit();
}

function print_new_report(){
	var doc = document.frm;
	var is_check_participant = 0;
	var is_check_report = 0;
	for(var i=0; i<doc.length; i++){
		if(doc.elements[i].type == "checkbox" && doc.elements[i].checked == true && doc.elements[i].name == "chkid"){
			is_check_participant = is_check_participant + 1;
		}
		if(doc.elements[i].type == "checkbox" && doc.elements[i].checked == true && doc.elements[i].name == "chkid_report"){
			is_check_report = is_check_report + 1;
		}
	}
	if(is_check_participant == 0){
		alert("Please select participant!");
		return false;
	}else	if(is_check_report == 0){
		alert("Please select report or cover page!");
		return false;
	}
	doc.act.value = "print_report";
	doc.action = "print_report_new.asp";
	doc.target = "_blank";
	doc.submit();
}

function check_skillingroup(obj){
	var doc = document.frm;
	var arr_skill_id = obj.value.split(',')
	
	for(var i=0; i<doc.chkadminskill.length; i++){
		for(var j=0; j<arr_skill_id.length; j++){
			if(doc.chkadminskill[i].value == arr_skill_id[j]){
				doc.chkadminskill[i].checked = obj.checked;
				doc.chkadminskill_comment[i].disabled = !obj.checked;
				j = arr_skill_id.length;
			}
		}
	}
	if(obj.checked == false)
		doc.chkadminall.checked = false;
}

function check_360skill(obj){
	var doc = document.frm;
	for(var i=0; i<doc.chkadminskill.length; i++){
		doc.chkadminskill[i].checked = obj.checked;
		doc.chkadminskill_comment[i].disabled = !obj.checked;
		if(obj.checked == false){
			doc.chkadminskill_comment[i].checked = obj.checked;
		}
	}
	if(typeof(doc.chkskillgroup) == "object"){
		for(var i=0; i<doc.chkskillgroup.length; i++){
			doc.chkskillgroup[i].checked = obj.checked;
		}
	}
}

function check_userskill(obj){
	var doc = document.frm;
	for(var i=0; i<doc.chkuserskill.length; i++){
		doc.chkuserskill[i].checked = obj.checked;
		doc.chkuserskill_comment[i].disabled = !obj.checked;
		if(obj.checked == false){
			doc.chkuserskill_comment[i].checked = obj.checked;
		}
	}
}

function trim(st)
{
	index = 0;
	for (var i = 0; i < st.length; i++)
	{
		ch = st.charAt(i);
		if (ch == ' ')
			index++;
		else 
			break;
	}
	st = st.substring(index, st.length);
	index = st.length;
	for (i = index-1; i > 0; i--)
	{
		ch = st.charAt(i);
		if (ch==' ')
			index--;
		else
			break;
	}
	st = st.substring(0, index);
	return st;
}
