/**
 * All javascript
 * MotoTools
 */
/**
 * Lcation
 */
function SearchProducts(){
    var searchText = document.getElementById('searchText').value;
	location.href = '/search/?text=' + searchText;
    return false;
}


function sMenu(obj, menu, align){
    pTop = 0;
    pLeft = 0;
    getAbsolutPosition(obj);
    if (align == "left") {
        //window.alert(menu);
        //document.getElementById(menu).offsetWidth=obj.offsetWidth='px';
        //document.getElementById(menu).style.left=pLeft - 250 + 'px';
        document.getElementById(menu).style.left = pLeft - obj.offsetWidth + 'px';
        //document.getElementById(menu).style.left=pLeft - document.getElementById(menu).offsetWidth+'px';
        document.getElementById(menu).style.top = pTop + 'px';
        document.getElementById(menu).style.display = 'block';
    }
    else 
        if (align == "down") {
            //window.alert(obj.tagName);
            document.getElementById(menu).style.left = pLeft - 9 + 'px';
            document.getElementById(menu).style.top = pTop + obj.offsetHeight + 'px';
            document.getElementById(menu).style.display = 'block';
        }
        else {
            pTop = pTop + 'px';
            document.getElementById(menu).style.left = pLeft + obj.offsetWidth + 'px';
            document.getElementById(menu).style.top = pTop;
            document.getElementById(menu).style.display = 'block';
        }
}


function getAbsolutPosition(obj){
    pObj = obj.offsetParent;
    
    if (pObj.tagName != "BODY") {
        getAbsolutPosition(pObj);
    }
    
    pTop = pTop + obj.offsetTop;
    pLeft = pLeft + obj.offsetLeft;
}


function hMenu(obj, menu){
    document.getElementById(menu).style.display = 'none';
}


function popup(fileUrl, winW, winH, winN, scrollB){
    var winWidth = (winW) ? winW : 200;
    var winHeight = (winH) ? winH : 200;
    var winName = (winN) ? winN : 'popupWin';
    var scrollBars = (scrollB) ? scrollB : 'auto'
    posX = Math.round((screen.width - winWidth) / 2);
    posY = Math.round((screen.height - winHeight) / 2);
    posCode = "left=" + posX + ",top=" + posY;
    var popupWin = window.open(fileUrl, winName, "menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);
    if (popupWin) 
        popupWin.focus();
}

function makedate(){
    document.forms.booking.dd.value = document.forms.booking.outDay.value + "/" + document.forms.booking.outMonth.value + "/" + document.forms.booking.outYear.value
    document.forms.booking.ad.value = document.forms.booking.inDay.value + "/" + document.forms.booking.inMonth.value + "/" + document.forms.booking.inYear.value
    document.forms.booking.inYear.value = ''
    document.forms.booking.inDay.value = ''
    document.forms.booking.inMonth.value = ''
    document.forms.booking.outYear.value = ''
    document.forms.booking.outDay.value = ''
    document.forms.booking.outMonth.value = ''
}


