//confirm
function confirm_entry(text, link)
{
    var input_box=confirm(text);
    if (input_box == true) {            
       window.location = link;
    }
    else
    {
        //none
    }
}

//confirm
function confirm_entry_eval(text, command) {
    var input_box = confirm(text);
    if (input_box == true) {
        eval(command);
    }
    else {
        //none
    }
}

//on ajax send to friend
function onAjaxSendToFriend(e)
{
	var keyIndex = 0;
	if (navigator.appName == "Netscape")
		keyIndex = e.which;
	else
		keyIndex = window.event.keyCode;

	if (keyIndex == 13)
	{
	    openSendToFriendModalDialog('', '', '', '', 1);
	}
}

//on ajax job ad content
function onAjaxJobAdContact(e, jobadid) 
{
    var keyIndex = 0;
    if (navigator.appName == "Netscape")
        keyIndex = e.which;
    else
        keyIndex = window.event.keyCode;

    if (keyIndex == 13) 
    {
        openJobAdContactModalDialog(jobadid, '', '', '', '', '', 1);
    }
}


//change class name to over or back
function itemOver(object) 
{
    if (object.className.indexOf('over') > 0)
        object.className = object.className.replace('over', '');
    else
        object.className = object.className + 'over';

}

//show header top menu
function showHeaderMenu(display) 
{
    if (display == "block") 
        document.getElementById("moredivlinks").style.display = "block";
    if (display == "none") 
        document.getElementById("moredivlinks").style.display = "none";
}

//jobselectionleftbar
function expand(position)
{
    if (document.getElementById("sel" + position).src.indexOf("arrow_black1") > 0) {
        document.getElementById("sel" + position).src = "images/arrow_black2.gif";
        document.getElementById("sub" + position).style.display = "block";
    }
    else {
        document.getElementById("sel" + position).src = "images/arrow_black1.gif";
        document.getElementById("sub" + position).style.display = "none";
    }
}

//jobselectionleftbar
function expandMore(position) 
{
    if (document.getElementById("more" + position).style.display=="block")
    {
        document.getElementById("more" + position).style.display = "none";
        document.getElementById("spanMore" + position).style.display = "block";
        document.getElementById("spanClose" + position).style.display = "none";
    }
    else 
    {
        document.getElementById("more" + position).style.display = "block";
        document.getElementById("spanClose" + position).style.display = "block";
        document.getElementById("spanMore" + position).style.display = "none";
    }
}

//firstpage navigation
function setNewJobAdsPage(page) 
{
    sendAjaxRequest("ajaxfirstpagenewjobads.aspx?page=" + page, "newjobadsajaxdiv", "");
}

//businessserviceinfo show document
function openDocument(docid, rooturl, blue) 
{
    sendAjaxRequest(rooturl + "ajaxbusinessserviceinfo.aspx?docid=" + docid + "&blue=" + blue, "contentdiv", "");
}

      
//close window
function KillMe(StayAlive)
{
    //close window
    setTimeout("self.close()",StayAlive * 1);
}

//get enddate -> startdate + days
function getEndDate(startday, startmonth, startyear, days, returntype)
{
    //get enddate
    var myDate=new Date(startyear,startmonth-1,startday); 
    myDate.setDate(myDate.getDate() + parseInt(days) - 1);

    //return
    if (returntype == 'day') return myDate.getDate();
    if (returntype == 'month') return myDate.getMonth()+1;
    if (returntype == 'year') return myDate.getFullYear();
}

//key: only numeric 
function keyOnlyNumeric(e)
{
    //validate input
    if (navigator.appName == "Netscape") 
        var keyIndex = e.which; //for netscape
    else 
        var keyIndex = window.event.keyCode; //other

    // only allow numbers and backspace
    if((keyIndex>47 && keyIndex<58) || keyIndex==0 || keyIndex==8 || keyIndex==46 || keyIndex==44)
        return true;
    else
        return false;
}

