var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;

function pop_err(fieldname,err_msg)
{
	fieldname.focus();
	alert(err_msg);
}

function textLimit(field, maxlen) {
	if (field.value.length > maxlen){
		alert('Your input will be truncated because content must be ' + maxlen + ' characters or less!');
		field.value = field.value.substring(0, maxlen);
	}
}

function goProjectTab(type){
	var doc = document.frm;
	if(type == 1){
		doc.action = "project_detail.asp";
	}else if(type == 2){
		doc.action = "project_task.asp";
	}else if(type == 3){
		doc.action = "project_checklist.asp";
	}else if(type == 4){
		doc.action = "project_version.asp";
	}
	doc.submit();
}

function DoAdd(type){
	var doc = document.frm;
	if(type == 3){
		if(doc.permission.value == 1){
			doc.action = "project_task_detail.asp";
			doc.submit();
		}else{
			alert("Only Administrator or PM can do this action!");
			return false;
		}
	}else if(type == 4){
		doc.action = "check_list_detail.asp";
		doc.submit();
	}else if(type == 6){
		doc.action = "project_version_detail.asp";
		doc.submit();
	}
}

//Type = 1: Project, 	2: User, 	3: Task,	4: Check List,	5: Client,	6: Version
function DoUpdate(type){
	if(type == 1){
		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 == "chkitem"){
				page_direct = "project_detail.asp?pid=" + doc.elements[i].value;
				window.location.replace(page_direct);
			}
		}
	}else if(type == 2){
		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 == "chkitem"){
				page_direct = "user_detail.asp?uid=" + doc.elements[i].value;
				window.location.replace(page_direct);
			}
		}
	}else if(type == 3){
		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 == "chkitem"){
				page_direct = "project_task_detail.asp?tid=" + doc.elements[i].value;
				window.location.replace(page_direct);
			}
		}
	}else if(type == 4){
		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 == "chkitem"){
				page_direct = "check_list_detail.asp?cid=" + doc.elements[i].value;
				window.location.replace(page_direct);
			}
		}
	}else if(type == 5){
		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 == "chkitem"){
				page_direct = "client_detail.asp?cid=" + doc.elements[i].value;
				window.location.replace(page_direct);
			}
		}
	}else if(type == 6){
		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 == "chkitem"){
				page_direct = "version_detail.asp?vid=" + doc.elements[i].value;
				window.location.replace(page_direct);
			}
		}
	}
}

//Type = 1: Project, 	2: User, 	3: Task, 	4: Check List, 	5: Client, 	6: Version
function DoDelete(type){
	var doc = document.frm;
	if(type == 1){
		if(!confirm("Are you sure you want to delete selected project(s)?")){
			return false;
		}else{
			doc.act.value = "del_project";
			doc.submit();
		}
	}else if(type == 2){
		if(!confirm("Are you sure you want to delete selected user(s)?")){
			return false;
		}else{
			doc.act.value = "del_user";
			doc.submit();
		}
	}else if(type == 3){
		if(doc.permission.value == 1){
			if(!confirm("Are you sure you want to delete selected task(s)?")){
				return false;
			}else{
				doc.act.value = "del_task";
				doc.submit();
			}
		}else{
			alert("Only Administrator or PM can do this action!");
			return false;
		}
	}else if(type == 4){
		if(!confirm("Are you sure you want to delete selected check list(s)?")){
			return false;
		}else{
			doc.act.value = "del_checklist";
			doc.submit();
		}
	}else if(type == 5){
		if(!confirm("Are you sure you want to delete selected client(s)?")){
			return false;
		}else{
			doc.act.value = "del_client";
			doc.submit();
		}
	}else if(type == 6){
		if(!confirm("Are you sure you want to delete selected version(s)?")){
			return false;
		}else{
			doc.act.value = "del_version";
			doc.submit();
		}
	}
}

function validateProject(){
	var doc = document.frm;
	if(doc.project_name.value == ""){
		pop_err(doc.project_name, "Please enter Project Name!");
		return false;
	}
	if(doc.start_date.value == ""){
		pop_err(doc.start_date, "Please enter Start Date!");
		return false;
	}
	if(doc.percent_complete.value != "" && !isInteger(doc.percent_complete.value)){
		pop_err(doc.percent_complete,"% complete must be integer! Please input again!");
		return false;
	}
	if(doc.totalhours.value != "" && !isNumeric(doc.totalhours.value)){
		pop_err(doc.totalhours,"Total hour must be numerical! Please input again!");
		return false;
	}
	if(doc.pid.value == ""){
		doc.act.value = "add";
	}else{
		doc.act.value = "update";	
	}
	return true;	
}

