var oktosubmit = 0;
var bool = 0;

function ajaxcufon() {
Cufon.replace('h1,h3,.euro,#join-mnl-grid th, ,#join-mnl-grid td, .mediaPortfolio', { fontFamily: 'Eurostile LT Std', hover: true });
Cufon.replace('h4,.bank,th', { fontFamily: 'BankGothic Lt BT', hover: true });
}

function submitter(currpage, param1, param2, param3, param4, param5, param6, param7, param8){
var oktosubmit = 1;
var frm = eval('document.form1');

if(oktosubmit == 1){
//if(currpage || param1 || param2 || param3 || param4 || param5 || param6 || param7 || param8 ){
url = "index.php?page="+currpage;
if(param1) url = url+"&"+param1;
if(param2) url = url+"&"+param2;
if(param3) url = url+"&"+param3;
if(param4) url = url+"&"+param4;
if(param5) url = url+"&"+param5;
if(param6) url = url+"&"+param6;
if(param7) url = url+"&"+param7;
if(param8) url = url+"&"+param8;
frm.action = url;
//}
frm.submit();
}
}

function submittergeneral(currpage, param1, param2, param3, param4, param5, param6, param7, param8, form) {
var oktosubmit = 1;
var frm = eval('document.getElementById(form)');

if(oktosubmit == 1){
url = "index.php?page="+currpage;
if(param1) url = url+"&"+param1;
if(param2) url = url+"&"+param2;
if(param3) url = url+"&"+param3;
if(param4) url = url+"&"+param4;
if(param5) url = url+"&"+param5;
if(param6) url = url+"&"+param6;
if(param7) url = url+"&"+param7;
if(param8) url = url+"&"+param8;
frm.action = url;
frm.submit();
}
}

function submitsearch(currpage, param1, param2, param3, param4, param5, param6, param7, param8){
var oktosubmit = 1;
var frm = eval('document.searchform');

if(oktosubmit == 1){
url = "index.php?page="+currpage;
if(param1) url = url+"&"+param1;
if(param2) url = url+"&"+param2;
if(param3) url = url+"&"+param3;
if(param4) url = url+"&"+param4;
if(param5) url = url+"&"+param5;
if(param6) url = url+"&"+param6;
if(param7) url = url+"&"+param7;
if(param8) url = url+"&"+param8;
frm.action = url;
frm.submit();
}
}

function submitform(currpage, param1, param2, param3, param4, param5, param6, param7, param8, form, strcomment) {
var oktosubmit = 1;
var frm = eval('document.getElementById(form)');
if(oktosubmit == 1){
url = "index.php?page="+currpage;
if(param1) url = url+"&"+param1;
if(param2) url = url+"&"+param2;
if(param3) url = url+"&"+param3;
if(param4) url = url+"&"+param4;
if(param5) url = url+"&"+param5;
if(param6) url = url+"&"+param6;
if(param7) url = url+"&"+param7;
if(param8) url = url+"&"+param8;
frm.action = url;
frm.onsubmit = confirmdelete3(strcomment);
if(frm.onsubmit)
frm.submit();
else
frm.submit.disabled=true;
}
}

//function to check total number of CheckBoxes
//that are checked in a form
function countChecks(checkname)
{
//alert(checkname);
//initialize total count to zero
var chkname;
var totalChecked = 0;
//get total number of CheckBoxes(BY NAME) in form
//var chkBoxCount = document.getElementsByName('categoryid[]').length;
var chkBoxCount = document.getElementsByName(checkname).length;
//alert(chkBoxCount);
//loop through each CheckBox
for (var i = 0; i < chkBoxCount; i++)
{
//check the state of each CheckBox
//(GET CHECKBOX BY ID)
if (checkname == 'categoryid[]') {
if (eval("document.getElementById('categoryid[" + i + "]').checked") == true)
{
//it's checked so increment the counter
chkname = eval("document.getElementById('categoryid[" + i + "]').value");
totalChecked += 1;
}
} else if (checkname == 'word[]') {
if (eval("document.getElementById('word[" + i + "]').checked") == true)
{
//it's checked so increment the counter
chkname = eval("document.getElementById('word[" + i + "]').value");
totalChecked += 1;
}
} else if (checkname == 'oid[]') {
if (eval("document.getElementById('oid[" + i + "]').checked") == true)
{
//it's checked so increment the counter
chkname = eval("document.getElementById('oid[" + i + "]').value");
totalChecked += 1;
}
} else if (checkname == 'nameid[]') {
if (eval("document.getElementById('nameid[" + i + "]').checked") == true)
{
//it's checked so increment the counter
chkname = eval("document.getElementById('nameid[" + i + "]').value");
totalChecked += 1;
}
}
}
return totalChecked;
}

function submittheform(currpage, param1, param2, param3, param4, param5, param6, param7, param8, form) {
var oktosubmit = 1;
var frm = eval('document.getElementById(form)');
if(oktosubmit == 1){
url = "index.php?page="+currpage;
if(param1) url = url+"&"+param1;
if(param2) url = url+"&"+param2;
if(param3) url = url+"&"+param3;
if(param4) url = url+"&"+param4;
if(param5) url = url+"&"+param5;
if(param6) url = url+"&"+param6;
if(param7) url = url+"&"+param7;
if(param8) url = url+"&"+param8;
frm.action = url;
frm.submit();
}
}