//key: only numeric Int32
function keyOnlyNumericInt32(e, name)
{
    //init variables
    var nvalue=name.value;     
    
    //validate input
    if (navigator.appName == "Netscape") 
        var keyIndex = e.which; //for netscape
    else 
        var keyIndex = window.event.keyCode; //other

    // only allow numbers and backspace
    if((keyIndex>47 && keyIndex<58) || keyIndex==0 || keyIndex==8 || keyIndex==46 || keyIndex==44)
    {        
        var ntmpvalue = parseInt(nvalue.toString() + String.fromCharCode(keyIndex));        
        if (ntmpvalue <= 2147483647)    
            return true;        
        else                  
            return false;  
    }
    else
        return false;
}

//key: only numeric 
function keyOnlyNumericWEnter(e)
{
    //validate input
    if (navigator.appName == "Netscape") 
        var keyIndex = e.which; //for netscape
    else 
        var keyIndex = window.event.keyCode; //other

    // only allow numbers and backspace
    if((keyIndex>47 && keyIndex<58) || keyIndex==0 || keyIndex==8 || keyIndex==46 || keyIndex==44 || keyIndex==13)
        return true;
    else
        return false;
}

//show / hide divs
function showDiv(index)
{
    //loop divs
    for (i=1;i<6;i++)
    {
        //show selected div
        if(i==index)
        {
            //set class and show div
            document.getElementById("panel" + i).className = "jobadpanneltabselected";
            document.getElementById("div"+i).style.display="block";
        }
        else
        {
            //set class and hide div
            document.getElementById("panel" + i).className = "jobadpanneltab";
            document.getElementById("div" + i).style.display = "none";
        }
    }
}

//-----------------------

//jobseekermyaccountcv auxiliary
function addAuxiliaryWorkExperience(jobseekercvauxiliaryid, jobseekercvworkexperienceauxiliaryid) 
{
    if (jobseekercvworkexperienceauxiliaryid > 0)
        $("workexperiencevalidate").value = "0";    
    
    if ($("jobseekercvworkexperienceauxiliaryid").value > 0) {
        sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=1&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&workexperienceperiod=" + escape(document.getElementById("workexperienceperiod").value) + "&workexperiencetitle=" + escape(document.getElementById("workexperiencetitle").value) + "&workexperiencedescription=" + escape($("workexperiencedescriptiontextarea").value).replace(/%0D%0A/g, "###newline###").replace(/%0A/g, "###newline###") + "&jobseekercvworkexperienceauxiliaryid=" + $("jobseekercvworkexperienceauxiliaryid").value + "&validate=" + $("workexperiencevalidate").value, "ajaxworkexperiencecvauxiliarydiv", "");
    }
    else
        sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=1&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&workexperienceperiod=" + escape(document.getElementById("workexperienceperiod").value) + "&workexperiencetitle=" + escape(document.getElementById("workexperiencetitle").value) + "&workexperiencedescription=" + escape($("workexperiencedescriptiontextarea").value).replace(/%0D%0A/g, "###newline###").replace(/%0A/g, "###newline###") + "&jobseekercvworkexperienceauxiliaryid=" + jobseekercvworkexperienceauxiliaryid + "&validate=" + $("workexperiencevalidate").value, "ajaxworkexperiencecvauxiliarydiv", "");

    if (document.getElementById("workexperiencetitle").value != "" && document.getElementById("workexperiencetitle").className == "inputlarge" && document.getElementById("workexperiencedescriptiontextarea").value.length > 0 && document.getElementById("workexperiencedescriptiontextarea").className == "" && document.getElementById("workexperiencedescriptiontextarea").value.length <= 1024 && document.getElementById("workexperienceperiod").value != "" && document.getElementById("workexperienceperiod").className == "inputsmall") {
        $("workexperiencevalidate").value = "1";
        $("jobseekercvworkexperienceauxiliaryid").value = "";
        document.getElementById("workexperiencetitle").value = "";
        document.getElementById("workexperienceperiod").value = "";
        document.getElementById("workexperiencedescriptiontextarea").value = "";
        $("workexperiencevalidateimage").src = rooturl + "images/sl-SI/buttons/addadditionalcv.png";
    }
}

//edit jobseekermyaccountcv auxiliary
function editAuxiliaryWorkExperience(jobseekercvauxiliaryid, jobseekercvworkexperienceauxiliaryid, validate) {
    sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=1&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&jobseekercvworkexperienceauxiliaryid=" + jobseekercvworkexperienceauxiliaryid + "&validate=" + validate, "", "handleAuxiliaryWorkExperience");

    $("workexperiencevalidateimage").src = rooturl + "images/sl-SI/buttons/save_change.png";
}

