function txtBlur(ele, action, defVal) {

if(action == "blur") {
        ele.value = ele.value.replace(/^\s+/,'');
        ele.value = ele.value.replace(/\s+$/,'');
        if(ele.value=="") {
            ele.value=defVal; 
            ele.style.color="#8D8D8D";
        }
    }
    else if(action == "focus" && ele.value == defVal) {
ele.value="";
        ele.style.color="#444";    
    }
}

function shuffle_topemployers()
{
   try {
        if (!featuredCount || !featuredColSize) // in case bms is down
            return;
        var i, j, k, x, featuredEles_arr = new Array(featuredCount);
        for (i=1; i<=featuredCount; ++i)
            featuredEles_arr[i-1] = document.getElementById("fc_id_" + i);
        var origInnerHTML_arr = new Array(featuredCount%featuredColSize);
        // Shuffle the Logos
        for(j, x, i=featuredCount; i; j=parseInt(Math.random() * i), x=featuredEles_arr[--i].innerHTML, featuredEles_arr[i].innerHTML = featuredEles_arr[j].innerHTML, featuredEles_arr[j].innerHTML = x);
    }
    catch(e) {}
}

function keyblank() {
    var qp=gbi("qp");
    qp.value = qp.value.replace(/^\s+/,'');
    qp.value = qp.value.replace(/\s+$/,'');

    var ql=document.getElementById("ql");
    ql.value = ql.value.replace(/^\s+/,'');
    ql.value = ql.value.replace(/\s+$/,'');

    var qe=document.getElementById("qe");
    qe.value = qe.value.replace(/^\s+/,'');
    qe.value = qe.value.replace(/\s+$/,'');

    var qf=document.getElementById("qf");
    qf.value = qf.value.replace(/^\s+/,'');
    qf.value = qf.value.replace(/\s+$/,'');

    activeTxtColor = "#444";
    inactiveTxtColor = "#8D8D8D";
    if(qp.value=="" || qp.value=="Type your skills, Designation.") {
        qp.value="Type your skills, Designation.";
        qp.style.color=inactiveTxtColor; 
    } 
    else {
        qp.style.color=activeTxtColor;
    }

    if(ql.value=="" || ql.value=="Type city name") {
        ql.value="Type city name";
        ql.style.color=inactiveTxtColor;
    } 
    else {
        ql.style.color=activeTxtColor;
    }

    if(qe.value=="Exp.") { 
        qe.value="Exp.";
        qe.style.color=inactiveTxtColor;
    }
    else {
        qe.style.color=activeTxtColor;
    }

    if(qf.value=="Select") {
        qf.value="Select";
        qf.style.color=inactiveTxtColor;
    }
    else {
        qf.style.color=activeTxtColor;
    }
}

function keyblank_ar() {
    var qp=gbi("qp");
    qp.value = qp.value.replace(/^\s+/,'');
    qp.value = qp.value.replace(/\s+$/,'');

    var ql=document.getElementById("ql");
    ql.value = ql.value.replace(/^\s+/,'');
    ql.value = ql.value.replace(/\s+$/,'');

    var qe=document.getElementById("qe");
    qe.value = qe.value.replace(/^\s+/,'');
    qe.value = qe.value.replace(/\s+$/,'');

    var qf=document.getElementById("qf");
    qf.value = qf.value.replace(/^\s+/,'');
    qf.value = qf.value.replace(/\s+$/,'');

    activeTxtColor = "#444";
    inactiveTxtColor = "#8D8D8D";
    if(qp.value=="" || qp.value=="Type your skills, Designation."||qp.value=="اكتب مهاراتك، المسمى الوظيفي" ) {
        qp.value="اكتب مهاراتك، المسمى الوظيفي";

        qp.style.color=inactiveTxtColor; 
    } 
    else {
        qp.style.color=activeTxtColor;
    }

    if(ql.value=="" || ql.value=="Type city name" ||ql.value=="اكتب اسم المدينة") {
        ql.value="اكتب اسم المدينة";    
         //   ql.value="hello";*/
        ql.style.color=inactiveTxtColor;
    } 
    else {
        ql.style.color=activeTxtColor;
    }

    if(qe.value=="الخبرة"||qe.value=="Exp.") { 
            qe.value="الخبرة";
        qe.style.color=inactiveTxtColor;
    }
    else {
        //qe.value="ﺎﻠﺨﺑﺭﺓ";
        qe.style.color=activeTxtColor;
    }

    if(qf.value=="Select"||qf.value=="اختر المجال الوظيفي") {
        qf.value="اختر المجال الوظيفي";
        qf.style.color=inactiveTxtColor;
    }
    else {
        qf.style.color=activeTxtColor;
    }
}