function isNumberKey(evt,id){
var value = document.getElementById(id).value;
var charCode = (evt.which) ? evt.which : event.keyCode
if(charCode == 8){
if(value == 0) {
value = 1;
}
return true;
}
if (charCode > 31 && (charCode < 48 || charCode > 57) ){
return false;
}
return true;
}

function NotZeroValue(id) {
var value = document.getElementById(id).value;
if(value == null){
return false
}
if(value == 0) {
return false
}
return true;
}

function confirmdelete(objtodelete) {
var b = confirm('Do you want to delete '+objtodelete+'?\nClick \'OK\' to confirm');

if(b)
return 1;
else
return 0;
}

function confirmdelete1() {
var answer = confirm('Do you want to delete this catgegory?\nAll words in this catgegory will be deleted\nClick \'OK\' to confirm');
if(answer)
return true;
else
return false;
}

function confirmdelete2() {
var answer = confirm('Do you want to delete this word?\nThe meaning of this word will also deleted.\nClick \'OK\' to confirm');
if(answer)
return true;
else
return false;
}
//for general purpose
function confirmdelete3(comment) {

var answer = confirm(comment);
if(answer)
return true;
else
return false;
}

/*FOR GENERAL PURPOSE*/
//how to use: id of object as parameter that should have value
function SubmitIfAllWasFilled() {
for(var i=0; i<arguments.length; i++) {
if(trim(document.getElementById(arguments[i]).value) == '') {
alert('Please fill up the blank');
return false;
}
}
return true;
}

function SubmitAllIFShowAndFilled() {
for(var i=0; i<arguments.length; i++) {
if(i < 4) {
if(trim(document.getElementById(arguments[i]).value) == '') {
setBool(0);
alert('Please fill up the blank');
return false;
}
}
if(i > 3 && i < 8 && document.getElementById('ref2').style.display == 'block') {
if(trim(document.getElementById(arguments[i]).value) == '') {
setBool(0);
alert('Please fill up the blank');
return false;
}
}
if(document.getElementById('ref3').style.display == 'block') {
if(trim(document.getElementById(arguments[i]).value) == '') {
setBool(0);
alert('Please fill up the blank');
return false;
}
}
}
setBool(1);
return true;
}

function setBool(mybool) {
this.bool = mybool;
}

function getBool(){
return this.bool;
}

function SubmitIfAllFilled(id1,id2, id3) {
if((document.getElementById(id1).value != "") && (document.getElementById(id2).value != "") && (document.getElementById(id3).value != "")) {
return true;
} else {
alert('Please fill up the blank');
return false;
}
}

/*submit if 1 field is not null*/
function SubmitIfFilled(id1) {
if(document.getElementById(id1).value != "") {
return true;
} else {
alert('Please name the category');
return false;
}
}

// add/remove option from using two select boxes

var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

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;
}
}

function moveOptions(theSelFrom, theSelTo, mode){
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;
if(mode==1){
deleteOption(theSelFrom, i);
}
selectedCount++;
}
}

if(mode==0){
// 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]);
}
}

if(NS4) history.go(0);
}

function transfertohidden(mainsel, hiddentemp){
var mainLength = mainsel.length;

hiddentemp.value = '';
for(i=mainLength-1; i>=0; i--)
{
if(i == mainLength-1){
hiddentemp.value = mainsel.options[i].value;
}
else{
hiddentemp.value = hiddentemp.value +','+ mainsel.options[i].value;
}
}
}

function expandcollapse(elem){
if(document.getElementById(elem).className   == "minimize")
document.getElementById(elem).className = "maximize";
else
document.getElementById(elem).className = "minimize";
}

function expand(elem, elem2){
document.getElementById(elem).className = "maximize";
document.getElementById(elem2).className = "minimize";
}

function checkIfEmpty(fld, req){
error = sEmpty(fld, req);
}

function showprintablepage() {
var WinOpen = window.open('', '', 'left=0, top=0, width=0, height=0, visible=false, toolbar=0, scrollbars=1, status=0');
var css = '<style type="text/css">@import url("themes/hrms/stylesheets/reports.css");</style>';
var hdr = document.getElementById('head');
var printer = document.getElementById('report');
var content = hdr.innerHTML+printer.innerHTML;

WinOpen.document.write(css+'<br /><table border=0><tr><td>'+content+'</td></tr></table>');
WinOpen.document.close();
WinOpen.print();
}

function isNumeric(elem, helperMsg){
var error = "";
var numericExpression = /^[0-9]+$/;

if(elem.value.length == 0) {
elem.style.background = 'Yellow';
error = 'Please Provide a Number';
elem.focus();
}
else if(!elem.value.match(numericExpression)){
elem.style.background = 'Yellow';
error = elem.value+' is not a number';
elem.focus();
} else {
elem.style.background = 'White';
}
return error;
}