//handle work experience
function handleAuxiliaryWorkExperience(responseText) {
    $("workexperiencetitle").value = responseText.split('###')[1];
    $("workexperiencetitle").className = "inputlarge";
    
    $("workexperienceperiod").value = responseText.split('###')[0];
    $("workexperienceperiod").className = "inputsmall";
    
    $("workexperiencedescriptiontextarea").value = responseText.split('###')[2];
    $("workexperiencedescriptiontextarea").className = "";

    $("workexperiencevalidate").value = "2";
    $("jobseekercvworkexperienceauxiliaryid").value = responseText.split('###')[3];
}

//--------------------------------

//jobseekermyaccountcv auxiliary
var jobauxiliaryeducationcount = 0;
function addAuxiliaryEducation(jobseekercvauxiliaryid, count, jobseekercveducationauxiliaryid) 
{
    var jobadeducationselected = 0;
    jobauxiliaryeducationcount = document.jobseekercvform.jobadeducation.length;
    count = jobauxiliaryeducationcount;
    var selectedvalue = 0;

    for (var i = 0; i < jobauxiliaryeducationcount; i++) {
        if (document.jobseekercvform.jobadeducation[i].checked == true) {
            jobadeducationselected = i + 1;
            selectedvalue = document.jobseekercvform.jobadeducation[i].value;
        }
    }

    if (jobseekercveducationauxiliaryid > 0) {
        $("educationvalidate").value = "0";
    }


    //if edit / remove
    if ($("jobseekercveducationauxiliaryid").value > 0) {
        sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=2&educationtitle=" + escape($("educationtitle").value) + "&jobeducationid=" + selectedvalue + "&yearofcompletion=" + escape(document.getElementById("yearofcompletion").value) + "&educationalinstitution=" + escape($("educationalinstitution").value) + "&jobseekercveducationauxiliaryid=" + $("jobseekercveducationauxiliaryid").value + "&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&validate=" + $("educationvalidate").value, "ajaxeducationauxiliary", "");
    }
    else {
        sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=2&educationtitle=" + escape($("educationtitle").value) + "&jobeducationid=" + selectedvalue + "&yearofcompletion=" + escape(document.getElementById("yearofcompletion").value) + "&educationalinstitution=" + escape($("educationalinstitution").value) + "&jobseekercveducationauxiliaryid=" + jobseekercveducationauxiliaryid + "&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&validate=" + $("educationvalidate").value, "ajaxeducationauxiliary", "");
    }


    if ($("educationtitle").value != "" && $("yearofcompletion").value != '' && $("educationalinstitution").value!='' && jobadeducationselected > 0) {
        $("educationtitle").value = "";
        $("yearofcompletion").value = "";
        $("educationalinstitution").value = "";
        $("jobseekercveducationauxiliaryid").value = "";
        $("educationvalidate").value = "1";
        $("educationimage").src = rooturl + "images/sl-SI/buttons/addadditionalcv.png";

        for (var i = 0; i < jobauxiliaryeducationcount; i++) {
            document.jobseekercvform.jobadeducation[i].checked = false;
        }
    }
}

//edit jobseekermyaccountcv auxiliary
function editAuxiliaryEducation(jobseekercvauxiliaryid, jobseekercveducationauxiliaryid, validate) {
    sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=2&jobseekercveducationauxiliaryid=" + jobseekercveducationauxiliaryid + "&validate=" + validate, "", "handleAuxiliaryEducation");

    $("educationimage").src = rooturl + "images/sl-SI/buttons/save_change.png";
}

//handle education
function handleAuxiliaryEducation(responseText) {
    $("educationtitle").value = responseText.split('###')[0];
    $("educationtitle").className = "inputsmall";

    for (var i = 0; i < jobauxiliaryeducationcount; i++) {
        if (document.jobseekercvform.jobadeducation[i].value == responseText.split('###')[1])
            document.jobseekercvform.jobadeducation[i].checked = "true";
    }

    $("yearofcompletion").value = responseText.split('###')[2];
    $("yearofcompletion").className = "inputlittle";
    
    $("educationalinstitution").value = responseText.split('###')[3];
    $("educationalinstitution").className = "inputlarge";

    $("educationvalidate").value = "2";
    $("jobseekercveducationauxiliaryid").value = responseText.split('###')[4];
}

