// Default scripts

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function openWin(url)
{
	var w = (screen.width > 1600) ? 1600 : screen.width - 50; 
	var h = (screen.height > 1000) ? 1000 : screen.height - 30; 
	var wl = (screen.width / 2) - (w / 2); 
	var wt = ((screen.height / 2) - (h / 2) - 10);
	var win = window.open(url, "popup", "width=" + w + ",height=" + h + ",menubar=1,resizable=1,location=1,status=1,scrollbars=1,top=" + wt + ",left=" + wl);
}

function checkFrames() {
	if (top.location != location) {
		top.location.href = document.location.href;
	}
}

function _search() {
    var s = $("#searchfor").val();
    s = cleanup_search(s);
    $("#searchfor").val(s);
    return (s != "");
}
function _search_page(p) {
    if (p == 0) {
        var s = $("#searchfor2").val();
        s = cleanup_search(s);
        $("#searchfor").val(s);
    } else {
        var s = $("#searchfor_p").val();
        $("#searchfor").val(s);
        $("#searchpage").val(p);
    }
    //$("#searchplatform").val($("#searchplatform2").val());
    document.forms["formsearch"].submit();
    return false;
}
function cleanup_search(s) {
    s = s.replace(/^\s*|\s*$/gi, "");
    s = s.replace(/\s+/gi, " ");
    s = s.replace(/[^a-z0-9\s-]/gi, "");
    return s;
}
function setSearch(s) {
    $("#searchfor").val(s);
    $("#searchpage").val(1);
    $("#searchplatform").val($("#searchplatform3").val());
    document.forms["formsearch"].submit();
}
function setPlatform() {
    $("#searchpage").val(1);
    $("#searchplatform").val($("#searchplatform2").val());
    document.forms["formsearch"].submit();
}
function setSearchBackColor() {
    var s = $("#searchplatform2").val();
    if (s) {
        var arr = s.split(":");
        if (arr.length == 3) {
            var c = "#e9e9e9";
            if (arr[0] == "microsoft") c = "#e2eee2";
            if (arr[0] == "nintendo") c = "#dbe6ec";
            if (arr[0] == "pc") c = "#faf3d6";
            if (arr[0] == "sony") c = "#f1d7e0";
            $("#SearchPageBox").css("background-color", c);
        }
    }
}
