function doAdReport(ad_id){    
    r_reason = $("#r_reason").val();
    r_name = $("#r_name").val();
    r_email = $("#r_email").val();
    r_details = $("#r_details").val();
    
    strOutput = $.ajax({
    url: "http://www.runclassifieds.com/ajax/ajax.utils.php?action=report_ad&ad_id=" + ad_id + "&reason=" + r_reason + "&name=" + r_name + "&email=" + r_email + "&details=" + r_details  ,
    async: false
    }).responseText;    
        
    $('#report_response').html("&nbsp;The report was sent!");
    
    return true;    
}


function doAdDeleteRequest(ad_id){
    delcode = $("#delete_anunt_check").val();

    strOutput = $.ajax({
    url: "http://www.runclassifieds.com/ajax/ajax.utils.php?action=ad_delete_request&ad_id=" + ad_id + "&delcode=" + delcode,
    async: false
    }).responseText;    
        
    $('#delete_anunt_response').html(strOutput);
    
    return true;        
}



function setServerVariable(varName,varValue) {    
    strOutput = $.ajax({
    url: "http://www.runclassifieds.com/ajax/ajax.utils.php?action=set_server_variable&varName=" + varName + "&varValue=" + varValue,
    async: false
    }).responseText;    
    
    return true;
}


function doRapidFilter(){
    region_id = $("#filter_location").val();
    categ_id = $("#filter_categ").val();    
    
    strLinkRedir = $.ajax({
    type: "GET", 
    url: "/ajax/ajax.utils.php?action=get_fast_search_redir&region_id=" + region_id + "&categ_id=" + categ_id,
    async: false
    }).responseText;        
    
    window.open (strLinkRedir,'_self');
}


//LISTARE - TRIMITE UNUI PRIETEN
function showSend2Friend () {
    if (subscribe_status==1) {
        $('#subscribe').slideUp('normal', function () {
            subscribe_status = 0;
            $('#send_mail').slideDown('normal');
            send_mail_status = 1;
        });
    } else {
        $('#send_mail').slideDown('normal');
        send_mail_status = 1;
    }
    
    return false;
}

function closeSend2Friend() {
    send_mail_status = 0;    
    $('#send_mail').slideUp('normal');    
    return false;
}

function sendMail2Friend() {
    //do validare
    is_valid = true;
    $('#email_self_error').html('');
    $('#email_friend_error').html('');
    $('#name_self_error').html('');
    
    if ($('#email_self').val()=="") {
        is_valid = false;
        $('#email_self_error').html (' - required');
    } else {
        if (echeck($('#email_self').val())==false) {
            is_valid = false;
            $('#email_self_error').html (' - invalid email');
        }
    }
    
    if ($('#email_friend').val()=="") {
        is_valid = false;
        $('#email_friend_error').html (' - required');
    } else {
        if (echeck($('#email_friend').val())==false) {
            is_valid = false;
            $('#email_friend_error').html (' - invalid email');
        }
    }
    
    if ($('#name_self').val()=="") {
        is_valid = false;
        $('#name_self_error').html (' - required');
    }
    
    //do action
    if (is_valid) {
        $('#cmdSubmit').hide(function(){
            $('#email_msg_ajax_loader').show('fast', function(){
                $.post ('/ajax/ajax.utils.php', {action: 'send_email_to_friend', email_from: $('#email_self').val(), email_to: $('#email_friend').val(), 
                page_link: $('#page_link').val(), msg_email: $('#email_msg_container').val(), name_from: $('#name_self').val()}, function(data) {
                    $('#email_msg_ajax_response').html(data);
                    $('#email_msg_ajax_loader').hide();
                    self.setTimeout ("$('#cmdSubmit').show('fast'); $('#email_msg_ajax_response').html(''); closeSend2Friend()", 3000);
                    
                })
            });
        });    
        
    }
    
    return false;
}