function validate(defaultErrorMsg) {
    try {
        if(typeof(validation_arr) !== 'undefined') {
            var errorCount = 0;
            var length = 0;
            for (field in validation_arr) {
                length++;
                if(!eval(validation_arr[field]["function"] + "('"+field+"','"+validation_arr[field]["default"]+"')")) {
                    errorCount++;
                }
            }

            if(length == errorCount && errorCount > 0) {
                errorShowHide('all', 'show', defaultErrorMsg);
                return false;
            }
            setFieldsBlank('search'); // Set fields with default values blank
        }
        errorShowHide('all', 'hide');
        return true;
    }
    catch(e) {return true;}
}

function setFieldsBlank(frm) {
    if(frm == "search") {
        if(typeof(validation_arr) !== 'undefined') {
            for(field in validation_arr) {
                if(gbi(field).value == validation_arr[field]["default"]) {
                    gbi(field).value = "";
                }
            }
        }
    }
    else if(frm == "login") {
        if(typeof(login_arr) !== 'undefined') {
            for(field in login_arr) {
                if(gbi(field).value == login_arr[field]["default"]) {
                    gbi(field).value = "";
                }
            }
        }
    }
}

function validateKeyword(eleId, defaultText) {
    content = trim(gbi(eleId).value);
    if(content == defaultText || content == '') {
        return false;
    }
    return true;
}

function validateFarea(eleId, defaultText) {
    if(gbi(eleId).selectedIndex == -1 || gbi(eleId).selectedIndex == 0) {
        return false;
    }
    return true;
}

function validateLocation(eleId, defaultText) {
    content = trim(gbi(eleId).value);
    if(content == defaultText || content == '') {
        return false;
    }
    return true;
}

function errorShowHide(field, type, message) {
    if(type == "show") {
        gbi("errortxt").style.display = "block";
        gbi("errortxt").innerHTML = message;
    }
    else {
        gbi("errortxt").style.display = "none";
        gbi("errortxt").innerHTML = "";
    }

    switch(field) {
        case 'qp':break;
        case 'qf[]':break;
        case 'ql':break;
        default:
                  for (field in validation_arr) {
                      if(field.substring((field.length-2),field.length) == "SL") { // Select Box
                          field = field.substring(0,(field.length-2));
                      }
                      if(type=="show") {
                          leftClass = gbi(field+"left").className;
                          rightClass = gbi(field+"right").className;
                          if(leftClass.substring((leftClass.length-2),leftClass.length) != "er") {
                              gbi(field+"left").className += "er"; 
                          }
                          if(rightClass.substring((rightClass.length-2),rightClass.length) != "er") {
                              gbi(field+"right").className += "er"; 
                          }
                      } 
                      else if(type=="hide") {
                          leftClass = gbi(field+"left").className;
                          rightClass = gbi(field+"right").className;
                          if(leftClass.substring((leftClass.length-2),leftClass.length) == "er") {
                              gbi(field+"left").className = leftClass.substring(0, (leftClass.length-2)); 
                          }
                          if(rightClass.substring((rightClass.length-2),rightClass.length) == "er") {
                              gbi(field+"right").className = rightClass.substring(0, (rightClass.length-2)); 
                          }
                      }
                  }
    }
}