//jobseekermyaccountcv auxiliary
function getCheckboxValue(id)
{
    var returnValue=0;
    if(document.getElementById(id).checked==true)
        returnValue = 1;

    return returnValue;
}

//-------------------------------------------------

//jobseekermyaccountcv auxiliary
function addAuxiliaryLanguage(jobseekercvauxiliaryid, jobseekercvlanguageauxiliaryid) {

    if (jobseekercvlanguageauxiliaryid == 0 && getCheckboxValue("languageleveltalk") == 0 && getCheckboxValue("languagelevelread") == 0 && getCheckboxValue("languagelevelwrite") == 0 && getCheckboxValue("languagelevelunderstand") == 0)
        $("educationlevelerrordiv").style.display = 'block';
    else
        $("educationlevelerrordiv").style.display = 'none';

    if (jobseekercvlanguageauxiliaryid > 0 && $("languagevalidate").value == "2") {
        $("languagevalidate").value = "0";
    }

    if ($("auxiliarylanguageids") && $("jobseekercvlanguageauxiliaryid").value=="0") {
        if ($("auxiliarylanguageids").value.indexOf(',' + $("valuejoblanguage").value + ',') > -1 && jobseekercvlanguageauxiliaryid<1) {
            document.getElementById("educationexistserrordiv").style.display = 'block';
        }
        else {
            document.getElementById("educationexistserrordiv").style.display = 'none';
            sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=3&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&joblanguageid=" + document.getElementById("valuejoblanguage").value + "&levelspeak=" + getCheckboxValue("languageleveltalk") + "&levelread=" + getCheckboxValue("languagelevelread") + "&levelwrite=" + getCheckboxValue("languagelevelwrite") + "&levelunderstand=" + getCheckboxValue("languagelevelunderstand") + "&jobseekercvlanguageauxiliaryid=" + jobseekercvlanguageauxiliaryid + "&validate=" + $("languagevalidate").value, "ajaxlanguageauxiliarydiv", "");

            //reset
            $("languageleveltalk").checked = false;
            $("languagelevelread").checked = false;
            $("languagelevelwrite").checked = false;
            $("languagelevelunderstand").checked = false;
            $("jobseekercvlanguageauxiliaryid").value = "0";
            $("languagevalidate").value = "0";
            $("languageimage").src = rooturl + "images/sl-SI/buttons/addadditionalcv.png";
        }
    }
    else {
        if ($("jobseekercvlanguageauxiliaryid").value > 0) {
            sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=3&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&joblanguageid=" + document.getElementById("valuejoblanguage").value + "&levelspeak=" + getCheckboxValue("languageleveltalk") + "&levelread=" + getCheckboxValue("languagelevelread") + "&levelwrite=" + getCheckboxValue("languagelevelwrite") + "&levelunderstand=" + getCheckboxValue("languagelevelunderstand") + "&jobseekercvlanguageauxiliaryid=" + $("jobseekercvlanguageauxiliaryid").value + "&validate=" + $("languagevalidate").value, "ajaxlanguageauxiliarydiv", "");
            
            //reset
            $("languageleveltalk").checked = false;
            $("languagelevelread").checked = false;
            $("languagelevelwrite").checked = false;
            $("languagelevelunderstand").checked = false;
            $("jobseekercvlanguageauxiliaryid").value = "0";
            $("languagevalidate").value = "0";
            $("languageimage").src = rooturl + "images/sl-SI/buttons/addadditionalcv.png";
        }
        else
            sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=3&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&joblanguageid=" + document.getElementById("valuejoblanguage").value + "&levelspeak=" + getCheckboxValue("languageleveltalk") + "&levelread=" + getCheckboxValue("languagelevelread") + "&levelwrite=" + getCheckboxValue("languagelevelwrite") + "&levelunderstand=" + getCheckboxValue("languagelevelunderstand") + "&jobseekercvlanguageauxiliaryid=" + jobseekercvlanguageauxiliaryid + "&validate=" + $("languagevalidate").value, "ajaxlanguageauxiliarydiv", "");
    }
}

