function gotoURL(url) {
	if (url != "") {
	window.top.location.href = url;
	}
}
// click to popup
function openWindow(url,winName,features) {
	if (winName.window) winName.focus;
	popupWin = window.open(url,winName,features)
	popupWin.focus;
}
// forum,user_content,admin_content_types
function deleteConfirm(what,formName,url) {
	if (confirm("Are you sure you want to delete "+ what +"? ")) {
		if (formName != null) {
			formName.submit()
		} else {
			window.location.href = url
		}
	}
}
// forum,admin_style
var key_tab = 9;
function processTab() {
	if (window.event.keyCode == key_tab) 
	{
	var s = document.selection;
	var tr = s.createRange();
	if ( tr != null ) 
		tr.text = "\t";
		window.event.returnValue=false;
	}
}
// admin_content
function update_field(sNewValue,sForm,sField){
	eval("document." + sForm + "[sField].value = sNewValue;");
}
function secureImages(type,id,title,w,h){
	if (type=='a'){url='http://images.amazon.com/images/P/'+id+'.01.MZZZZZZZ.jpg';}
	if (type=='a1'){url='http://images.amazon.com/images/P/'+id+'.01.LZZZZZZZ.jpg';}
	if (type=='a2'){url='http://images.amazon.com/images/P/'+id+'.01.MZZZZZZZ.jpg';}
	if (type=='a3'){url='http://images.amazon.com/images/P/'+id+'.01.THUMBZZZ.jpg';}
	document.write ('<img alt="'+title+'" title="'+title+'" src="'+url+'" style="'+w+h+'">');
}
function secureLink(type,id,title,aid){
	if (type=='abuybtn'){url='http://www.amazon.com/exec/obidos/ASIN/'+id+'/'+aid;url2='/style/images/merx/buy6whitesmall.gif'}
	if (type=='abuyimage'){url='http://www.amazon.com/exec/obidos/ASIN/'+id+'/'+aid;url2='http://images.amazon.com/images/P/'+id+'.01.MZZZZZZZ.jpg'}
	if (type=='abuylink'){url='http://www.amazon.com/exec/obidos/ASIN/'+id+'/'+aid;}
	if (type=='abuylink')
		{document.write ('<a href="'+url+'" title="'+title+'">'+title+'</a>');}
	else
		{document.write ('<a href="'+url+'" alt="'+title+'" title="'+title+'"><img style=float:left; src="'+url2+'"></a>');}
}
function secureLink2(type,id,title,title_pre,title_post,aid,mo,w,h){
	var style;
	if (w||h){
		style=' style=';
		if (w) style+='width:'+w+'px;';
		if (h) style+='height:'+h+'px;';
	}
	if (mo){
		mo=' onmouseover="window.status=\'http://'+mo+'\';return true;" onmouseout="window.status=\'\';return true;"';
 	}
	if (type=='cimage'){url='http://www.qksrv.net/click-'+aid+'-'+id;url2='http://www.qksrv.net/image-'+aid+'-'+id;}
	if (type=='clink'){url='http://www.qksrv.net/click-'+aid+'-'+id;}
	if (type=='clink')
		{document.write (title_pre+'<a href="'+url+'" title="'+title+'"'+mo+'>'+title+'</a>'+title_post);}
	else
		{document.write ('<a href="'+url+'" alt="'+title+'" title="'+title+'" '+mo+'><img '+style+' src="'+url2+'"></a>');
		//document.write (url+'<br>'+url2);
	}
}

function addOnloadEvent(fnc){
// ex. addOnloadEvent(function(){functionName('arg1') });   or, if no args, just say addOnloadEvent(functionName);
// add as many of these as needed - does not interfere with any existing onloads
	if (typeof window.addEventListener != "undefined") window.addEventListener("load", fnc, false);
	else if (typeof window.attachEvent != "undefined") {window.attachEvent("onload", fnc);}
	else {if (window.onload != null) {var oldOnload = window.onload;window.onload = function (e) {
		oldOnload(e);window[fnc]();};}else window.onload = fnc;}
}
var  m = document.uniqueID /*IE*/
	&& document.compatMode  /*>=IE6*/
	&& !window.XMLHttpRequest /*<=IE6*/
	&& document.execCommand;
try{if(m){document.execCommand("BackgroundImageCache", false, true);}} /* = IE6 only */
catch(err){};

function classExists(o,c){ //does (c)lassname exist in tag or (o)bject? - returns true or false
	var re=new RegExp('\\b'+c+'\\b');return re.test(o.className);
}
function getCookie(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
		return ""
}
function setCookie(name, value){
	document.cookie = name+"="+value //cookie value is domain wide (path=/)
}

// checks for old browsers - replace el=document.getElementById(id) with el=ALTgetElementById(id)
var ALTgetElementById;
if(document.getElementById){ALTgetElementById = function(id){return document.getElementById(id);}}//prefer W3C DOM
else if(document.all){//older browsers - tests that IDs are unique and dont coincide with NAME on other elements
	ALTgetElementById = function(id){
		var tempEl=null, el=document.all[id];
		if (!el){el=null;}//el is undefined so its null
	 	else if((!el.id)||(el.id != id)){//if collection or name same as id
			if(el.length){ // a collection (but could be name of form or select element)
				for(var c=0;c<el.length;c++){if((el[c].id)&&(el[c].id == id)){tempEl=el[c];break;}}
				el=tempEl;//its the first match, or if no match its still null
			}
			else {el=null;} //getElementById should not return named elements, its null
		}//else, passed test (found matching id)
		return el;
	}
}
else{ALTgetElementById = function(id){return null;}
}