function validateTask(){
	var doc = document.frm;
	if(doc.permission.value == 1){
		if(doc.task_name.value == ""){
			pop_err(doc.task_name, "Please enter Task Name!");
			return false;
		}
		if(doc.status.value == ""){
			pop_err(doc.status, "Please select Status!");
			return false;
		}
		if(doc.assigned_date.value == ""){
			pop_err(doc.assigned_date, "Please enter Assigned Date!");
			return false;
		}
		if(doc.total_hours.value != "" && !isNumeric(doc.total_hours.value)){
			pop_err(doc.total_hours,"Total hour must be numerical! Please input again!");
			return false;
		}
		if(doc.percent_complete.value != "" && !isInteger(doc.percent_complete.value)){
			pop_err(doc.percent_complete,"% complete must be integer! Please input again!");
			return false;
		}
		if(doc.assigned_to.value == ""){
			pop_err(doc.assigned_to, "Please select user to assign task!");
			return false;
		}
		if(doc.tid.value == ""){
			doc.act.value = "add";
		}else{
			doc.act.value = "update";	
		}
		return true;
	}else{
		alert("You don't have permission to do this action!");
		return false;
	}
}

function validateVersion(){
	var doc = document.frm;
	if(doc.version.value == ""){
		pop_err(doc.version, "Please enter Version!");
		return false;
	}else if(!checkKeyword(doc.version.value)){
		pop_err(doc.version, "Version must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.version_url.value == ""){
		pop_err(doc.version_url, "Please enter URL!");
		return false;
	}else if(!checkKeyword(doc.version_url.value)){
		pop_err(doc.version_url, "URL must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.total_hours.value != "" && !isNumeric(doc.total_hours.value)){
		pop_err(doc.total_hours,"Total hour must be numerical! Please input again!");
		return false;
	}
	if(doc.dms_note.value != "" && !checkKeyword(doc.dms_note.value)){
		pop_err(doc.dms_note, "DMS's Note must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.vid.value == ""){
		doc.act.value = "add";
	}else{
		doc.act.value = "update";	
	}
	return true;
}

function validateClient(){
	var doc = document.frm;
	if(doc.company.value == ""){
		pop_err(doc.company, "Please enter Company Name!");
		return false;
	}else if(!checkKeyword(doc.company.value)){
		pop_err(doc.company, "Company Name must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.contact_name.value == ""){
		pop_err(doc.contact_name, "Please enter Contact Name!");
		return false;
	}else if(!checkKeyword(doc.contact_name.value)){
		pop_err(doc.contact_name, "Contact Name must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.address.value != "" && !checkKeyword(doc.address.value)){
		pop_err(doc.address, "Address must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.city.value != "" && !checkKeyword(doc.city.value)){
		pop_err(doc.city, "City must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.zipcode.value != "" && !checkKeyword(doc.zipcode.value)){
		pop_err(doc.zipcode, "Zip code must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.email.value == ""){
		pop_err(doc.email, "Please enter Email!");
		return false;
	}else if(!isemailaddress(doc.email.value)){
		pop_err(doc.email, "E-mail is not valid. Please try again!");
		return false;
	}
	if(doc.password.value == ""){
		pop_err(doc.password, "Password must not be blank!");
		return false;
	}else if(doc.password.value.length < 5){
		pop_err(doc.password, "Password must have at least 5 characters!");
		return false;
	}else if(!checkKeyword(doc.password.value)){
		pop_err(doc.password, "Password must not contain keyword '<script>' or '</script>!");
		return false;
	}
	if(doc.phone.value != "" && !checkKeyword(doc.phone.value)){
		pop_err(doc.phone, "Phone must not contain keyword '<script>' or '</script>!");
		return false;
	}
	for(i=doc.project_selected.length-1; i>=0; i--)  {
		doc.project_selected.options[i].selected = true;
	}
	if(doc.cid.value == ""){
		doc.act.value = "add";
	}else{
		doc.act.value = "update";	
	}
	return true;
}

function validateMember(){
	var doc = document.frm;
	if(doc.uid.value == ""){
		doc.act.value = "add";
	}else{
		doc.act.value = "update";	
	}
	return true;	
}

function validateCheckList(){
	var doc = document.frm;
	if(doc.title.value == ""){
		pop_err(doc.title, "Please enter Title!");
		return false;
	}
	if(doc.cid.value == ""){
		doc.act.value = "add";
	}else{
		doc.act.value = "update";	
	}
	return true;	
}

function setComment(){
	var doc = document.frm;
	var comment_str = "";
	var id_str = "";
	var comment_checklist = "";
	var checklist_value = ""
	for(var i=0; i<doc.length; i++){
		if(doc.elements[i].type == "checkbox" && doc.elements[i].checked == true && doc.elements[i].name == "checklist"){
			checklist_value = doc.elements[i].value;
			var checklist_arr = checklist_value.split("-|-");
			comment_str = comment_str + checklist_arr[1] + "\n";
			id_str = id_str + checklist_arr[0] + ",";
		}
	}
	doc.comment.value = comment_str;
	doc.checklist_str.value = id_str;
}

function saveComment(type){
	var oForm = document.frm;
	var err = 0;
	if(type == "PH"){
		if(oForm.p_comment.value == ""){
			pop_err(oForm.p_comment, "Please enter comment!");
			err = 1;
		}
	}else if(type == "MA"){
		if(oForm.m_comment.value == ""){
			pop_err(oForm.m_comment, "Please enter comment!");
			err = 1;
		}
	}else if(type == "ME"){
		if(oForm.t_comment.value == ""){
			pop_err(oForm.t_comment, "Please enter comment!");
			err = 1;
		}
	}
	if(err == 0){
		if(oForm.comment_id.value == ""){
			oForm.act.value = "add_comment";
		}else{
			oForm.act.value = "edit_comment";	
		}
		oForm.comment_type.value = type;
		var sBody = getRequestBody(oForm);	
		var oXmlHttp = zXmlHttp.createRequest();	
		oXmlHttp.open("post", "comment_action.asp", true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () 
		{
			if (oXmlHttp.readyState == 4) {
				if (oXmlHttp.status == 200) {
					if(type == "PH"){
						document.getElementById("div_phillip_comment").innerHTML = oXmlHttp.responseText;
					}else if(type == "MA"){
						document.getElementById("div_manager_comment").innerHTML = oXmlHttp.responseText;
					}else if(type == "ME"){
						document.getElementById("div_member_comment").innerHTML = oXmlHttp.responseText;
					}
				} else {
					alert("An error occurred: " + oXmlHttp.statusText);
				}
			}            
		};
		if(type == "PH"){
			oForm.p_comment.value = "";
			document.getElementById("label_phillip_comment").innerHTML = "Add";
		}else if(type == "MA"){
			oForm.m_comment.value = "";	
			document.getElementById("label_manager_comment").innerHTML = "Add";
		}else if(type == "ME"){
			oForm.t_comment.value = "";	
			document.getElementById("label_member_comment").innerHTML = "Add";
		}
		oForm.comment_id.value = "";
		oForm.comment_type.value = "";
		oXmlHttp.send(sBody);
	}
}

function editComment(id, type){
	var oForm = document.frm;
	var comment_edit = "comment" + id;
	var comment_value = document.getElementById(comment_edit).value;
	if(type == "PH"){
		oForm.p_comment.value = comment_value;
		document.getElementById("label_phillip_comment").innerHTML = "Update";
	}else if(type == "MA"){
		oForm.m_comment.value = comment_value;
		document.getElementById("label_manager_comment").innerHTML = "Update";
	}else if(type == "ME"){
		oForm.t_comment.value = comment_value;
		document.getElementById("label_member_comment").innerHTML = "Update";
	}
	oForm.comment_id.value = id;
	oForm.comment_type.value = type;
}

function delComment(id, type){
	if(!confirm("Are you sure you want to delete this comment?")){
		
	}else{
		var oForm = document.frm;
		oForm.act.value = "del_comment";
		oForm.comment_id.value = id;
		oForm.comment_type.value = type;
		var sBody = getRequestBody(oForm);	
		var oXmlHttp = zXmlHttp.createRequest();	
		oXmlHttp.open("post", "comment_action.asp", true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () 
		{
			if (oXmlHttp.readyState == 4) {
				if (oXmlHttp.status == 200) {
					if(type == "PH"){
						document.getElementById("div_phillip_comment").innerHTML = oXmlHttp.responseText;
					}else if(type == "MA"){
						document.getElementById("div_manager_comment").innerHTML = oXmlHttp.responseText;
					}else if(type == "ME"){
						document.getElementById("div_member_comment").innerHTML = oXmlHttp.responseText;
					}
				} else {
					alert("An error occurred: " + oXmlHttp.statusText);
				}
			}            
		};
		oForm.comment_id.value = "";
		oForm.comment_type.value = "";
		oXmlHttp.send(sBody);
	}
}

function docheckall()
{
	var doc = document.frm;
	var is_check = document.frm.chkall.checked;
	for(var i=0; i<doc.length; i++){
		if(doc.elements[i].type == "checkbox")
			doc.elements[i].checked = is_check;
	}	
	if(is_check == true){
		doc.cmdDelete.disabled = false;
		if(doc.total_item.value == 1){
			doc.cmdUpdate.disabled = false;
		}else{
			doc.cmdUpdate.disabled = true;
		}
	}else{
		doc.cmdDelete.disabled = true;
		doc.cmdUpdate.disabled = true;
	}
}

function docheckitem()
{
	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 == "chkitem")
			is_check = is_check + 1;
	}
	if(is_check > 0){
		doc.cmdDelete.disabled = false;
	}else{
		doc.cmdDelete.disabled = true;
	}
	if(is_check == 1)
		doc.cmdUpdate.disabled = false;
	else
		doc.cmdUpdate.disabled = true;
	if(is_check == doc.total_item.value)
		doc.chkall.checked = true;
	else
		doc.chkall.checked = false;
}

function getRequestBody(oForm)
{
	 var aParams = new Array();            
     for (var i=0 ; i < oForm.elements.length; i++) {
         var sParam = encodeURIComponent(oForm.elements[i].name);
         sParam += "=";
         sParam += encodeURIComponent(oForm.elements[i].value);
         aParams.push(sParam);
     }      
     return aParams.join("&"); 
}

function ClientCalculateValue()
{
	var doc = document.frmLogin;
	var szPW = doc.loginpass.value;
	szPW +=sharedValue;
	return calcValue(szPW);
}

function doLogin()
{
	var doc = document.frm;
	if(doc.username.value == ""){
		pop_err(doc.username, "Please enter user name!");
		return false;
	}
	if(doc.password.value == ""){
		pop_err(doc.password, "Please enter password!");
		return false;
	}
	doc.act.value = "login";
	return true;
}

function changePassword(){
	var doc = document.frm;
	if(doc.password.value == ""){
		pop_err(doc.password, "Please enter password!");
		return false;
	}
	if(doc.new_password.value == ""){
		pop_err(doc.new_password, "Please enter new password!");
		return false;
	}else if(doc.new_password.value.length < 5){
		pop_err(doc.new_password, "New Password must have at least 5 characters!");
		return false;
	}else if(!checkKeyword(doc.new_password.value)){
		pop_err(doc.new_password, "New Password must not contain keyword '<script>' or '</script>!");
		return false;
	}else{
		if(doc.new_password.value != doc.confirm_password.value){
			pop_err(doc.new_password, "New password and Confirm password do not match. Please try again!");
			return false;
		}
	}
	doc.act.value = "change_password";
	return true;
}

function openAttachForm(pid){
	var page = "upload_form.asp?pid=" + pid;
	window.open(page, "Attach_File", "height=175,width=500,scrollbars=no");
}

function checkUploadForm(){
	if(trim(document.frm.attach_file.value) == ""){
		alert("Please select a file to import!");
		return false;
	}else{
		document.getElementById("import").style.visibility = "hidden";
	}
}

function loadAttachment(){
	var oForm = document.frm;
	oForm.act.value = "load_attachment";
	var sBody = getRequestBody(oForm);	
	var oXmlHttp = zXmlHttp.createRequest();	
	oXmlHttp.open("post", "attachment_action.asp", true);
	oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	oXmlHttp.onreadystatechange = function () 
	{
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
				document.getElementById("div_attachment").innerHTML = oXmlHttp.responseText;
			} else {
				alert("An error occurred: " + oXmlHttp.statusText);
			}
		}            
	};
	oForm.act.value = "";
	oXmlHttp.send(sBody);
}

function delAttachment(id){
	if(!confirm("Are you sure you want to delete this attachment?")){
		
	}else{
		var oForm = document.frm;
		oForm.act.value = "del_attachment";
		oForm.attachment_id.value = id;
		var sBody = getRequestBody(oForm);	
		var oXmlHttp = zXmlHttp.createRequest();	
		oXmlHttp.open("post", "attachment_action.asp", true);
		oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oXmlHttp.onreadystatechange = function () 
		{
			if (oXmlHttp.readyState == 4) {
				if (oXmlHttp.status == 200) {
					document.getElementById("div_attachment").innerHTML = oXmlHttp.responseText;
				} else {
					alert("An error occurred: " + oXmlHttp.statusText);
				}
			}            
		};
		oForm.attachment_id.value = "";
		oForm.act.value = "";
		oXmlHttp.send(sBody);
	}
}

function goCheckListTab(type){
	var doc = document.frm;
	if(type == 1){
		doc.action = "check_list.asp";
	}else if(type == 2){
		doc.action = "checklist_assign.asp";
	}
	doc.submit();
}

function saveProjectCheckList(){
	var doc = document.frm;
	var is_selected = 1;
	if(doc.checklist_selected.length == 0){
		is_selected = 0;
	}
	if(is_selected == 0){
		if(!confirm("You do not select any check list to assign for project. Are you sure you want to continue with this selection?"))
			return false;
	}
	for(i=doc.checklist_selected.length-1; i>=0; i--)  {
		doc.checklist_selected.options[i].selected = true;
	}
	doc.act.value = "save";
	return true;
}

// Count the appearance of substring in string
function countString(pstring, sub_string) {
	var temp = pstring; // temporary holder
	var result = 0;
	while (temp.indexOf(sub_string) != -1) {
		temp = temp.replace(sub_string, 'AAAAAAAAAA');
		result = result + 1;
	}
	return result;
}

function moveOptions(theSelFrom, theSelTo){
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)  {
    if(theSelFrom.options[i].selected)    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
  if(NS4) history.go(0);
}

function addOption(theSel, theText, theValue){
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex){ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

//check numeric
function isInteger(num){
	var re = /^[0-9]*$/;
	num = trim(num);
	var pos = num.search(re);
	if(pos == -1){
		return false;
	}else{
		return true;
	}
}

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;
}

function check_url(str_url)
{
	var arr = new Array();
	var re = /[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*:\/\/([0-9a-zA-Z-_`!@$&*+|\]\[:;?,~=]+)+(\.[0-9a-zA-Z-_`!@$&*+|\]\[:;?,~=]+)*(\/[0-9a-z A-Z-_`!@$&*+|\]\[:;?,~.=]*)*$/;
	str_url = trim(str_url);
	if(str_url.search(re)){
		return false;
	} else{
		pos_pointslash = str_url.indexOf("./");
		pos_slashpoint = str_url.indexOf("/.");
		if(pos_pointslash != -1 || pos_slashpoint != -1)
			return false;
		arr = str_url.split("//");
		if(arr.length > 2)
			return false;
		return true;
	}
}

function isNumeric(num){
	return !isNaN(num);
}

function checkKeyword(string){
	var string_lower = string.toLowerCase();
	if(string_lower.indexOf("<script") != -1 || string_lower.indexOf("</script") != -1
			|| string_lower.indexOf("&lt;script") != -1 || string_lower.indexOf("&lt;/script") != -1){
		return false;
	}
	return true;
}

function isemailaddress(str_email){
	var re = /^[0-9a-z-A-Z-_~=:,|\/\\\'\"]+(\.[0-9a-z-A-Z-_~=:,|\/\\\'\"]+)*@[0-9a-z-A-Z-_~=:,|\/\\\'\"]+(\.[0-9a-z-A-Z-_~=:,|\/\\\'\"]+)+(\.[0-9a-z-A-Z-_~=:,|\/\\\'\"]+)*$/;
	var pos = str_email.search(re);
	if(pos == -1){
		return false;
	}else{
		return true;
	}
}