function sendMail2FriendFromAdPage(adId, the_code) {
    //do validare
    is_valid = true;
    $('#f_email_self_error').html('');
    $('#f_email_friend_error').html('');
    $('#f_name_self_error').html('');
    
    if ($('#f_email_self').val()=="") {
        is_valid = false;
        $('#f_email_self_error').html (' - required');
    } else {
        if (echeck($('#f_email_self').val())==false) {
            is_valid = false;
            $('#f_email_self_error').html (' - invalid email');
        }
    }
    
    if ($('#f_email_friend').val()=="") {
        is_valid = false;
        $('#f_email_friend_error').html (' - required');
    } else {
        if (echeck($('#f_email_friend').val())==false) {
            is_valid = false;
            $('#f_email_friend_error').html (' - invalid email');
        }
    }
    
    if ($('#f_name_self').val()=="") {
        is_valid = false;
        $('#f_name_self_error').html (' - required');
    }
    
    //do action
    if (is_valid) {        
        $('#f_email_msg_ajax_loader').show('fast', function(){
            $.post ('/ajax/ajax.utils.php', {action: 'send_email_to_friend', email_from: $('#f_email_self').val(), email_to: $('#f_email_friend').val(), 
            page_link: $('#f_page_link').val(), msg_email: $('#f_email_msg_container').val(), name_from: $('#f_name_self').val(), code: the_code, ad_id: adId}, function(data) {
                //alert (data);
                $('#f_email_msg_ajax_response').html(data);
                $('#f_email_msg_ajax_loader').hide();                                        
                                    
            })
        });                
    }
    
    return false;
}


//LISTARE - ABONEAZA-TE
function showSubscribe () {
    if (send_mail_status==1) {
        $('#send_mail').slideUp('normal', function () {
            send_mail_status = 0;
            $('#subscribe').slideDown('normal');
            subscribe_status = 1;
        });
    } else {
        $('#subscribe').slideDown('normal');
        subscribe_status = 1;
    }
    
    return false;
}

function closeSubscribe() {
    subscribe_status = 0
    $('#subscribe').slideUp('normal');            
    return false;
}

function subscribe2Content() {
    //do validare
    is_valid = true;    
    $('#sub_name_self_error').html ('');
    $('#sub_email_self_error').html ('');
    
    if ($('#sub_name_self').val()=="") {
        is_valid = false;
        $('#sub_name_self_error').html (' - required');
    }
    
    if ($('#sub_email_self').val()=="") {
        is_valid = false;
        $('#sub_email_self_error').html (' - required');
    } else {
        if (echeck($('#sub_email_self').val())==false) {
            is_valid = false;
            $('#sub_email_self_error').html (' - invalid email');            
        }
    }
        
    
    
    //do subscribe
    if (is_valid) {
        $('#cmdSubmit2').hide(function(){
            $('#sub_ajax_loader').show('fast', function(){
                $.post ('/ajax/ajax.utils.php', {action: 'subscribe_to_content', email_self: $('#sub_email_self').val(), name_self: $('#sub_name_self').val(), 
                sub_category_id: $('#sub_category_id').val(), sub_subcategory_id: $('#sub_subcategory_id').val(), 
                sub_tara_id: $('#sub_tara_id').val(), sub_judet_id: $('#sub_judet_id').val(), freq: $('#sub_freq').val()}, function(data) {
                    $('#sub_ajax_response').html(data);
                    $('#sub_ajax_loader').hide();
                    self.setTimeout ("$('#cmdSubmit2').show('fast'); $('#sub_ajax_response').html(''); closeSubscribe()", 3000);                    
                })
            });
        });        
    }
    
    
    return false;
}


//Adaugare - box de help
function addBox_ShowHelp (showWhat, mtop) {    
    //empty_text = "";
    if (showWhat=="empty") {showWhat=empty_text;}
    $("#add_anunt_help").html (showWhat);    
    $(".formular_help").css("margin-top",mtop+"px")
}