//edit jobseekermyaccountcv auxiliary
function editAuxiliaryLanguage(jobseekercvauxiliaryid, jobseekercvlanguageauxiliaryid, validate) {
    sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=3&jobseekercvlanguageauxiliaryid=" + jobseekercvlanguageauxiliaryid + "&validate=" + validate, "", "handleAuxiliaryLanguage");

    $("languageimage").src = rooturl + "images/sl-SI/buttons/save_change.png";
}

//handle education
function handleAuxiliaryLanguage(responseText) {

    selectChoice(document.getElementById("nodeidjoblanguage" + responseText.split('###')[0]), "joblanguage", responseText.split('###')[0], "", "false");

    //languageleveltalk
    if (responseText.split('###')[1] == "1")
        $("languageleveltalk").checked = true;
    else
        $("languageleveltalk").checked = false;

    //languagelevelread
    if (responseText.split('###')[2] == "1")
        $("languagelevelread").checked = true;
    else
        $("languagelevelread").checked = false;

    //languagelevelwrite
    if (responseText.split('###')[3] == "1")
        $("languagelevelwrite").checked = true;
    else
        $("languagelevelwrite").checked = false;

    //languagelevelunderstand
    if (responseText.split('###')[4] == "1")
        $("languagelevelunderstand").checked = true;
    else
        $("languagelevelunderstand").checked = false;

    $("languagevalidate").value = "2";
    $("jobseekercvlanguageauxiliaryid").value = responseText.split('###')[5];
}


//------------------------------------------

//jobseekermyaccountcv auxiliary
function addAdditionalEducation(jobseekercvauxiliaryid, jobseekercvadditionaleducationauxiliaryid) 
{
    if (jobseekercvadditionaleducationauxiliaryid > 0)
        $("additionaleducationvalidate").value = "0";

    if ($("jobseekercvadditionaleducationauxiliaryid").value > 0)
        sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=4&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&additionaleducationtitle=" + escape($("additionaleducationtitle").value) + "&jobseekercvadditionaleducationauxiliaryid=" + $("jobseekercvadditionaleducationauxiliaryid").value + "&validate=" + $("additionaleducationvalidate").value, "ajaxadditionaleducationauxiliarydiv", "");
    else
        sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=4&jobseekercvauxiliaryid=" + jobseekercvauxiliaryid + "&additionaleducationtitle=" + escape($("additionaleducationtitle").value) + "&jobseekercvadditionaleducationauxiliaryid=" + jobseekercvadditionaleducationauxiliaryid + "&validate=" + $("additionaleducationvalidate").value, "ajaxadditionaleducationauxiliarydiv", "");

    if ($("additionaleducationtitle").value != "" && $("additionaleducationtitle").className == "inputlarge") {
        $("additionaleducationtitle").value = "";
        $("additionaleducationvalidate").value = "1";
        $("jobseekercvadditionaleducationauxiliaryid").value = "";
        $("additionaleducationimage").src = rooturl + "images/sl-SI/buttons/addadditionalcv.png";
    }
}

//edit jobseekermyaccountcv auxiliary
function editAdditionalEducation(jobseekercvauxiliaryid, jobseekercvadditionaleducationauxiliaryid, validate) {
    sendAjaxRequest(rooturl + "ajaxjobseekercvauxiliary.aspx?type=4&jobseekercvadditionaleducationauxiliaryid=" + jobseekercvadditionaleducationauxiliaryid + "&validate=" + validate, "", "handleAdditionalEducation");

    $("additionaleducationimage").src = rooturl + "images/sl-SI/buttons/save_change.png";
}

//handle additional education
function handleAdditionalEducation(responseText) {
    $("additionaleducationtitle").value = responseText.split('###')[0];
    $("additionaleducationtitle").className = "inputlarge";
    
    $("additionaleducationvalidate").value = "2";
    $("jobseekercvadditionaleducationauxiliaryid").value = responseText.split('###')[1];
}



//------------------------------------------

 //check number on input and submit
