// Copyright Search-22 © 2002-2003
// Do not adapt, alter, reverse engineer,  reverse assemble, or create a derivative work from any of the material
// contained in this web-site. This material may not be copied, modified, distributed, or transmitted in any way
// without prior written permission of the Owner of the Search-22.com website that can be reached through the
// online form at http://www.Search-22.com/contact.html

var dom    = (document.getElementById) ? true : false;
var ns4    = (document.layers) ? true : false;
var ie     = (document.all) ? true : false;
var ns	   = (navigator.appName=='Netscape') ? true : false;
var ie4    = ie && !dom;
var mac    = (navigator.appVersion.indexOf("Mac") != -1);
var ie4mac = ie4 && mac;

var ie5mac = dom && ie && mac;
var ie5win = dom && ie && !mac;
var ns6    = dom && (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
var appVer;
(ns6)? appVer=parseFloat(navigator.userAgent.slice(-3)) : appVer=parseFloat(navigator.appVersion);
var newWin;
var hlpWin;
var strQ;

function bookmark(url, desc) {
	if (window.external) { window.external.AddFavorite(url, desc); }
	else if (ns) {
		alert("Push the OK button and hit CTRL-D to add Search-22 to your bookmarks");
	} else {
		alert("Sorry, your browser does not support the Javascript bookmark-function. Push the OK button and manually add this page to your bookmarks.");
	}
}

var pa_id;
var c_bg;
var c_bt;
var c_lt;
var c_dk;

function set_pa() {
	switch (pa_id) {
		case 0: c_bg = "#F1F0FF"; c_bt = "#F0C080"; c_lt = "#F5CC99"; c_dk = "#A07040"; break;
		case 1: c_bg = "#F1F0FF"; c_bt = "#AFC4D5"; c_lt = "#D6E7EF"; c_dk = "#104A7B"; break;
		case 2: c_bg = "#F1F0FF"; c_bt = "#CC9966"; c_lt = "#CC9999"; c_dk = "#663300"; break;
		case 3: c_bg = "#F1F0FF"; c_bt = "#CCCC99"; c_lt = "#DADAA8"; c_dk = "#999933"; break;
		case 4: c_bg = "#F1F0FF"; c_bt = "#CBCFEB"; c_lt = "#E4E8FF"; c_dk = "#9A9ECD"; break;
		case 5: c_bg = "#F1F0FF"; c_bt = "#99CC99"; c_lt = "#D0E8D0"; c_dk = "#6AB56A"; break;
		case 6: c_bg = "#F1F0FF"; c_bt = "#FF9999"; c_lt = "#FFCCCC"; c_dk = "#FF3333"; break;
		case 7: c_bg = "#F1F0FF"; c_bt = "#CCCCCC"; c_lt = "#E4E4E4"; c_dk = "#C0C0C0"; break;
		case 8: c_bg = "#F1F0FF"; c_bt = "#99CCFF"; c_lt = "#CCE5FF"; c_dk = "#6699FF"; break;
		case 9: c_bg = "#F1F0FF"; c_bt = "#99FF66"; c_lt = "#CAFFB0"; c_dk = "#66CC33"; break;
		
		case 911: c_bg = "#F1F0FF"; c_bt = "#0000ff"; c_lt = "#0000ff"; c_dk = "#0000ff"; break;		

		default: c_bg = "#F1F0FF"; c_bt = "#CC9966"; c_lt = "#CC9999"; c_dk = "#663300";
	}
}

function sts(s_id) { top.status = sDesc[s_id]; }

function mover(s_id) {
	var strSearch = "search" + s_id;
	var elem;
	top.status = sDesc[s_id];
	set_pa();
	if (dom) elem = document.getElementById(strSearch);
	else if (ie) elem = document.all[strSearch];
	elem.style.cursor = ( ie ?  "hand" : "pointer" );
	elem.style.backgroundColor = c_bt;
	elem.style.borderBottom = c_dk + " solid thin";
	elem.style.borderLeft = c_lt + " solid thin";
	elem.style.borderRight = c_dk + " solid thin";
	elem.style.borderTop = c_lt + " solid thin";
}

function mdown(s_id)  {
	var strSearch = "search" + s_id;
	var elem;
	if (dom) elem = document.getElementById(strSearch);
	else if (ie) elem = document.all[strSearch];
	elem.style.backgroundColor = c_bt;
	elem.style.borderBottom = c_lt + " solid thin";
	elem.style.borderLeft = c_dk + " solid thin";
	elem.style.borderRight = c_lt + " solid thin";
	elem.style.borderTop = c_dk + " solid thin";
}

function mout(s_id) {
	var strSearch = "search" + s_id;
	var elem;
	top.status = '';
	if (dom) elem = document.getElementById(strSearch);
	else if (ie) elem = document.all[strSearch];
	elem.style.backgroundColor = c_bg;
	elem.style.border = c_bg + " solid thin";
}

function search22(num) {
	var i = 0;
	while (!document.docForm.openIn[i].checked) i++;

	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);

	setCookie("open_in_n", i, now);

	if (document.docForm.strQuery.value == "") { alert('Enter some keywords before clicking!  '); }
	else {

		setCookie("qry", document.docForm.strQuery.value, now);
		
		switch(i){
			case 0 : openSame(num); break;
			case 1 : openNew(num); break;
			default: openSame(num);
		}
	}
}

