var ToolTip = 0;
var ShowLabel = 1;
var pagestr = pagestr;

var strClicksns = FormatS();
var strClicks = "" + FormatS();
var strClicky = "button " + strClicks

// class=\"positive\"
// onmouseover=\"this.className = \'positive:hover\';\" onmouseout=\"this.className = \'positive\';\" 

var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet; // Is the PreSet value onces a selection has been made
var rated;


setTimeout('checkLogin();',900000);

function checkLogin() {
	if (AccountID > 0) {
		if (confirm('Your website session is about to expire and you will be logged out.\n\nClick OK to continue your session or click CANCEL or do nothing to have your session expire normally.') == true) {
			window.open('session.asp','session','width=200, height=200,modal=true,status=0,');
			setTimeout('checkLogin();',900000);
		}
	}
}

// Rollover for image Stars //
function rating(num){
	sMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}
	
	if(!rated){
		s = num.id.replace("_", ''); // Get the selected star
		a = 0;
		for(i=1; i<=sMax; i++){		
			if(i<=s){
				getObj("_"+i).className = "on";
				getObj("rateStatus").innerHTML = num.title;	
				holder = a+1;
				a++;
			}else{
				getObj("_"+i).className = "";
			}
		}
	}
}

// For when you roll out of the the whole thing //
function off(me){
	if(!rated){
		if(!preSet){	
			for(i=1; i<=sMax; i++){		
				getObj("_"+i).className = "";
				getObj("rateStatus").innerHTML = me.parentNode.title;
			}
		}else{
			rating(preSet);
			getObj("rateStatus").innerHTML = getObj("ratingSaved").innerHTML;
		}
	}
}

// When you actually rate something //
function rateIt(me, y){
	if(!rated){
		getObj("rateStatus").innerHTML = getObj("ratingSaved").innerHTML + " :: "+me.title;
		preSet = me;
		rated=1;
		getObj("ratingid").value = y;
	//	sendRate(me);
		rating(me);
	}
}

function SetCheckBox(cbn, cbv) {
	//
	if (getObj(cbn) != null) {
		if (cbv > 0) {
			getObj(cbn).checked = true;
		} else {
			getObj(cbn).checked = false;
		}
	}
	//
}

function PostSpeak(speakvalue) {
	if (tinyMCE != null) {
		getObj('Message').value = tinyMCE.getContent();
		getObj('stufff').submit();
	}
}

	
	function RemoveTiny(t) {
		var elm = window.top.tinyMCE.getInstanceById(t);
		if (elm) {
			window.top.tinyMCE.execCommand('mceRemoveControl', false, t);
		}
	}

	function AddTiny(t) {
		var elm = window.top.tinyMCE.getInstanceById(t);
		if (elm) {
			window.top.tinyMCE.execCommand('mceRemoveControl', false, t);
		}
		window.top.tinyMCE.execCommand('mceAddControl', false, t);
	}


function FormatS() {
	return "";
}

function submitform(f) {
	document.forms[f].submit();
}

function AdBr() {
document.write("<br>");
}



function AdB(Actions, Titles, Names) {
document.write("<" + strClicky + "  onclick=\"window.location.replace(\'" + Actions + "\');\" title=\"" + Titles + "\">" + Names + "</button>");
}

function Pages(Count, CurPage) {
	PagesL(Count, CurPage, 6, 0);
}

function AddPageButton(i, CurPage, ii) {
	return '<a ' + (CurPage != i ? ' class="menu" id="greenbutton" style="width:20" onclick="GoP(\'' + i + '\')"' : ' class="menu" id="greenbutton" style="width:20; font-weight: bold;"') + '>' + ii + '</a>';        
}

function GoP(p) {
	window.location.replace('?P=' + p + (pagestr != null ? '' + pagestr : ''));
}

function AddNavButton(CurPage, Count, PageLimit, ii, offsetp) {
	return '<a style="width:20" class="menu" id="greenbutton" onclick="PagesL(' + Count + ',' + CurPage + ',' + PageLimit + ',' +offsetp + ')">' + ii + '</a>';        
}

function AddPageButton2() {
	return '<a style="width:20; font-weight: bold" class="menu" id="greenbutton">1</a>';
}