function check_number_and_submit(e,form)
{
    //netscape
    var ns = (navigator.appName == "Netscape");

    //get key code
    if(ns) var key_index = e.which;
    else var key_index = window.event.keyCode;
    
    //check number on input
    if((key_index>47 && key_index<58)|| key_index==0 || key_index==8)
    {
        return true;
    }
    else if(key_index==13) //enter key
    {
        //submit form
        form.submit();
    }
    else
        return false;
}	
      
//currency format 
function formatCurrency(name,dec)   
{
    //init variables
    inp=name.value;
    comma=0; 
    sign = ""

    //get sign
    if (inp.substring(0,1) == '-') 
    {
        sign = "-";
        inp = inp.substring(1, inp.length);
    };

    //validate input value
    if (inp=="") 
        return;
    outt="";
    
    //loop characters
    for (var i=0; i<inp.length; i++) 
    {
        //get character
        sChar=inp.charAt(i);
        if (sChar==".") 
            continue;
        else if (sChar==",") 
        {      
            if (dec==0) 
                break;
            if (comma>0) 
                break;
            comma=1;
            outt=outt+sChar;
        }
        else if (sChar<"0" || sChar>"9") 
            break;
        else 
        outt=outt+sChar;    
    }
    
    //get value with zeros
    out="";
    if (dec) 
    {
        zeros="000000000"; 
        out=",";
        pos1=outt.indexOf(",");
        if (pos1!=-1) 
        {
            pos2=outt.length;
            if (pos2-pos1-1>dec) 
                pos2=pos1+dec+1;
            out=out+outt.substring(pos1+1,pos2);
            outt=outt.substring(0,pos1);
        }  
        out=out+zeros.substring(0,3-out.length); 
    }
    //format value with separators
    for (i=outt.length; i>3; i-=3) 
        out="." + outt.substring(i-3,i) + out;
        
    //return formated value
    out=outt.substring(0,i)+out;
    name.value=sign+out;
}

//iframeinput: start ...

//on load iframe
function onloadIframe(frameid, contentlength) 
{
    //set design mode on
    document.getElementById(frameid).contentWindow.document.designMode = 'on';
	
	//attach key event handler and set content length
    if (contentlength > 0) {

        //set interval for content size
        setInterval(function() { contentSize(frameid, contentlength); }, 1000); 

	    //attach key events
	    attachKeyEventHandler(frameid, contentlength);
	    
	    //when content window document available
	    if (document.getElementById(frameid).contentWindow.document.body != null) contentSize(frameid, contentlength);
	}
}

//execute command on frame
function executeCommand(command, frameid)
{
	document.getElementById(frameid).contentWindow.document.execCommand(command, false, null);
}

//clear frame
function clearIframe(frameid, contentlength)
{
    //clear content
    document.getElementById(frameid).contentWindow.document.body.innerHTML  = "";
    
    //refresh: content size
    if (contentlength > 0) contentSize(frameid, contentlength);
}

//attach key event handler
function attachKeyEventHandler(frameid, contentlength)
{
    //get element by frameid
    var element = document.getElementById(frameid).contentWindow.document;
    
    //attach key event handler
    if (element.addEventListener) 
    {
        element.addEventListener ("keyup", function() {contentSize(frameid, contentlength)}, false);
        element.addEventListener ("keydown", function() {contentSize(frameid, contentlength)}, false);
    } 
    else if (element.attachEvent) 
    {
            element.attachEvent ("onkeyup", function() {contentSize(frameid, contentlength);});
            element.attachEvent ("onkeydown", function() {contentSize(frameid, contentlength);});
    }
    else 
    {
        element.onkeyup = function() {contentSize(frameid, allowedsize)};
        element.onkeydown = function() {contentSize(frameid, allowedsize)};
    }
}

//remove html comments
function removeHTMLComments(html) {
    return html.replace(/<!(?:--[\s\S]*?--\s*)?>\s*/g, '').replace(/[\r\n]/g, '').replace(/[\r]/g, '').replace(/[\n]/g, '').replace(/^\s+|\s+$/g, '');
}

