﻿
function nnv(id) { return document.getElementById(id); }

function showHints(f, field) {                
    var tempmsg = nnv('temp'); //No I18N
    tempmsg.innerHTML = hints[field]; //file commonJs.php
	
    nnv('tempdiv').style.left = findPosX(f)+f.offsetWidth-10+'px';
    nnv('tempdiv').style.top = findPosY(f)-(f.offsetHeight+3)+'px';
    nnv('tempdiv').style.display='';
}

function hideHints() {
    nnv('tempdiv').style.display = 'none'; //No I18N
}
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    }else if (obj.x) { curleft += obj.x; }
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    }else if (obj.y) {
        curtop += obj.y;
    }
    return curtop;
}

//
function changeLange(lang) {
	document.langForm.lang.value = lang ;
	document.langForm.submit();
} 
/********************/
function doChecked(obj, chkname) {
	if(obj.checked)
		checkall(chkname);
	else
		uncheckall(chkname);
}

// check all check box with checkBoxName
function checkall( checkBoxName )
{	
	var el = document.getElementsByName( checkBoxName ) ;
	for(i=0;i<el.length;i++){
		el[i].checked=true ;
	}
}

// un check all check box with checkBoxName
function uncheckall( checkBoxName ){	
	e2 = document.getElementsByName( checkBoxName ) ;
	for(i=0;i<e2.length;i++){
		e2[i].checked = false ; 
	}
}

// checke selected status for all option in select box
function checkSelectBox( formName , selectBoxName ){	
	selectBox = document.formName.selectBoxName ;
	
	for( var i=0 ; i < selectBox.length ; i++ ){
		document.formName.selectBoxName.options[i].selected = true ;
		//alert( 'at : ' + i + ' value : ' + document.formName.selectBoxName.options[i].selected )  ;
	} 
}

function maxLength( _68, len){
	if(_68.value.length>len){
	_68.value=_68.value.substr(0,len);
	}
}


function doSubmit( formName ){
	document.forms[formName].submit();
}

function resetForm( formName ){
	document.forms[formName].reset();
}


function selectAllOptions(selId)
{  	
  var selObj = document.getElementById(selId);
  for (var i=0; i<selObj.options.length; i++) {
       selObj.options[i].selected = true;
  }
}

function toggle(section) {
	var elem = document.getElementById('section_'+ section);
	if (elem) {
		elem.style.display = (elem.style.display != '') ? '' : 'none';
	}
	var img  = document.getElementById('toggle_' + section);
	if (img && img.src == plus.src) {
		img.src = minus.src;
	} else if (img) {
		img.src = plus.src;
	}
}
var minus = new Image(9,9);
var plus  = new Image(9,9);
minus.src = "/image/icon/minus_9x9.gif";
plus.src  = "/image/icon/plus_9x9.gif";


function searchJob(){
	careerId = document.quickSearchForm.careerId.value  ;
	if( careerId > 0 ){
		document.quickSearchForm.submit();
	}	 
}

function saveJob(){
	if( isChecked('riId[]') ){
		document.listJobForm.submit() ;
	}
}

function stopRecievedEmail(actionurl){
	var email = document.mailalert.email.value;
	if( checkEmail(email) == true ){
		document.mailalert.action= actionurl;
		document.mailalert.submit();
	}
}

function sendMail(){
	var email=document.mailalert.email.value;	
	if( checkEmail(email) == true ){
		document.mailalert.submit();
	}	
	return;
}

function updateStatus( id , status ) {	
//	if( confirm( '{#_mah_an_ho_so_xac_nhan_#' ) ){
		document.updateForm.id.value = id ;		 
		document.updateForm.status.value = status ;
		document.updateForm.submit();
	//}
}