function openSame(num) {
	var url, strQ;
	strQ = escape(document.docForm.strQuery.value);
	url = pre[num] + strQ + post[num];
	location.href=url;
}

function openNew(num){
	var url, strQ;
	strQ = escape(document.docForm.strQuery.value);
	url = pre[num] + strQ + post[num];
	if (newWin != null && !newWin.closed) {
		newWin.location.href=url;
		newWin.focus();

	} else
		newWin=window.open(url);
}

function popHelp(){
	if (hlpWin != null && !hlpWin.closed) { 
		hlpWin.close();
	}
	hlpWin=window.open("/helpopup.php", "newwin", "resizable=1,scrollbars=1,height=480,width=640");
}


function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
		date.setTime(date.getTime() - skew);
}

function draw_table(pBgColor,pTextClass,pRdoBg, pBgImage, pTxt) {
	var str;
	var i;
	var vTxt;
	var qry = document.URL;
	
	if (pTxt=="") {vTxt = "First type some keywords";} else {vTxt = pTxt;}
	
	str = "<table border=0 width=594 bgcolor=#333333 cellspacing=1 cellpadding=22>";
	str += "<tr>";
	str += add_bg(pBgColor, pBgImage);
	str += "<table border=0 width=550 cellspacing=0 cellpadding=0>";
	str += "<tr><td width=99% align=center class=" + pTextClass + ">" + vTxt + ": <font point-size=10><input onblur=\"updateIframe();\" name=strQuery size=33 border=1></font></td><td width=1% align=right class=" + pTextClass + "><a href=javascript:popHelp() class=" + pTextClass + "><small><small>Help!</small></small></a></td></tr>";
	str += "<tr><td width=100% height=22 colspan=2 class=" + pTextClass + ">Then click one of the search buttons below...<img src=/1.gif border=0 height=22 width=1></td></tr>";
	str += "<tr>";
	str += "<td width=100% bgcolor=#333333 colspan=2>";
	str += "<table border=0 width=100% cellspacing=1 cellpadding=0>";
	str += "<tr>";
	for (i=0; i<22; i++) {
		str += "<td width=20% height=22 bgcolor=#f1f0ff>";
		str += "<div id=search" + i + " class=btn onmouseover=\"mover(" + i + ");\" onmousedown=\"mdown(" + i + ");\" onmouseout=\"mout(" + i + ");\" onclick=\"search22(" + i + ");\">";
		str += "<a onmouseover=\"sts(" + i + ");return true\" href=\"javascript:search22(" + i + ")\" onclick=\"(ie)?event.cancelBubble=true:(dom)?event.stopPropagation():false;\"><nobr>";
		str += sn(sName[i]) + "</nobr></a></div></td>";
		if (i%5==4) {str += "</tr><tr>";}
	}
	str += "<td width=60% bgcolor=" + pRdoBg + " colspan=3 align=center><div class=rdo><nobr>" + rd() + "</nobr></div></td>";
	str += "</tr>";
	str += "</table>";
	str += "</td>";
	str += "</tr>";
	str += "</table>";
	str += "</td>";
	str += "</tr>";
	str += "</table>";
	str += "";
	return str;
}

function sn(sName) {
	var str;
	if (ns6) { str = "<font point-size=8>" + sName + "</font>";}
	else if (ns4) { str = "<nobr><font point-size=9>" + sName + "</font></nobr>";}
	else { str = sName; }
	return str;
}

function rd() {
	var str;
	if (ns6) { str = "<font point-size=8>Show results in:&nbsp;"+cBox[0]+"This Window&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+cBox[1]+"New Window</font>";}
	else if (ns4) { str = "<font point-size=9>Show results in:&nbsp;"+cBox[0]+"This Window&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+cBox[1]+"New Window</font>";}
	else { str = "Show results in:&nbsp;"+cBox[0]+"This Window&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+cBox[1]+"New Window";}
	return str;
}

function add_bg(pBgColor, pBgImage) {
	var str;
	str = "<td width=100% bgcolor=" + pBgColor + " align=center";
	if (dom && (pBgImage != "")) {str += " background=" + pBgImage;}
	str += ">";
	return str;
}

// Copyright © 2002 Search-22.com All rights reserved.