//content size
function contentSize(frameid, contentlength)
{
    //calculate current size
    var currentSize = contentlength

    if (document.getElementById(frameid).contentWindow.document.body.innerText != null) currentSize -= document.getElementById(frameid).contentWindow.document.body.innerText.length; //ie
    if (document.getElementById(frameid).contentWindow.document.body.textContent != null) currentSize -= removeHTMLComments(document.getElementById(frameid).contentWindow.document.body.textContent).length //firefox
    
    if (currentSize < 0) 
    {
        //set calculated current size + over chars
        document.getElementById(frameid + 'csover').style.display = 'none';
        document.getElementById(frameid + 'csunder').style.display = 'block';
        document.getElementById(frameid + 'csalert').innerHTML = currentSize*-1;
        
        //return false
        return false;
    }
    else
    {
        //set calculated current size
        document.getElementById(frameid + 'csover').style.display = 'block';
        document.getElementById(frameid + 'csunder').style.display = 'none';
        document.getElementById(frameid + 'cs').innerHTML = currentSize;
        
        //return
        return true;
    }   
}

//iframeinput: end ...




//jobseekercv activate
function jobseekerCVActivate(jobseekercvid, count) {

    var months = -1;
    for (var i = 0; i < count; i++) {
        if (document.jobseekercvmonthsselect.jobseekercvmonths[i].checked == true)
            months = i;
    }

    //save and activate jobseekercv
    if ($('datevalidinmonths')) {
        $('datevalidinmonths').value = document.jobseekercvmonthsselect.jobseekercvmonths[months].value;
        submitJobseekerCVForm(3);
    }
    else {
        if (months == -1)
            window.location = rooturl + "xt_jobseekercv.aspx?jobseekercvid=" + jobseekercvid + "&jobseekercvactivate=true";
        else
            window.location = rooturl + "xt_jobseekercv.aspx?jobseekercvid=" + jobseekercvid + "&jobseekercvactivate=true&activateinmonths=" + document.jobseekercvmonthsselect.jobseekercvmonths[months].value;
    }
}

//check all checkboxes in an id
function checkAllInId(id) {
    var inputs = $(id).getElementsByTagName('input');
    for (var i = 0; inputs.length > i; i++) {
        if (inputs[i].type == 'checkbox') {
            inputs[i].checked = true;
        }
    }
}

//uncheck all checkboxes in an id
function uncheckAllInId(id) {
    var inputs = $(id).getElementsByTagName("input");
    for (var i = 0; inputs.length > i; i++) {
        if (inputs[i].type == 'checkbox') {
            inputs[i].checked = false;
        }
    }
}

//get service type
function getServiceType(articleid, servicetypeid, quantity, remove, zindex) {
    sendAjaxRequest(rooturl + "ajaxbusinessmyaccountorder.aspx?articleid=" + articleid + "&servicetypeid=" + servicetypeid + "&quantity=" + quantity + "&remove=" + remove + "&zindex=" + zindex, "", "handleServiceType");
}

//get job contact notification files
function ajaxJobContactNotificationFiles(jobadid) {
    sendAjaxRequest(rooturl + "ajaxjobadnotificationfile.aspx?jobadid=" + jobadid, "ajaxjobadcontactnotificationfiles", "handlerJobContactNotificationFileCountCheck");
}

//file count check
function handlerJobContactNotificationFileCountCheck(responseText) {
    if (document.getElementById('jobadcontactnotificationfilecount')) {
        //get file count
        var filecount = document.getElementById('jobadcontactnotificationfilecount').value;

        if (document.getElementById('jobadcontactnotificationframe')) {
            //if filecount is less than 5 show upload button
            if (filecount < 5) {
                document.getElementById('jobadcontactnotificationframe').style.display = 'block';
                document.getElementById('jobadcontactnotificationframeinfo').style.display = 'none';
            } else {
                document.getElementById('jobadcontactnotificationframe').style.display = 'none';
                document.getElementById('jobadcontactnotificationframeinfo').style.display = 'block';
            }
        }
    }
}

//remove file from job contact notification
function ajaxJobContactNotificationFileRemove(jobadid, fileid) {
    sendAjaxRequest(rooturl + "ajaxjobadnotificationfile.aspx?jobadid=" + jobadid + "&fileid=" + fileid, "", "handlerJobContactNotificationFiles");
}

//handler function after file removal
function handlerJobContactNotificationFiles(responseText) {
    if (responseText != '') {
        //refresh file list
        ajaxJobContactNotificationFiles(responseText);
    }
}