
var elRow = "";
var elRowClass = "";

function openChat() {
	window.open('http://www.hawksquawk.net/chat_new/index.php','ChatFactory','toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no,status=no,width=625,height=470');
}

function checkIP(ip) {
	var str = 'http://www.hawksquawk.net/forums/admin/duplicatecheck.php?ip=' + ip;
	window.open(str,'CheckIP','toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=900,height=470');
}

function mapIP(ip) {
	var str = 'http://www.mapmyipaddress.com/default.aspx?a=' + ip;
	window.open(str,'MapIP','toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=900,height=470');
}

function checkSpelling(str) {
	var origStr = str;
	var sendStr = str;
	var url = 'http://www.spellcheck.net/cgi-bin/spell.exe?action=checkpg&string=' + str;
	window.alert('You will have to COPY and PASTE the corrected text back into your post.');
	window.open(url,'message','toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=750,height=550');
	
	/*
	if(confirm('Format the hard disk?'))
		alert('You are very brave!');
	else alert('A wise decision!')
	*/
}

function submitForm(elem){
	while (elem.parentNode && elem.parentNode.tagName != "FORM"){
		elem = elem.parentNode;
	}
	var oForm = elem.parentNode;
	oForm.submit();
}

function buttonPressed(url) {
	window.location = url;
}

function removeHTMLTags(str) {
	var strTagStrippedText = str.replace(/<\/?[^>]+(>|$)/g, "");
	return strTagStrippedText;     
}

function highlightRow(rowID) {
	elRow = document.getElementById(rowID);
	if (elRow != null && elRow != "") {
		elRowClass = elRow.className.toLowerCase();
		if (elRowClass != null && elRowClass != "") {
			if (elRowClass == 'darktable' || elRowClass == 'newdarktable') {
				elRow.style.backgroundColor = "#dddddd";
			}
			if (elRowClass == 'lighttable' || elRowClass == 'newlighttable') {
				elRow.style.backgroundColor = "#cccccc";
			}
			if (elRowClass == 'stickyrow') {
				elRow.style.backgroundColor = "#efefef";
			}		
		}
	}
}

function lowlightRow(rowID) {
	elRow = document.getElementById(rowID);
	if (elRow != null && elRow != "") {
		elRowClass = elRow.className.toLowerCase();
		if (elRowClass != null && elRowClass != "") {
			if (elRowClass == 'darktable' || elRowClass == 'newdarktable') {
				elRow.style.backgroundColor = "#eeeeee";
			}
			if (elRowClass == 'lighttable' || elRowClass == 'newlighttable') {
				elRow.style.backgroundColor = "#ffffff";
			}
			if (elRowClass == 'stickyrow') {
				elRow.style.backgroundColor = "#dddddd";
			}
		}
	}
}

function ProperCase() {
	document.word.string.value = SetProperCase(document.word.string.value);
	document.textbody.string.value = SetProperCase(document.textbody.string.value)
}

function SetProperCase(stext) {
	var stemp;
	
	// Set all to lowercase
	stext = stext.toLowerCase();
	
	// Clear leading spaces
	while (stext.charAt(0) == ' ') {    
	  stext = stext.substr(1);
	} 

	// Clear trailing spaces
	while (stext.charAt(stext.length-1) == ' ')	{    
	  stext = stext.substr(0,stext.length-1);
	} 

	// Uppercase first character
	stemp = stext.substr(0,1);
	stemp = stemp.toUpperCase();
	stext = stemp + stext.substr(1);

	// Uppercase after any space
	for (var i=0;i<stext.length;i++) {
	  
		// If letter a-z or A-Z
	  if (((stext.charCodeAt(i) >= 0x41) && (stext.charCodeAt(i) <= 0x5A)) || ((stext.charCodeAt(i) >= 0x61) && (stext.charCodeAt(i) <= 0x7A))) {
	    
			// If previous character is space or '(' then uppercase this character
	    if ((stext.charAt(i-1) == ' ') || (stext.charAt(i-1) == '(') || (stext.charCodeAt(i-1) == 10)) {
	      stemp = stext.substr(i,1);
	      stemp = stemp.toUpperCase();
	      stext = stext.substr(0,i) + stemp + stext.substr(i+1);
	    }
	  }
	}
	return stext;
}

function fixCase(divID) {
	var el = document.getElementById(divID);
	if (el != null) {
		var textStr = SetProperCase(el.innerHTML);
		el.innerHTML = textStr;
		//window.alert(textStr);
	}
}

function removeCaps(divID) {
	var el = document.getElementById(divID);
	if (el != null) {
		el.style.textTransform = "lowercase";	
	}
}

function colorAltTable() {
	var i=0; 
	for (i=0; document.getElementById("altRowTable").rows[i]; i=i+2) {
		tab = document.getElementById("altRowTable").rows[i];
		tab.bgColor = "\#dddddd";
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

