function ShowPic(caller, url) {
    if (caller.src != url) {
        caller.src = url;
    }
}

function openPopup(url, widthx, heighty, startx, starty, fixed) {
    if (fixed == true) {
        window.open(url, '', 'width=' + widthx + ', height=' + heighty + ', resizable=no, scrollbars=no, screenx=' + (screen.width - widthx) / 2 + ', screeny=' + (screen.height - heighty) / 2 + ',menubar=0, toolbar=0');
    }
    else {
        window.open(url, '', 'width=' + widthx + ', height=' + heighty + ', resizable=yes, scrollbars=yes, screenx=' + (screen.width - widthx) / 2 + ', screeny=' + (screen.height - heighty) / 2 + ', menubar=0, toolbar=0');
    }
}

function srchClick(obj) {
    obj.style.color = '#000000';

    if (obj.value == 'Mot Clef ou num Annonce') {
        obj.value = '';
    }
}

function OpenCitySearch() {
    window.open('srch_city_pop.php', '_blank', 'widht=450, height=390, resizable=false, scrollbars=no, menubar=0, toolbar=0');
}

function GetURLParameter(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);

    if (results == null) {
        return "";
    }
    else {
        return results[1];
    }
}

function SetSrchCity(id, zone) {
    sWord = GetURLParameter('words');
    sCategory = GetURLParameter('category');
    sSubCategory = GetURLParameter('subcategory');
    sMinimumPrice = GetURLParameter('price_min');
    sMaximumPrice = GetURLParameter('price_max');
    sMinimumYear = GetURLParameter('year_min');
    sMaximumYear = GetURLParameter('year_max');
    sCommOnly = GetURLParameter('comm_only');
    sSeekOnly = GetURLParameter('seek_only');
    sSoldOnly = GetURLParameter('sold_only');
    sPicsOnly = GetURLParameter('pics_only');
    sZone = GetURLParameter('zoneopt');


    window.location = 'index.php?section=search&words=' + sWord +
    '&category=' + sCategory +
    '&subcategory=' + sSubCategory +
    '&price_min=' + sMinimumPrice +
    '&price_max=' + sMaximumPrice +
    '&year_min=' + sMinimumYear +
    '&year_max=' + sMaximumYear +
    '&comm_only=' + sCommOnly +
    '&seek_only=' + sSeekOnly +
    '&sold_only=' + sSoldOnly +
    '&pics_only=' + sPicsOnly +
    '&city=' + id +
    '&zoneopt=' + zone;
}

function checkEnterKey(form) {
    if (window.event.keyCode == 13) {
        form.submit();
    }
}

function highlightLoginButton(obj) {
    obj.getElementsByTagName('img')[0].src = '/media/img/btn/left_ovr.gif';
    obj.getElementsByTagName('img')[1].src = '/media/img/btn/right_ovr.gif';
    obj.getElementsByTagName('td')[1].style.background = 'url(/media/img/btn/center_ovr.gif)';
}

function resetLoginButton(obj) {
    obj.getElementsByTagName('img')[0].src = '/media/img/btn/left.gif';
    obj.getElementsByTagName('img')[1].src = '/media/img/btn/right.gif';
    obj.getElementsByTagName('td')[1].style.background = 'url(/media/img/btn/center.gif)';
}