function display_featuredemployers(arrLinks) {
    try {
        cntr=0;
        var lnkImg="";
        var slot=1;
        var slot1=slot2=slot3="";
        links = new Array();
        for(key in arrLinks) {
            var objDiv = document.createElement('div');
            objDiv.innerHTML = arrLinks[key];
            arrObjLinks = objDiv.getElementsByTagName("a");
            arrObjImages = objDiv.getElementsByTagName("img");

            for(var key2=0; key2 < arrObjLinks.length; key2++) {
                var lnkLabel = arrObjLinks[key2].innerHTML;
                var lnkLocation = arrObjLinks[key2].href;
                links[cntr] = {"lnkLabel":lnkLabel, "lnkLocation":lnkLocation};
                cntr++;
            }

            for(var key3=0; key3 < arrObjImages.length; key3++) {
                lnkImg += "<img src='"+arrObjImages[key3].src+"' height=0 width=0/>";
            }
        }

        links.sort(sortLinks);
        for(var i=0; i < links.length; i++) {
            if(slot==1) {
                slot1 +="<tr><td class='dot'><a href='"+links[i].lnkLocation+"' target='_blank' class='txtlink'>"+links[i].lnkLabel+"</a></td></tr>";
            }
            else if(slot==2) {
                slot=0;
                slot2 +="<tr><td heigclass='dot'><a href='"+links[i].lnkLocation+"' target='_blank' class='txtlink'>"+links[i].lnkLabel+"</a></td></tr>";
            }
            slot++;
        }
        lnkHTML = "<div class='brwjob'><table border=0 cellpadding=2 cellspacing=2>"+slot1+"</table></div><div class='brwjob'><table border=0 cellpadding=2 cellspacing=2>"+slot2+"</table></div>";
        document.write(lnkHTML+lnkImg);
    } catch(e){}
}

function linkUpd(lnkObj,trackId, log) {
    if(track != "off") {
        if(trackId != "") {
            if (typeof log == 'undefined') {
                //lnkObj.href = "http://www.naukri.com/tieups/tieups.php?othersrcp="+trackId;
                lnkObj.href = Domain_Path+"track-"+trackId;
            }
            else {
                if(document.images) {
                    (new Image()).src="http://www.naukri.com/tieups/tieups.php?othersrcp="+trackId;
                }
            }
        }
    }
}

function getFrame(frameName, getDoc) {
  getDoc = getDoc ? true : false;
  var iframes = document.getElementsByTagName('iframe'), iframe;
  for (i=0; i<iframes.length; ++i) {
    if (iframes[i].name == frameName)
      iframe = iframes[i];
  }
  if (! getDoc)
    return iframe;
  if (iframe.contentDocument != undefined) // FF, Opera
    idoc = iframe.contentDocument;
  else if (iframe.document != undefined) // IE
    idoc = iframe.contentWindow.document;
  else
    idoc = null;
  return idoc;
}

function resizeIframe(iframe) {
    iFrame = getFrame(iframe.name, true);
    iframe.width = 0;
    iframe.width = iFrame.body.scrollWidth + 4 + "px";
    iframe.style.width = iFrame.body.scrollWidth + 4 + "px";
    iframe.height = iFrame.body.scrollHeight;
    if(document.getElementById('id_wrapper_'+iframe.name) && iframe.height <= 20) {
      document.getElementById('id_wrapper_'+iframe.name).style.display = "none";
    }
}

function toggle(id, obj) {
    if(gbi(id)) {
      if(gbi(id).style.display=="none") {
        gbi(id).style.display="block";
        //obj.className = obj.className.replace("more","less");
        obj.innerHTML = obj.innerHTML.replace("More","Less");
        obj.innerHTML = obj.innerHTML.replace("أخرى","أقل");
      }
      else if(gbi(id).style.display=="block") {
        gbi(id).style.display="none";
        //obj.className = obj.className.replace("less","more");
        obj.innerHTML = obj.innerHTML.replace("Less","More");
        obj.innerHTML = obj.innerHTML.replace("أقل","أخرى");
      }
    }
}

function sortLinks(v1, v2) {return (v1.lnkLabel.toLowerCase() < v2.lnkLabel.toLowerCase() ? -1 : ((v1.lnkLabel.toLowerCase() > v2.lnkLabel.toLowerCase()) ? 1 : 0));}
function gbi(eleId) {return document.getElementById(eleId);}
function gbt(tag) {return document.getElementsByTagName(tag);}
function getTagName(eleObj) {return eleObj.tagName;}
function trim(text) {return text.replace(/^\s+|\s+$/, '');}

