// JavaScript Document
// document.getElementById('stf_mail').value, document.getElementById('stf_name').value, document.getElementById('stf_sender_mail').value,
function stf_send(aUrl, aJoid) {
    //var Email = 
    //alert($('stf_name').value+"/"+$('stf_mail').value+"/"+$('stf_sender_mail').value);
    if(check_form_stf($('stf_mail').value, $('stf_name').value, $('stf_sender_mail').value)){
        var a = new Ajax.Request(aUrl+"ajax.php?action=SendToFriendJobOffer&email="+$('stf_mail').value+"&name="+$('stf_name').value+"&sender_email="+$('stf_sender_mail').value+"&joid="+aJoid,{asynchronous:false})
        var text = a.transport.responseText;
        //alert (text.search(/ok/i));
        //alert(a.transport.responseText.search(/ok/i));
        if(a.transport.responseText.search(/ok/i)==0){
            //alert('hurray');
            $('stf').style.display='none';
            $('stf_thanks').style.display='block';
            return true;
        }
        else{
            $('stf').style.display='block';
            $('stf_thanks').style.display='none';
            return false;
        }
    } 
    return false;
}

function acheck_form_stf (aUrl,aCheckEmail, form ) {

    if(check_form_register(form)){
        var a = new Ajax.Request(aUrl+"ajax.php?action=CheckEmail&email="+aCheckEmail,{asynchronous:false})
        if(a.transport.responseText=='ok'){
            return true;
        }
        else{
            $('CheckEmail').innerHTML=a.transport.responseText;
            return false;
        }
    } 
    return false;
}

function SwitchBranchStatus (aUrl, aBranch, aBranchStatus) {
    new Ajax.Request(aUrl+"index.php?module=job_offers&job_offers_action=switch_branch_status&branch_id="+aBranch+"&curr_status="+aBranchStatus,{
                         method: 'get',
                         onSuccess: function(transport) {
                             $('branch_list').update( transport.responseText );
                         }
                     }
                    );
}


function SwitchJobOfferStatus (aUrl, aJobOffer, aJobOfferStatus, aPage) {
    new Ajax.Request(aUrl+"index.php?module=job_offers&job_offers_action=switch_job_offer_status&job_offer_id="+aJobOffer+"&curr_status="+aJobOfferStatus+"&page="+aPage,
                     {method: 'get', asynchronous:false, 
                                  onLoading: function SetDefaultModelPhotoOnLoading(){
                                  $('onloading_'+aJobOffer+'').style.display='inline';
                                  },
                                  onSuccess: function(transport) {
                                   $('onloading_'+aJobOffer+'').style.display='none';
                                   $('job_offers_list').update( transport.responseText );
                                  }
                                }
                    );
}