//Adaugare - validare formular step 1
function add_ValidateForm(){
    retVal = true;
    err_string = "";
    
    //oras, email, titlu, desc
    
    if ($('#ad_city').val()=="") {
        retVal = false;
        err_string = err_string + "The field <strong>City</strong> is required <br/>"
    }
    if ($('#ad_email').val()=="") {
        retVal = false;
        err_string = err_string + "The field <strong>Email</strong> is required <br/>"
    } else {
        if (echeck($('#ad_email').val())==false) {
            retVal = false;
            err_string = err_string + "The field <strong>Email</strong> does not contain a valid email<br/>"            
        }
    }
    if ($('#ad_title').val()=="") {
        retVal = false;
        err_string = err_string + "The field <strong>Ad title</strong> is required <br/>"
    }
    if ($('#ad_description').val()=="") {
        retVal = false;
        err_string = err_string + "The field <strong>Ad Description</strong> is required <br/>"
    }    
    
    if ($('#ad_price').val()!="") {
        if (IsNumeric($('#ad_price').val())==false){
            retVal = false;
            err_string = err_string + "Price is invalid. Please change it! <br/>"            
        }
    }
        
    
    sVerif = $('#ad_verificare').val();        
    if (sVerif=="") {
        retVal = false;
        err_string = err_string + "Please input the result for the calculation 'Are you human?'. <br/>"        
    } else {
        data = $.ajax ({type: "POST", url: "/ajax/ajax.utils.php", data: "action=check_human&result="+sVerif, async: false}).responseText;         
            if (data=="no") {                
                retVal = false;
                err_string = err_string + "Wrong result for the calculation 'Are you human?'. <br/>"        
            }
    }
    
    if (err_string!="") {
        err_string = "<strong>We've found some errors, please review:</strong><br/><br/>" + err_string;
        $('#add_err_container').html (err_string);
        $('#add_err_container').slideDown ('normal');
    }
    
    /*
    if (err_string==""){
        document.forms["AddAd"][0].action = rpath;
        document.forms["AddAd"][0].submit();
    }
    */
    
    
    return retVal;
}



//AD IMAGES
function ajaxFileUpload(imgType, ad_id)
{
    $('#err_container').html("");
    $('#err_container').hide();       
    
    //starting setting some animation when the ajax starts and completes
    $("#loading")
    .ajaxStart(function(){
        $(this).show();
    })
    .ajaxComplete(function(){
        $(this).hide();
    });
   
   
   
    /*
        prepareing ajax file upload
        url: the url of script file handling the uploaded files
                    fileElementId: the file type of input element id and it will be the index of  $_FILES Array()
        dataType: it support json, xml
        secureuri:use secure protocol
        success: call back function when the ajax complete
        error: callback function when the ajax failed
       
            */
    $.ajaxFileUpload
    (
        {
            url:'/manager/ajax/ajax.global.utils.php?action=do_ad_img_upload&imgType='+imgType+'&ad_id='+ad_id,
            secureuri:false,
            fileElementId:'fileToUpload',
            dataType: 'json',
            success: function (data, status)
            {
                if(typeof(data.error) != 'undefined')
                {
                    if(data.error != '')
                    {
                        //alert("ERR1 " + data.error); //eroare
                        $('#err_container').html(data.error);
                        $('#err_container').slideDown('normal');
                    }else
                    {
                        //alert("JOB DONE " + data.msg); //job done                        
                        doImageContainerRefresh (ad_id);
                    }
                }
            },
            error: function (data, status, e)
            {
                //alert("OTHER ERROR " + e); //eroare
                $('#err_container').html('Unknown error');
                $('#err_container').slideDown('normal');
            }
        }
    )
   
    return false;

} 



function doImageContainerRefresh (ad_id){    
    
    $('#ad_image_container').fadeOut('fast',function(){
        strOutput = "";
            
        strOutput = $.ajax({
        url: "/manager/ajax/ajax.global.utils.php?action=do_ad_img_refresh_fe&ad_id=" + ad_id,
        async: false
        }).responseText;    
        
        $('#ad_image_container').html (strOutput);
        $('#ad_image_container').fadeIn('fast');
    });
    
}

function doImageDelete (ad_id, img_type, img_id) {
    strOutput = "";
        
    strOutput = $.ajax({
    url: "/manager/ajax/ajax.global.utils.php?action=do_ad_delete_img&ad_id=" + ad_id + "&img_type=" + img_type + "&img_id=" + img_id,
    async: false
    }).responseText;    
    
    doImageContainerRefresh (ad_id);    
}


function doVideoAdd (ad_id){
    $('#video_preview').html ('<img id="loading" src="/images/ajax-loader.gif">');
    
    $.post ('/ajax/ajax.utils.php', {action: 'ad_add_video', ad_id: ad_id, video_code: $('#ad_video_code').val()}, function(){        
        $('#video_preview').html ('Video-ul a fost asociat cu anuntul adaugat');
    });        
}


//Stergerea unui anunt cu confirmare de cod secret
function do_AdDeleteByCode(ad_id){
    secret_code = $('#delete_code').val();
    $("#ajax_response").html ('');                
    
    if (secret_code=="") {
        //codul nu a fost introdus
        $("#ajax_response").html ("Please input the security code!");
    } else {
        //codul a fost introdus si il trimitem prin ajax
        $("#loading_img").fadeIn ('fast', function(){
            $.post ("/ajax/ajax.utils.php", {action: "delete_ad", ad_id: ad_id, ad_delete_code: secret_code}, function (data){
                $("#loading_img").hide();
                $("#ajax_response").html (data);                
            });
        });
    }
}


