function showSubmenu(elementId) {
    var elements = $$('.bottomnav_show');
    elements.each(function(item) {
        item.className="navline_bottom bottomnav_hidden";
    });
    if (elementId) {
        $(elementId).className = 'navline_bottom bottomnav_show';
    }
}




var items = new Array();
function userSelect(state,articleid,starnumber) {
    if (state) {
        cookie = Get_Cookie('ArticleUserRating_' + articleid);
        if (!cookie) {
            for (i=1;i<=5;i++) {
                items[i] = document.getElementById('star_' + i).src;
            }
            for (i=1;i<=starnumber;i++) {
                document.getElementById('star_' + i).src = '/images/full.gif';
            }
            for (i=(starnumber+1);i<=5;i++) {
                document.getElementById('star_' + i).src = '/images/off.gif';
            }
        }
    } else {
        for (i=1;i<=5;i++) {
            document.getElementById('star_' + i).src = items[i];
        }
    }
}

function vote(articleid,starnumber) {
    var date = new Date();
    date.setTime(date.getTime()+(365*24*60*60*1000));
    Set_Cookie('ArticleUserRating_' + articleid,'1',date); 

    new Ajax.Request('/article.php?mode=userratingdb&articleid=' + articleid + '&rating=' + starnumber,
    {
        method:'get',
        asyncronus: false,
        onSuccess: function(transport) {
            var response = transport.responseText;
            var json = transport.responseText.evalJSON();
            var values = json['average'].split('.');
            $('numbervotes').innerHTML = json['total'];
            for (i=1;i<=5;i++) {
                $('star_' + i).removeAttribute('onclick');
                $('star_' + i).removeAttribute('title');
                $('star_' + i).removeAttribute('onmouseover');
                $('star_' + i).removeAttribute('onmouseout');
                if (i < 5) {
                    $('stardot_' + i).removeAttribute('onmouseover');
                    $('stardot_' + i).removeAttribute('onmouseout');
                }
            }
            var starcounter = 1;
            for (i=1;i<=values[0];i++) {
                $('star_' + i).src = '/images/full.gif';
                starcounter++;
            }

            if (values[1] <= 5 && values[1] > 0) {
                $('star_' + starcounter).src = '/images/half.gif';
                starcounter++;
            }

            if (values[1] > 5) {
                $('star_' + starcounter).src = '/images/full.gif';
                starcounter++;
            }
            
            if (starcounter <= 5) {
                for (i=starcounter;i<=5;i++) {
                    $('star_' + starcounter).src = '/images/off.gif';
                    starcounter++;
                }
            }


        },
        onFailure: function(){ alert('Something went wrong...') }
    });


}

function CheckEmail(form,field)  {
    url = document[form][field].value;
    var status = true;
    if (url != null && url != "") {
        a = url.lastIndexOf("@");
        b = url.lastIndexOf(".");
        c = url.indexOf(":");
        d = url.indexOf("/");
        e = url.substring(0,a);
        f = e.indexOf("@");
        g = url.substring(a+1,url.length);
        h = g.indexOf("[");
        i = g.indexOf("]");
        j = g.indexOf("<");
        k = g.indexOf(">");
        l = url.substring(a+1,b);
        m = url.substring(b+1,url.length);
        n = url.substring(0,a);
        o = 0;
        if (a > b) {o++};
        if (c != -1) {o++};
        if (d != -1) {o++};
        if (f != -1) {o++};
        if (h != -1) {o++};
        if (i != -1) {o++};
        if (j != -1) {o++};
        if (k != -1) {o++};
        if (l.length < 1) {o++};
        if (m.length < 2 || m.length > 4) {o++};
        if (n.length < 1) {o++};
        if (o == 0) {
            status = true;
        }
        else {
            status = false;
        }
    }
    else {
        status = false;
        url="";
    }
    return status;
}

function PrintFriendly() {
    newWindow=window.open(printfriendly_url,"mywindow","width=900,height=500,toolbar=1,menubar=0,scrollbars=1,resizeable=1");
    newWindow.focus();
}

function ChangeIssue() {
    if (document.issue.issueID.options[document.issue.issueID.selectedIndex].value != 0) {
        location.href='/issue.' + document.issue.issueID.options[document.issue.issueID.selectedIndex].value + '.html';
    }
}
function openBigMap() {
    newWindow=window.open("/categorymap.php?mode=big","mywindow","width=900,height=655,toolbar=0,menubar=0,scrollbars=0,resizeable=0");
    newWindow.focus();
}

function showVideo(videoid) {
    var videoWindow=window.open('/videowindow.php?videoid=' + videoid,"videowindow","width=650,height=450,toolbar=0,menubar=0,scrollbars=1,resizeable=1");
    videoWindow.focus();
}

function showLegalTerms() {
	var legalTerm=window.open('/legalterms.php','legaltermwindow',"width=600,height=300,toolbar=0,menubar=0,scrollbars=1,resizeable=1");
    legalTerm.focus();
}

