///////////////////////////////////////////////////
///// COPYRIGHT: 2007 DESIGN OF A DECADE
///// PROGRAMER: Paul Smiechowicz
///// EMAIL: paul@designofadecade.com
///////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////// GLOBAL FUNCTION
function initLoad () {
var newHeight = document.getElementById('contentHolder').offsetHeight;
document.getElementById('leftCol').style.height = (newHeight-25)+"px";
document.getElementById('rightCol').style.height = (newHeight-25)+"px";
}

var previousDIV = 'n/a';
function opensubmenu (divID) {
if (divID.childNodes[2]) {
startList(divID.childNodes[2]);
divID.childNodes[2].style.visibility = 'visible';
previousDIV = divID;
} else {
previousDIV = 'n/a';
}


}

function closesubmenu (divID) {
divID.style.visibility = 'hidden';
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/////////////////////////////////////////////////////////////////////////// GLOBAL FUNCTION



///////////////// SEARCH FILED
function searchInventroy () {
location.href = 'http://www.orangefish.ca/items.php?search='+document.getElementById('searchInput').value;
}

function cleanupScript (validID) {
var cleanup = validID.value.replace (/[~|%|^|*|(|)|{|}|:|;|\"|\'|<|>|,|\/|`|\||\\|\$|]/gi,''); 
validID.value = cleanup;
}

function checkE (evt) {
var evt = (evt) ? evt : ((window.event) ? event : null);
var charCode = (evt.charCode) ? evt.charCode : evt.keyCode;
if (charCode == 13) {
searchInventroy ()
}
}
///////////////// SEARCH FILED


function cleanupSpecial (validID) {
var cleanup = validID.value.replace (/[~|(|)|\"|\'|<|>|,|\/|`|\||\\|\$|]/gi,''); 
validID.value = cleanup;
}

function cleanupRequired (validID) {
if (validID.value == 'REQUIRED' || validID.value == 'PLEASE FILL IN VALID EMAIL' || validID.value == 'Invalid Password' || validID.value == 'Invalid Username' || validID.value == 'Please Sign In' || validID.value == 'Invalid Information' || validID.value == 'InvalidInformation') {
validID.value = '';
}
}

function checkFormEnter (evt,callForm) {
var evt = (evt) ? evt : ((window.event) ? event : null);
var charCode = (evt.charCode) ? evt.charCode : evt.keyCode;
if (charCode == 13) {
document[callForm].submit();
}
}

var previousOpenDIV = '';
function toggleView (divID) {

var nextDiv = document.getElementById(divID);
if (nextDiv.style.display == "none") {
nextDiv.style.display = "block";
} else {
nextDiv.style.display = "none";
}

if (document.getElementById(previousOpenDIV) && divID.length == previousOpenDIV.length) {
document.getElementById(previousOpenDIV).style.display = "none";
} else if (document.getElementById(previousOpenDIV) && divID.length < previousOpenDIV.length) {
var closeParent = previousOpenDIV.charAt(0);
document.getElementById(previousOpenDIV).style.display = "none";
document.getElementById(closeParent).style.display = "none";
} 

if (previousOpenDIV != divID) {
previousOpenDIV = divID;
} else {
previousOpenDIV = '';	
}

var getHeight = document.getElementById('checkHeight').offsetHeight;
if (getHeight > 400) {
document.getElementById('maincontentHeight').style.height = (getHeight+200)+"px";
} else {
document.getElementById('maincontentHeight').style.height = "618px";	
}
initLoad ();
}


function checkHeight() {
var getHeight = document.getElementById('checkHeight').offsetHeight;
if (getHeight > 400) {
document.getElementById('maincontentHeight').style.height = (getHeight+200)+"px";
} else {
document.getElementById('maincontentHeight').style.height = "618px";	
}	
initLoad ();
}

function viewpopup(loadpage) {

	var intWidth = 935;
	var intHeight = 600;
	var intLeft = (screen.availWidth / 2) - (intWidth / 2 );
	var intTop = (screen.availHeight / 2) - (intHeight / 2 );
	
OpenWin = this.open(loadpage, "Load", 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=935,height=600, screenX=' + intLeft + ',screenY=' + intTop + ',left=' + intLeft + ',top= ' + intTop + ''); 
OpenWin.focus();

}