//Pagina unui anunt - START

function contactAdOwner(adId, the_code) {
    err_string = "";
    
    //init err handlers
    $('#name_self_error').html ('');
    $('#email_self_error').html ('');
    $('#email_msg_container_error').html ('');
    
    //confident = $('#contact_confidentialitate').attr('checked');
    //if (confident!=true){confident=false;}
    confident = true;
    
    ad_link = $('#page_link').val();
    
    $('#contact_msg_ajax_loader').fadeIn ('fast', function() {
        //validare input        
        if ($('#name_self').val()=="") {
            err_string = err_string + "Please input your name!" + "<br/>";
            $('#name_self_error').html ('required');
        }
        if ($('#email_self').val()=="") {
            err_string = err_string + "Please input your email address!" + "<br/>";
            $('#email_self_error').html ('required');
        } else {
            if (echeck($('#email_self').val())==false) {
                err_string = err_string + "Your email address is invalid!" + "<br/>";
                $('#email_self_error').html ('invalid email');
            }
        }
        if ($('#email_msg_container').val()=="") {
            err_string = err_string + "Please write the message you want to send!" + "<br/>";
            $('#email_msg_container_error').html ('message is required');
        }  

	sVerif = $('#ad_verificare').val();
	    if (sVerif=="") {
	        retVal = false;
	        err_string = err_string + "You must input the result for the verification. <br/>";  
			$('#valid_msg_container_error').html ("You must input the result for the verification.");
	    } else {
	        data = $.ajax ({type: "POST", url: "/ajax/ajax.utils.php", data: "action=check_human&result="+sVerif, async: false}).responseText;         
	            if (data=="no") {                
	                retVal = false;
	                err_string = err_string + "Wrong verification code. <br/>";
					$('#valid_msg_container_error').html ("Wrong verification code.");					
	            }
	    }		
        
        if (err_string==""){
            //do ajax request
            strOutput = "";
            
            strOutput = $.ajax({
            type: "POST",
            url: "/ajax/ajax.utils.php",
            data: "action=send_contact_from_adpage&ad_id=" + adId + "&from_name=" + $('#name_self').val() + "&from_email=" + $('#email_self').val() 
            + "&from_phone=" + $('#phone_self').val() + "&ad_link=" + ad_link + "&confident=" + confident + "&msg=" + $('#email_msg_container').val() + "&the_code="+the_code, 
            async: false
            }).responseText; 
            
            
            $('#email_msg_ajax_response').html (strOutput);            
        }
        
    });
    
    $('#contact_msg_ajax_loader').fadeOut('fast');
    
    return false;
}

//Pagina unui anunt - END


//Adaugare si scoatere anunt in my ads - START

function addAdToMyList(ad_id, obj_container) {    
    //trimitere id catre ajax handler | returneaza numar de linkuri in my list
    
    glowItem (obj_container);
    
    $.get ("/ajax/ajax.utils.php", {ad_id: ad_id, action: "add_ad_to_mylist"}, function (data){
        //refresh link - data = numar de ad-uri in my ads
        $("#my_ads_link").text ("Favourite ads ("+data+")");
        $("#my_ads_link2").text ("Favourite ads ("+data+")");
    });        
}

function removeAdFromMyList(ar_position, ad_id) {
    //trimitere id catre ajax handler | returneaza numar de linkuri in my list
    
    $.get ("/ajax/ajax.utils.php", {ar_id: ar_position, ad_id: ad_id, action: "remove_ad_from_mylist"}, function (data){
        //refresh link - data = numar de ad-uri in my ads
        $("#my_ads_link").text ("Favourite ads ("+data+")");
        $("#my_ads_link2").text ("Favourite ads ("+data+")");
        //$("#box_anunt_"+ar_position).fadeOut('normal');
        $("."+ad_id).fadeOut('normal');
    });     
}