function EnableSaveIfFilled(elem, btnelem){
if(elem.value != '')
document.getElementById(btnelem).disabled=false;
else
document.getElementById(btnelem).disabled=true;
}

function CheckIfEmpty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg+' has not been filled in');
elem.focus();
return false;
}else{
return true;
}
}

function trim(s){
return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld, req) {
var error="";
var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;

if (fld.value == "") {
fld.style.background = 'Yellow';
error = req + " has not been filled in.\n";
} else if (!emailFilter.test(tfld)) {              //test email for illegal characters
fld.style.background = 'Yellow';
error = "Please enter a valid email address.\n";
} else if (fld.value.match(illegalChars)) {
fld.style.background = 'Yellow';
error = "The email address contains illegal characters.\n";
} else {
fld.style.background = 'White';
}
fld.focus();
return error;
}

function validateEmpty(fld, req) {
var error = "";
if (fld.value.length == 0) {
fld.style.background = 'Yellow';
fld.focus();
error = req + " has not been filled in.\n"
}
else {
fld.style.background = 'white';
}
return error;
}

function validateContactUsForm(formname) {
var reason = "";
var theForm = eval('document.'+formname);
if(reason == "") reason += validateEmpty(theForm.name, 'Name');
if(reason == "") reason += validateEmail(theForm.email, 'Email Address');
if(reason == "") reason += validateEmpty(theForm.message, 'Message');

if (reason != "") {
alert("Some fields need correction:\n" + reason);
return false;
}
return true;
}

function validateInquiryForm(theForm) {
var reason = "";
if(reason == "") reason += validateEmpty(theForm.contact_person, 'Contact Person');
if(reason == "") reason += validateEmpty(theForm.company, 'Company');
if(reason == "") reason += validateEmpty(theForm.tel_country_code, 'Telephone Country Code');
if(reason == "") reason += validateEmpty(theForm.tel_area_code, 'Telephone Area Code');
if(reason == "") reason += validateEmpty(theForm.tel_no, 'Telephone Number');
if(reason == "") reason += validateEmail(theForm.email, 'Email Address');
if(reason == "") reason += validateEmpty(theForm.message, 'Message');

if (reason != "") {
alert("Some fields need correction:\n" + reason);
return false;
}
return true;
}

function validateForm(theForm) {
var reason = "";
if(reason == "") reason += validateEmpty(theForm.category, 'Job Category');
if(reason == "") reason += validateEmpty(theForm.position, 'Position');
if(reason == "") reason += validateEmpty(theForm.salary, 'Expected Salary');
if(reason == "") reason += validateEmpty(theForm.lname, 'Last Name');
if(reason == "") reason += validateEmpty(theForm.fname, 'First Name');
if(reason == "") reason += isNumeric(theForm.bdyear, 'Birth Year');
if(reason == "") reason += validateEmpty(theForm.nationality, 'Nationality');
if(reason == "") reason += validateEmail(theForm.email1, 'Email Address');
if(reason == "") reason += validateEmpty(theForm.address1, 'Address');
if(reason == "") reason += isNumeric(theForm.postalcode, 'Postal Code');
if(reason == "") reason += validateEmpty(theForm.state, 'State');
if(reason == "") reason += validateEmpty(theForm.city, 'City');

if (reason != "") {
alert("Some fields need correction:\n" + reason);
return false;
}
return true;
}

function validateYear(obj, yr){
res = isNumeric(obj, '');
if(res != '') obj.value=yr;
if(obj.value < 1900) obj.value=yr;
if(obj.value > 2020) obj.value=yr;
}

function tooltip(elem,e){
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY) 	{
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY) 	{
posx = e.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}

var tmpDiv = El('tooltipdiv');
if (tmpDiv == null) return;

tmpDiv.style.top = (posy - 100) + "px";
tmpDiv.style.left = (posx-440) + "px";

tmpDiv.innerHTML=document.getElementById(elem).innerHTML
tmpDiv.style.display="block";
}

function confirmassessed(obj) {
var b = confirm('Do you want to mark  '+obj+' as assssed?\nClick \'OK\' to confirm');

if(b)
return 1;
else
return 0;
}

function validateFormETC(theForm) {
var reason = "";

if(reason == "") reason += validateEmail(theForm.email_to, 'Recipient Email Address');
if(reason == "") reason += validateEmail(theForm.email_from, 'Sender Email Address');
if(reason == "") reason += validateEmpty(theForm.subject, 'Subject');
if(reason == "") reason += validateEmpty(theForm.salutation, 'Salutation');
if(reason == "") reason += validateEmpty(theForm.recname, 'Recipient Name');
if(reason == "") reason += validateEmpty(theForm.message, 'Message');
if(reason == "") reason += validateEmpty(theForm.closing, 'Closing');
if(reason == "") reason += validateEmpty(theForm.sendername, 'Sender Name');

if (reason != "") {
alert("Some fields need correction:\n" + reason);
return false;
}

return true;
}

function simplesubmit(formname)
{
var frm = eval('document.'+formname);
frm.submit();
}