function PagesL(Count, CurPage, PageLimit, offsetp) {
var strTest = '';
var v = 0;
var startp = 1;
var endp = Count;
var starth = '';
var endh = '';
var minp = Math.floor(PageLimit / 2);
var maxp =PageLimit + minp;

if (offsetp == 0) {offsetp = CurPage}
if (offsetp > Count) {offsetp = Count - minp}

if (Count > PageLimit + minp) {
	startp = offsetp - minp;
	if (startp < 1) {startp = 1};
	if (offsetp  < 1) {offsetp = 1};
	endp = startp + maxp;
	if (endp > Count) {
		endp = Count;
	}
	starth = AddNavButton(CurPage, Count, PageLimit,'<<',1) + AddNavButton(CurPage, Count, PageLimit, '<',(startp - PageLimit) - 1);
	endh = AddNavButton(CurPage, Count, PageLimit, '>',(endp + minp) + 1) + AddNavButton(CurPage, Count, PageLimit, '>>',Count - PageLimit);
}

if (Count == 0) {
	strTest += AddPageButton2();
} else {
	for (i = startp; i <= endp; i++) 
	{         
		strTest += AddPageButton(i, CurPage, i);

	}
}
getObj('Pages').innerHTML = '<table class=\'weakercell\'><tr><td>Page: </td><td>' + starth + '' + strTest + '' + endh + '</td></tr></table>';
}

function PagesF(Count, CurPage, PageLimit, offsetp) {
var strTest = '';
var v = 0;
if (Count == 0) {
	strTest += AddPageButton2();
} else {
	for (i = 1; i <= Count; i++) 
	{         
		strTest += '<option value="' + i + '" ' + (i == CurPage ? 'selected' : '') + '>' + i + '</option>';

	}
}
getObj('Pages').innerHTML = '<table class=\'weakercell\'><tr><td>Page: </td><td><select onchange="GoP(this.options[this.selectedIndex].value);">' + strTest + '</select></td></tr></table>';
}


function PagesAZ(CurPage) {
var strTest = '';
var v = 0;
for (i = 1; i <= 26; i++) 
{         
	strTest += AddPageButton(String.fromCharCode(i + 64), CurPage, String.fromCharCode(i + 64));

	if (i == 13) {
		strTest += '<br>';
	}
}

getObj('Pages').innerHTML = '<table class=\'weakercell\'><tr><td>' + strTest + '<td></tr></table>';
}

function Ada(Actions, Titles, Names) {
document.write("<" + strClicky + " onclick=\"" + Actions + ";\" title=\"" + Titles + "\">" + Names + "</button>");
}

function Adf(Actions, Titles, Names) {
document.write("<" + strClicky + " onclick=\"" + Actions + ";\" title=\"" + Titles + "\">" + Names + "</button>");
}

function fxn(stuff) {
  var str = '';
  var s;

	for (s = 0; s < stuff.value.length; s++) {
		if (stuff.value.charCodeAt(s) >= 48 && stuff.value.charCodeAt(s) <= 57) {
			str = str + '' + stuff.value.charAt(s);
		}
	}
	stuff.value = str;
	if (stuff.value == '' || stuff.value == null) {
		stuff.value = 0;
	}
	if (stuff.value.length > 1 && stuff.value.charCodeAt(0) == 48)  {
		stuff.value = stuff.value.substr(1,stuff.value.length - 1)
	}
}

function getObj(objn) {
	if (document.getElementsByName(objn).length <= 1) {
		return document.getElementById(objn);
	} else {
		return document.getElementsByName(objn);
	}
}

function fxkp(e) {
	e = e || window.event;	
	if (e != null) {
		var f = e.keyCode;
		if (e.which != null && f == 0) {
			f = e.which;
		}

		if ((f < 45 || f > 57) && f != 8 && f != 9 && f != 13 && f != 192) {
			return false;
		} else {
			return true;
		}
	} else {
		return true;
	}
}

function FormEnter(e, f) {
	e = e || window.event;
	if (e == null) {
	} else {
		if (e.keyCode == 13) {
			if (f != null)	 {
				eval(f);
			}
		}
	}
}

function SetSelect(cbn, cbv) {
	//
	if (getObj(cbn) != null) {
		var myChildren = getObj(cbn); 
		for (var s = 0; s < myChildren.options.length; s++) { 
			if (myChildren.options[s].value == cbv) {
				myChildren.selectedIndex = s;
				break;
			}
		}
	}
	//
}