function glowItem(objItem){
    oldbg = $("#"+objItem).css("background-color");
    $("#"+objItem).css("background-color", "#FFF5A3");
    //alert ("$('#'"+objItem+").css('background-color', '#"+oldbg+"');");
    self.setTimeout ("$('#"+objItem+"').css('background-color', '"+oldbg+"');",300);
    self.setTimeout ("$('#"+objItem+"').css('background-color', '#FFF5A3');",600);
    self.setTimeout ("$('#"+objItem+"').css('background-color', '"+oldbg+"');",900);
    self.setTimeout ("$('#"+objItem+"').css('background-color', '#FFF5A3');",1200);
    self.setTimeout ("$('#"+objItem+"').css('background-color', '"+oldbg+"');",1500);    
}
//Adaugare si scoatere anunt in my ads - END


//Trimitere anunturile mele pe mail - START

function sendMyAdsToEmail(){
    
    if (echeck($('#myemail').val())==true) {
        //trimitere pe mail
        $.get ("/ajax/ajax.utils.php", {email: $('#myemail').val(), action: "send_my_list_to_email"}, function (data){
            $("#email_ok").slideDown("fast", function(){
                self.setTimeout ("$('#email_ok').fadeOut('fast');", 3000);
            })                    
        })
    } else {
        //email invalid
        $("#email_error").slideDown("fast", function(){
            self.setTimeout ("$('#email_error').fadeOut('fast');", 3000);
        })
    }
    
}

//Trimitere anunturile mele pe mail - END



//Pagina despre AnuntRapid.ro - START
function showDespreMenu (new_obj_id) {
    //global sel_id;
    
    if (sel_id!=new_obj_id) {
        //schimbare clasa menu vechi + menu nou
        $("#menu-item-"+sel_id).removeClass ("despre_menu_item_sel");
        $("#menu-item-"+sel_id).addClass ("despre_menu_item");
        $("#menu-item-"+new_obj_id).removeClass ("despre_menu_item");
        $("#menu-item-"+new_obj_id).addClass ("despre_menu_item_sel");
        
        //ascundere content vechi + afisare content nou
        $("#menu-"+sel_id).fadeOut ('normal', function(){
            $("#menu-"+new_obj_id).fadeIn('normal');
        });
        
        //new id becomes sel id
        sel_id = new_obj_id;
    }
}
//Pagina despre Anuntrapid.ro - END


//Pagina de contact - START
function sendContactMsg(){
    //init error handlers
    $("#contact_name_error").html('');
    $("#contact_email_error").html('');
    $("#contact_msg_error").html('');
    
    is_ok = true;
    
    //checking
    if ($("#contact_name").val()=="") {
        is_ok = false;
        $("#contact_name_error").html(" - required");
    }
    if ($("#contact_email").val()=="") {
        is_ok = false;
        $("#contact_email_error").html(" - required");
    } else {
        if (echeck($("#contact_email").val())==false) {
            is_ok = false;
            $("#contact_email_error").html(" - invalid email");            
        }
    }
    if ($("#contact_msg").val()=="") {
        is_ok = false;
        $("#contact_msg_error").html(" - required");
    }    
    
	sVerif = $('#ad_verificare').val();
	    if (sVerif=="") {
			
	        is_ok = false;
			$('#valid_msg_container_error').html ("Please input the result for the verification.");
	    } else {
	        data = $.ajax ({type: "POST", url: "/ajax/ajax.utils.php", data: "action=check_human&result="+sVerif, async: false}).responseText;         
	            if (data=="no") {                
	                is_ok = false;
					$('#valid_msg_container_error').html ("Wrong verification result.");					
	            }
	    }
	
    if (is_ok){
        $("#sendmsg").fadeOut ('fast', function(){
            $("#email_msg_ajax_loader").fadeIn('fast', function(){
                //do ajax request
                strOutput = "";
                
                strOutput = $.ajax({
                type: "POST",
                url: "/ajax/ajax.utils.php",
                data: "action=send_contact_msg&nume=" + $('#contact_name').val() + "&email=" + $('#contact_email').val() + "&msg=" + $('#contact_msg').val(), 
                async: false
                }).responseText;                             
                
                $("#email_msg_ajax_loader").fadeOut('fast');
                $('#email_msg_ajax_response').html (strOutput);                  
            })
        });
    }
    
}
//Pagina de contact - END


//Cautare globala - simpla - START

function global_doFastSearch(search_root){
    if ($('#searchbar').val()!="") {
        stext = $('#searchbar').val();
        stext = stext.replace (/[^a-zA-Z0-9]/g,"+");
        search_url = search_root + stext + "/";        
        $.ajax({
        type: "POST",
        url: "/ajax/ajax.utils.php",
        data: "action=mark_search_tag&search_tag=" + stext + "&search_root=" + search_root, 
        success: function(html){
            window.open (search_url, '_self');
        }        
        })
        
    }
    
    return false;
}

