function gid(id) {
    return document.getElementById(id);
}

function checkAllCheckboxes(form, namePrefix, checkAll) {
    if(typeof checkAll == "undefined") checkAll = true;

    for (i = 0; i < form.elements.length; i++) {
        e = form.elements[i];

        if(e.name.slice(0, namePrefix.length) == namePrefix) {
            e.checked = checkAll;
        }
    }
}

function popup_photo(url) {
    w = window.open("", "photo", "top=100,left=150,width=750,height=550,location=no,resizable=no,directories=no,menubar=no,scrollbars=yes,status=yes,titlebar=no,toolbar=no");
    w.document.write("<body style='margin:0;'><table height=100% align=center><tr><td>");
    w.document.write("<img src='"+url+"' border=0>");
    w.document.write("</td></tr></table></body>");
}

function popup(url, _width, _height) {
    if (window.innerWidth == null) {
        _openerWidth = document.body.clientWidth;
        _openerHeight=document.body.clientHeight;
    }
    else {
        _openerWidth = window.innerWidth;
        _openerHeight = window.innerHeight;
    }
    _left = (_openerWidth - _width) / 2;
    _top = (_openerHeight - _height) / 2;

    w = window.open(url, null, "top="+_top+",left="+_left+",width="+_width+",height="+_height+",location=no,resizable=no,directories=no,menubar=no,scrollbars=no,status=yes,titlebar=no,toolbar=no");
}
//popup window with scroll bars and with ability of resize window
function popup2(url, _width, _height) {
    if (window.innerWidth == null) {
        _openerWidth = document.body.clientWidth;
        _openerHeight=document.body.clientHeight;
    }
    else {
        _openerWidth = window.innerWidth;
        _openerHeight = window.innerHeight;
    }
    _left = (_openerWidth - _width) / 2;
    _top = (_openerHeight - _height) / 2;

    w = window.open(url, null, "top="+_top+",left="+_left+",width="+_width+",height="+_height+",location=no,resizable=yes,directories=no,menubar=no,scrollbars=yes,status=yes,titlebar=no,toolbar=no");
}
function emptyPopup(name, _width, _height){
    if (window.innerWidth == null) {
        _openerWidth = document.body.clientWidth;
        _openerHeight=document.body.clientHeight;
    }
    else {
        _openerWidth = window.innerWidth;
        _openerHeight = window.innerHeight;
    }
    _left = (_openerWidth - _width) / 2;
    _top = (_openerHeight - _height) / 2;
    w = window.open("", name, "top="+_top+",left="+_left+",width="+_width+",height="+_height+",location=no,resizable=no,directories=no,menubar=no,scrollbars=no,status=yes,titlebar=no,toolbar=no");
}
function popupForPrint(url, _width, _height) {
    if (window.innerWidth == null) {
        _openerWidth = document.body.clientWidth;
        _openerHeight=document.body.clientHeight;
    }
    else {
        _openerWidth = window.innerWidth;
        _openerHeight = window.innerHeight;
    }
    _left = (_openerWidth - _width) / 2;
    _top = (_openerHeight - _height) / 2;
    w = window.open(url, null, "top="+_top+",left="+_left+",width="+_width+",height="+_height+",location=no,resizable=no,directories=no,menubar=no,scrollbars=no,status=yes,titlebar=no,toolbar=yes");
}

var swapImageObject;
var swapImageOldSrc = "";

function swapImage(img, new_src) {
    swapImageObject = img;
    swapImageOldSrc = img.src;
    img.src = new_src;
    img.onmouseout = swapImgRestore;
}

function swapImgRestore() {
    swapImageObject.src = swapImageOldSrc;
}

function setCookie(name, value, days) {
    var today = new Date();
    var expDate = new Date(today.getTime() + days*24*60*60*1000);

    expires = expDate.toGMTString();
    __rnd = Math.random();
    document.cookie = name+"="+value+"; expires=" + expires;
    document.cookie = "__rnd="+__rnd+"; expires=" + expires;
}

function setLanguage(id) {
    buf = document.cookie;

    setCookie("lang", id, 30);
  //  alert(buf);
  //  alert(document.cookie);
    if (buf == document.cookie) return true; else{
        document.location.reload(); false;
    }
}
images = new Array(
        'white_arrow.gif',
        'black_arrow.gif',
        '2handtracer_004c_29.gif',
        'white_arrow.gif',
        'white_arrow.gif'
    )


    function PreloadImages()
    {
        for (var i=0; i<images.length; i++){
            PreloadImage(images[i]);
        }
    }

    function PreloadImage(name)
    {
        var img = new Image;
        img.src = 'http://agromachine.com/images/'+name;
    }

    PreloadImages();
	//--------------------------------------------------
	var _td, _url;
                            function left_menu_over(td, url) {
                                _td = td;
                                if (_td.className == "nav") {
                                    _td.className = "nav-over";
                                    _url = url;
                                    _td.onmouseout = left_menu_out;
                                }
                                _td.onclick = left_menu_click;
                            }

                            function left_menu_out() {
                                _td.className = "nav";
                            }

                            function left_menu_click() {
                                if (_url) top.location.href = _url;
                            }
							
	//--------------------------------------------------
	var _td, _img, _url;
 function top_menu_over(td, img, url) {
        _td = td;
        _td.className = "menu-select";
        _td.style.background = "url(\"http://agromachine.com/images/2handtracer_004c_29.gif\")";
        _img = document.getElementById(img);
        _img.src = "http://agromachine.com/images/white_arrow.gif";
        _url = url;
        _td.onmouseout = top_menu_out;
        _td.onclick = top_menu_click;
    }

    function top_menu_out() {
        _td.className = "menu";
        _td.style.background = "";
        _img.src = "http://agromachine.com/images/black_arrow.gif";
    }

    function top_menu_click() {
        top.location.href = _url;
    }
	
	//--------------------------------------------------
	<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-----------------------------------------