//Cautare globala - simpla - END


/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
function echeck(str) {

        var at="@"
        var dot="."
        var lat=str.indexOf(at)
        var lstr=str.length
        var ldot=str.indexOf(dot)
        if (str.indexOf(at)==-1){           
           return false
        }

        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){           
           return false
        }

        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
            return false
        }

         if (str.indexOf(at,(lat+1))!=-1){
            return false
         }

         if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
            return false
         }

         if (str.indexOf(dot,(lat+2))==-1){
            return false
         }
        
         if (str.indexOf(" ")!=-1){
            return false
         }

          return true                    
    }

/*
Checks if a text is number or not
*/
function IsNumeric(sText)

{
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

   
/*
Functii pentru zona de promotii
*/

function checkPromoCreateUser(){
    retVal = true;
    err = "";
    
    if ($('#nume').val()==""){retVal=false; err = err + "Campul 'Nume' trebuie completat" + "<br />"}
    if ($('#prenume').val()==""){retVal=false; err = err + "Campul 'Prenume' trebuie completat" + "<br />"}
    if ($('#email').val()==""){retVal=false; err = err + "Campul 'Email' trebuie completat" + "<br />"}else{
        if(echeck($('#email').val())==false){
            retVal=false; err = err + "Adresa de email introduse nu este valida" + "<br />"
        }
    }
    if ($('#username').val()==""){retVal=false; err = err + "Campul 'Utilizator' trebuie completat" + "<br />"}
    if ($('#password').val()==""){retVal=false; err = err + "Campul 'Parola' trebuie completat" + "<br />"} else {
        if ($('#password').val()!=$('#password_again').val()){
            retVal=false; err = err + "Campurile 'Parola' si 'Reintroducere parola' trebuie sa fie identice" + "<br />"
        }
    }
    
    if(retVal==false){
        $('#error_container').html("<b>Va rugam sa verificati urmatoarele erori:</b><br />" + err);
        $('#error_container').slideDown('normal');
    }
    
    return retVal
}


function promoConfirmDelete(sLink){
    var answer = confirm ("Sunteti sigur ca doriti sa stergeti?\n\rApasati OK pentru DA");
    if (answer) {window.open (sLink, '_self');}
}

function doPromoRapidFilter(rootUrl){
    sstring = $('#promo_search_string').val();
    scat = $('#promo_search_cat').val();
    
    if(sstring+scat==""){
        window.open(rootUrl+'promotii/produse/','_self');
    }else{
        if (sstring==""){sstring=" ";}        
        sstring = sstring.replace (/[^a-zA-Z0-9]/g,"_");
        
        if (sstring!=" ") {
            strLinkRedir = $.ajax({
            type: "GET", 
            url: "/ajax/ajax.utils.php?action=mark_promo_search&word="+sstring+"&link=" + rootUrl+'promotii/cauta/cat-'+scat+'/cuv-'+sstring+'/pagina-1.html',
            async: false
            }).responseText;            
        }
        
        window.open(rootUrl+'promotii/cauta/cat-'+scat+'/cuv-'+sstring+'/pagina-1.html','_self');
    }
}

function markPromoRapidFilter(word, link){
    strLinkRedir = $.ajax({
    type: "GET", 
    url: "/ajax/ajax.utils.php?action=mark_promo_search&word="+word+"&link="+link,
    async: false
    }).responseText;
}


function check_sendPromoProductContact(){
    retVal = true;
    err = "";
    
    if($('#self_name').val()==""){retVal = false; err = err + "- completati numele<br />"}
    if($('#self_email').val()==""){retVal = false; err = err + "- completati emailul<br />"}
    if($('#mesaj').val()==""){retVal = false; err = err + "- completati mesajul<br />"}
    if($('#capcha').val()==""){retVal = false; err = err + "- completati codul de verificare<br />"}else{
        strOutput = $.ajax({
        type: "POST",
        url: "/ajax/ajax.utils.php",
        data: "action=contactShop_checkCode&code=" + $('#capcha').val(), 
        async: false
        }).responseText;        
        
        if(strOutput!="ok"){
            retVal = false; err = err + "- codul de verificare a fost introdus gresit<br />"
        }
    }
    
    if (retVal==false) {
        $('#contact_error').html('<div style="font-weight: bold; font-size: 16px;">Eroare la trimiterea mesajului</div>'+err);
        $('#contact_error').slideDown('normal');
    }
    
    return retVal
}


function check_promoProductAdd(){
    retVal = true;
    err = "";
    
    if($('#title').val()==""){retVal = false; err = err + "- completati titlul produsului<br />"}
    if($('#prod_link').val()==""){retVal = false; err = err + "- completati linkul produsului<br />"}
    if($('#prod_desc').val()==""){retVal = false; err = err + "- completati descrierea sumara a produsului<br />"}
    if($('#price_start_fix').val()==""){retVal = false; err = err + "- completati pretul produsului<br />"}else{
        if(IsNumeric($('#price_start_fix').val())==false){
            retVal = false; err = err + "- pretul produsului este completat gresit<br />"
        }
    }
    
    
    if (retVal==false) {
        $('#prodadd_error').html('<div style="font-weight: bold; font-size: 16px;">Eroare la adaugarea produsului</div>'+err);
        $('#prodadd_error').slideDown('normal');
    }    
    
    return retVal
}


function check_promoProductEdit(){
    retVal = true;
    err = "";
    
    if($('#title').val()==""){retVal = false; err = err + "- completati titlul produsului<br />"}
    if($('#prod_link').val()==""){retVal = false; err = err + "- completati linkul produsului<br />"}
    if($('#prod_desc').val()==""){retVal = false; err = err + "- completati descrierea sumara a produsului<br />"}
    if($('#price_start_fix').val()==""){retVal = false; err = err + "- completati pretul produsului<br />"}else{
        if(IsNumeric($('#price_start_fix').val())==false){
            retVal = false; err = err + "- pretul produsului este completat gresit<br />"
        }
    }
    
    
    if (retVal==false) {
        $('#prodedit_error').html('<div style="font-weight: bold; font-size: 16px;">Eroare la salvarea produsului</div>'+err);
        $('#prodedit_error').slideDown('normal');
    }    
    
    return retVal
}


function check_promoShopAdd(){
    retVal = true;
    err = "";
    
    scats = $('#xcat').val();    
    if (scats!=null){        
        if(scats.length>5){retVal=false; err = err + "- puteti alege maxim 5 categorii<br />";}
    }
    if ($('#name').val()==""){retVal=false; err = err + "- completati numele magazinului<br />";}
    if ($('#shop_url').val()==""){retVal=false; err = err + "- completati adresa magazinului<br />";}
    if ($('#contact_email').val()==""){retVal=false; err = err + "- completati adresa de email de contact<br />";}
    if ($('#contact_persoana').val()==""){retVal=false; err = err + "- completati persoana de contact<br />";}
    if ($('#contact_telefon').val()==""){retVal=false; err = err + "- completati telefonul de contact<br />";}
    if ($('#contact_city').val()==""){retVal=false; err = err + "- completati orasul din care sunteti<br />";}  
    
    if (retVal==false) {
        $('#shopadd_error').html('<div style="font-weight: bold; font-size: 16px;">Eroare la adaugarea magazinului</div>'+err);
        $('#shopadd_error').slideDown('normal');
    }        
    
    return false
}


function check_promoShopEdit(){
    retVal = true;
    err = "";
    
    scats = $('#xcat').val();    
    if (scats!=null){        
        if(scats.length>5){retVal=false; err = err + "- puteti alege maxim 5 categorii<br />";}
    }
    if ($('#name').val()==""){retVal=false; err = err + "- completati numele magazinului<br />";}
    if ($('#shop_url').val()==""){retVal=false; err = err + "- completati adresa magazinului<br />";}
    if ($('#contact_email').val()==""){retVal=false; err = err + "- completati adresa de email de contact<br />";}
    if ($('#contact_persoana').val()==""){retVal=false; err = err + "- completati persoana de contact<br />";}
    if ($('#contact_telefon').val()==""){retVal=false; err = err + "- completati telefonul de contact<br />";}
    if ($('#contact_city').val()==""){retVal=false; err = err + "- completati orasul din care sunteti<br />";}  
    
    if (retVal==false) {
        $('#shopedit_error').html('<div style="font-weight: bold; font-size: 16px;">Eroare la adaugarea magazinului</div>'+err);
        $('#shopedit_error').slideDown('normal');
    }        
    
    return false
}


