<!-- Expandable Menu System
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));
}

//fix indexOf for IE.
if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;}
	        }
		return -1;
	    }
}

// LIST ALL SHOW/HIDE ELEMENT IDS HERE

menus_status_array = new Array ();// remembers state of switches
img_close = '../../gooimages/menuarrow2.gif';
img_open = '../../gooimages/menuarrow1.gif';

function showHideSwitch (theid) {
  if (document.getElementById) {
    var switch_id = document.getElementById(theid);
    var imgid = theid+'Button';
    var button_id = document.getElementById(imgid);
    if (menus_status_array[theid] != 'show') {
      button_id.setAttribute ('src', img_close);
      switch_id.className = 'showSwitch';
	  menus_status_array[theid] = 'show';
	  document.cookie = theid+'=show';
    }else{
      button_id.setAttribute ('src', img_open);
      switch_id.className = 'hideSwitch';
	  menus_status_array[theid] = 'hide';
	  document.cookie = theid+'=hide';
    }
  }
}
function resetMenu () { // read cookies and set menus to last visited state
  if (document.getElementById) {
    for (var i=0; i<menus_array.length; i++) {
      var idname = menus_array[i];
      var switch_id = document.getElementById(idname);
      var imgid = idname+'Button';
      var button_id = document.getElementById(imgid);
      if (getCookie(idname) == 'show') {
	    button_id.setAttribute ('src', img_close);
        switch_id.className = 'showSwitch';
	    menus_status_array [idname] = 'show';
	  }else{
	    button_id.setAttribute ('src', img_open);
        switch_id.className = 'hideSwitch';
	    menus_status_array [idname] = 'hide';
	  }
    }
  }
}
//-->
// REFRESH PAGE ENGINE
function refreshpage() {
	var pageid = "";
	var sURL = unescape(window.location.pathname+'?pageid='+pageid);
	window.location.replace( sURL );
}
//-->
// POPUP WINDOW
function openPopup(popPage, width, height) {
   var randomnumber=Math.floor(Math.random()*99999999)
   x = (640 - width)/2, y = (480 - height)/2;
   if (screen) {
      y = (screen.availHeight - height)/2;
      x = (screen.availWidth - width)/2;
   }
   popWin = window.open(popPage,randomnumber,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',resizable=no,scrollbars=yes');
}
//-->
// LOAD FLASH
function loadflash(flashfile, width, height, finalwidth) {
   var sizeratio = finalwidth / width;
   var finalheight = height * sizeratio;
   return('<embed src="'+flashfile+'" quality=high WIDTH="'+(finalwidth)+'" HEIGHT="'+finalheight+'" ALIGN="left" TYPE="application/x-shockwave-flash" PLUGINSPAGE="https://www.macromedia.com/go/getflashplayer">');	
}
//-->
// ADD IMAGES FROM ARCHIVE TO TEXT BOX AND IMAGE ELEMENTS
function getImage(w,x,y,z,a)
{
   //alert(w+'-'+x+'-'+y+'-'+z+'-'+a);
   document.getElementById(y).style.backgroundImage="url(../../user_images/tmb_"+x+")";
   if (w) {
      document.getElementById(w).value=z;
   } else {
	  document.getElementById(y+'_text').value=z;  
   }
   /*if (x != '') {
	  if (!a) { a = "tmb"; }
	  // Check to see if X has more than one value
      var x_split = x.split(",");
      if (x_split.length > 1) {
         var part_num=0;
         while (part_num < x_split.length) {
			document.getElementById(x_split[part_num]).style.backgroundImage="url(../../user_images/"+a+"_"+w+")";
            part_num+=1;
         }
      } else {
	     document.getElementById(x).style.backgroundImage="url(../../user_images/"+a+"_"+w+")";
	  }
	  if (z) {
         document.getElementById(z).value=y;
	  } else {
         document.getElementById(x+"_text").value=y;
	  }
   }  else {
      var oRTE;
      if (document.all) {
         oRTE = frames['rte1'];
         //get current selected range
         var selection = oRTE.document.selection; 
         if (selection != null) {
            rng = selection.createRange();
         }
      } else {
         oRTE = document.getElementById(rte).contentWindow;
         //get currently selected range
         var selection = oRTE.getSelection();
         rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
      }
      //imagePath = prompt('Enter Image URL:', 'http://');				
      oRTE.focus();
      oRTE.document.execCommand('InsertImage', false, '../../user_images/med_'+x);
      oRTE.focus();
   }*/
}
function deleteImage(y,z)
{
   if (y) {
      var y_split = y.split(",");
      if (y_split.length > 1) {
         var part_num=0;
         while (part_num < y_split.length) {
            document.getElementById(y_split[part_num]).style.backgroundImage="";
            part_num+=1;
         }
      } else {
         document.getElementById(y).style.backgroundImage="";   
      }
      if (z) {
         document.getElementById(z).value="";
      } else {
         document.getElementById(y+"_text").value=""; 
	  }
   }
}
function getFile(x,y,z)
{
   document.getElementById(y).value=x;
   document.getElementById(y+"_text").value=z;   
}
//-->
// TEXT BOX DATA GRAB
function tfinal(){
   updateRTE('rte1');
   document.getElementById("text").value=document.mainform.rte1.value;
}	
//-->
// SET ACTION VALUE AND SUBMIT PAGE
function submit_page(x,y,z) {
   document.getElementById('action').value=x;
   if (y != '') {
      document.getElementById('action2').value=y;
   }
   if (z != '') {
      document.getElementById('action3').value=z;
   }
   document.mainform.submit();
}
//-->
// GOOJAX FORM SUBMISSION
   var http_request = false;
   function makePOSTRequest(url,parameters,loadspan,loadtype,callback) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

	  http_request.onreadystatechange = function() { alertContents(http_request,loadspan,loadtype,callback); };
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }
   function alertContents(http_request,loadspan,loadtype,callback) {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
			result = http_request.responseText;
			if (loadspan) {
			   document.getElementById(loadspan).innerHTML = result;
			   // CHECK FOR SPECIAL DIALOG INSTRUCTIONS
			   if (document.getElementById('dialog_jscode')) {
			       eval(document.getElementById('dialog_jscode').value);   
			   }
			   if (loadtype == 1) {
				   
				  // CHECK TYPE OPTIONS
				  var strsearch = document.getElementById(loadspan).innerHTML;
				  if (strsearch.search('msgwinsort') != -1) {
					 goojax_msg_open(1);  
				  } else {
			         goojax_msg_open('');
				  }
			   }
			   eval(callback);
			} else {
			   eval(result);
			   if (loadtype == 1) {
			      //setTimeout("goojax_msg_close()",1000);
				  goojax_msg_close();
			   }  	
			}
         } else {
            //alert('Oops!  There was a small hiccup.  Press OK to continue.');
         }
      }
   }
function goojax_saveformdata(formlist,url,save) {      
   var getstr = '';
   var formlist_array=formlist.split(",");
   for (j=0; j<formlist_array.length; j++) {
	   obj=document.getElementById(formlist_array[j]);
      for (i=0; i<obj.length; i++) {
         var theElement = obj.elements[i];
         var element_type = theElement.type;
         var element_name = theElement.name;
         var element_value = theElement.value;
	     var typelist = typelist + element_type + ',';
	     if (element_type == "text" && element_value) {
	        getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	     }
	     if (element_type == "password" && element_value) {
	        getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	     }
	     if (element_type == "textarea" && element_value) {
	        getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	     }
	     if (element_type == "hidden" && element_value) {
	        getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	     }
	     if (element_type == "select-one" && element_value) {
	        getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	     }
	     if (element_type == "select-multiple" && element_value) {
		    var selectlist = '';
		    var opt = document.getElementById(element_name).length;
		    for (j=1;j<opt;j++) {
			   if (document.getElementById(element_name).options[ j ].selected) {
			      selectlist += document.getElementById(element_name).options[ j ].value+",";
			   }
		    }
		    getstr += element_name+"="+selectlist+"&";
	     }
	     if (element_type == "checkbox") {
            if (theElement.checked == true) {
		       getstr += element_name+"="+element_value+"&";
		    } else {
			   getstr += element_name+"=&"; 
		    }
	     }
	     if (element_type == "radio") {
            if (theElement.checked == true) {
		       getstr += element_name+"="+element_value+"&";
		    }
	     }
      }
   }
   //alert(getstr);
   if (save!=1) {
      goojax_msg_save();
	  makePOSTRequest(url,getstr,'','1');
   } else {
	  makePOSTRequest(url,getstr,'',''); 
   }
   
}
function goojax_savedata(obj,url) {      
   var getstr = '';
   for (i=0; i<obj.length; i++) {
      var theElement = obj.elements[i];
      var element_type = theElement.type;
      var element_name = theElement.name;
      var element_value = theElement.value;
	  var typelist = typelist + element_type + ',';
	  if (element_type == "text" && element_value) {
	     getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	  }
	  if (element_type == "password" && element_value) {
	     getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	  }
	  if (element_type == "textarea" && element_value) {
	     getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	  }
	  if (element_type == "hidden" && element_value) {
	     getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	  }
	  if (element_type == "select-one" && element_value) {
	     getstr += element_name+"="+encodeURIComponent(element_value)+"&";
	  }
	  if (element_type == "select-multiple" && element_value) {
		 var selectlist = '';
		 var opt = document.getElementById(element_name).length;
		 for (j=1;j<opt;j++) {
			if (document.getElementById(element_name).options[ j ].selected) {
			   selectlist += document.getElementById(element_name).options[ j ].value+",";
			}
		 }
		 getstr += element_name+"="+selectlist+"&";
	  }
	  if (element_type == "checkbox") {
         if (theElement.checked == true) {
		    getstr += element_name+"="+element_value+"&";
		 } else {
			getstr += element_name+"=&"; 
		 }
	  }
	  if (element_type == "radio") {
         if (theElement.checked == true) {
		    getstr += element_name+"="+element_value+"&";
		 }
	  }
   }
   //alert(getstr);
   goojax_msg_save();
   makePOSTRequest(url,getstr,'','1');
}
// -->
// SUBMIT BUTTON ACTIVATE
function activesubmit(num) {
   for (i=1;i<=num;i++) {
	   if(document.getElementById('submit'+i)) {
      		document.getElementById('submit'+i).style.filter = "alpha(opacity=100)";
	  		//document.getElementById('submit'+num).style.-moz-opacity = "1";
	  		document.getElementById('submit'+i).style.opacity = "1";
	   }
   }
}
// -->
// GOOJAX MESSAGE WINDOW
function goojax_msg_custom(url,data,callback) {
   makePOSTRequest(url,data,'msgbox','1',callback);    
}
function goojax_msg_save() {
   //document.getElementById('msgbox').innerHTML = '<table class="popupframe" width="300" height="100" border="0" cellpadding="0" cellspacing="0"><tr><td><span class="subheaders-white"><center>Saving Changes</center></span></td></tr></table>'; 
   //document.getElementById('msgbox').innerHTML = '<div style="height:100px;width:100px;"><embed src="/gooimages/pleasewait.swf" quality=high WIDTH="100" HEIGHT="100" ALIGN="center" TYPE="application/x-shockwave-flash" PLUGINSPAGE="https://www.macromedia.com/go/getflashplayer" wmode="transparent"></div>'; 
   document.getElementById('msgbox').innerHTML = '<div style="height:100px;width:100px;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100" height="100" id="pleasewait" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/gooimages/pleasewait.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#666666" /><embed src="/gooimages/pleasewait.swf" quality="high" wmode="transparent" bgcolor="#666666" width="100" height="100" name="pleasewait" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/go/getflashplayer" /></object></div>'; 
   goojax_msg_open('');	
}
function goojax_msg_delete(delfunc,delmsg,delsubmsg) {
   if (delmsg) {
      var delmsg = ' '+delmsg;   
   }
   if (delsubmsg) {
	  var delsubmsg = '<br><span class="bodytext-white">'+delsubmsg;   
   }
   document.getElementById('msgbox').innerHTML = '<table width="450" height="200" border="0" cellpadding="0" cellspacing="0"><tr><td valign="middle" bgcolor="#330033" class="popupframe"><div align="center"><p align="center"><span class="subheaders-white">Are you sure you want to delete this'+delmsg+'?</span>'+delsubmsg+'</p><div align="center"><input name="Submit2" type="button" class="popupbutton" value="Nevermind" onClick="goojax_msg_close();"> <input name="Submit3" type="button" class="popupbutton" value="Yes" onClick="'+delfunc+'"></div></div></td></tr></table>'; 
   goojax_msg_open('');	
}
function goojax_msg_general(header,msg) {
   document.getElementById('msgbox').innerHTML = '<table class="bodytext-white" width="450" height="200" border="0" cellpadding="0" cellspacing="0"><tr><td valign="middle" bgcolor="#330033" class="popupframe"><div align="center"><p align="center"><span class="subheaders-white">'+header+'</span><br><br>'+msg+'</p><div align="center"><input name="Submit2" type="button" class="popupbutton" value="Close" onClick="goojax_msg_close();"></div></div></td></tr></table>'; 
   goojax_msg_open('');	
}
function goojax_msg_cd(type,field,span,size) {
   eval(winsize());
   var width = document.getElementById('goocdwin').offsetWidth/2;
   var height = document.getElementById('goocdwin').offsetHeight/2;
   document.getElementById('goocdwin').style.top=document.body.scrollTop+(winheight/2)-height;
   document.getElementById('goocdwin').style.left = winwidth/2-width;
   document.getElementById('goocdwin').style.zIndex = 100001;
   document.getElementById('msgboxshadow').style.top=0;
   document.getElementById('msgboxshadow').style.left =0;
   document.getElementById('msgboxshadow').style.width='100%';
   document.getElementById('msgboxshadow').style.height = scrollheight;
   document.getElementById('msgboxshadow').style.zIndex = 100000;
   window.frames.goocdframe.goocd_winuse_setvars(type,field,span,size);
}
function goojax_msg_cd_close() {
   document.getElementById('goocdwin').style.top=-10000;
   document.getElementById('goocdwin').style.left = -10000;
   document.getElementById('goocdwin').style.zIndex = 802;
   document.getElementById('msgboxshadow').style.top=-10000;
   document.getElementById('msgboxshadow').style.left = -10000;	
   document.getElementById('msgboxshadow').style.zIndex = 799;
}
function goojax_msg_colorpicker(color,colorvar,buttid) {
   eval(winsize());
   var width = document.getElementById('colorpickerbox').offsetWidth/2;
   var height = document.getElementById('colorpickerbox').offsetHeight/2;
   document.getElementById('colorpickerbox').style.top=document.body.scrollTop+(winheight/2)-height;
   document.getElementById('colorpickerbox').style.left = winwidth/2-width;
   document.getElementById('msgboxshadow').style.top=0;
   document.getElementById('msgboxshadow').style.left =0;
   document.getElementById('msgboxshadow').style.width='100%';
   document.getElementById('msgboxshadow').style.height = scrollheight;
   window.frames.colpickbox.goosetcolor('#'+color,colorvar,buttid);
}
function goojax_msg_colorpicker_save(color,colorvar,buttid) {
	//alert(color+" "+colorvar+" "+buttid);
	document.getElementById(colorvar).value = color;
	document.getElementById(buttid).style.background = '#'+color;
	goojax_msg_colorpicker_close();
}
function goojax_msg_colorpicker_close() {
   document.getElementById('colorpickerbox').style.top=-10000;
   document.getElementById('colorpickerbox').style.left = -10000;
   document.getElementById('msgboxshadow').style.top=-10000;
   document.getElementById('msgboxshadow').style.left = -10000;	
}
function goojax_msg_open(type) {
   // SET TYPES
   if (type == 1) { // LOAD SORT
      dragsort.makeListSortable(document.getElementById('msgwinsort'),verticalOnly, saveOrder);
   }
   eval(winsize());
   var width = document.getElementById('msgbox').offsetWidth/2;
   var height = document.getElementById('msgbox').offsetHeight/2;
   document.getElementById('msgbox').style.top=document.body.scrollTop+(winheight/2)-height+'px';
   document.getElementById('msgbox').style.left = winwidth/2-width+'px';
   document.getElementById('msgboxshadow').style.top=0+'px';
   document.getElementById('msgboxshadow').style.left =0+'px';
   document.getElementById('msgboxshadow').style.width='100%';
   document.getElementById('msgboxshadow').style.height = scrollheight+'px'; 
}
function goojax_msg_adjust() {
   eval(winsize());
   var width = document.getElementById('msgbox').offsetWidth/2;
   var height = document.getElementById('msgbox').offsetHeight/2;
   document.getElementById('msgbox').style.top=document.body.scrollTop+(winheight/2)-height+'px';
   document.getElementById('msgbox').style.left = winwidth/2-width+'px';  	
}
function goojax_msg_close() {
   if (document.getElementById('openafter')) { 
      eval(document.getElementById('openafter').value);
	  document.getElementById('openafter').value = '';
   }
   document.getElementById('msgbox').style.top=-10000+'px';
   document.getElementById('msgbox').style.left = -10000+'px';
   document.getElementById('msgboxshadow').style.top=-10000+'px';
   document.getElementById('msgboxshadow').style.left = -10000+'px';	
   document.getElementById('msgbox').innerHTML = '';
}
function goojax_msgbox_close() {
   document.getElementById('msgbox').style.top=-10000+'px';
   document.getElementById('msgbox').style.left = -10000+'px';
}
function goojax_load_data(url,data,loadspan) {
   makePOSTRequest(url,data,'','2');    
}
// -->
// IMAGE LARGE VIEW WITH MULTIPLE
function gooimagebox_open(imglist,desclist,boxstyle) {
   if (boxstyle == 1) { // SYSTEM BOX
      boxstyle = "popupframe";
   }
   goojax_msg_save();
   imgPreloader = new Image();
   imgPreloader.onload=function(){
	  imgPreloader.onload=function(){};
	  goojax_msgbox_close();
      document.getElementById('msgbox').innerHTML = '<div class="'+boxstyle+'"><table border="0" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><img id="img1" src="/user_images/'+imglist+'"/></td></tr><tr><td style="padding-top:5px;padding-bottom:5px" class="bodytext-white">'+unescape(desclist)+'</td><td nowrap style="padding-left:10px;" align="right" class="bodytext-white"><a href="javascript:goojax_msg_close()">Close</a></td></tr></table></div>';
      goojax_msg_open('');  
   }
   imgPreloader.src = '/user_images/'+imglist;
   //document.getElementById('msgbox').innerHTML = '<div style="width:100px;height:100px;"><center><img src="/gooimages/loading.gif"/></center></div>';
   //goojax_msg_open();
   //document.getElementById('msgboxshadow').style.filter = 'alpha(opacity=100)';
   //document.write('<div id="foobox" style="height:25px;width:25px;background:#000000;;z-index:802;position:absolute;left:100px;top:100px;"><span id="imgspots"><img id="img1" src="/userimages/'+imglist+'" width="'+imgx+'" height="'+imgy+'"/></span></div>');
}
// -->
// WINDOW WIDTH AND HEIGHT - eval() on return value
function winsize() {
   var myWidth = 0, myHeight = 0;
   if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
       myWidth = window.innerWidth;
       myHeight = window.innerHeight;
	   if (myHeight > document.body.scrollHeight) {
	      scrollHeight = myHeight;
	   } else {
		  scrollHeight = document.body.scrollHeight;   
	   } 
   } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
       //IE 6+ in 'standards compliant mode'
       myWidth = document.documentElement.clientWidth;
       myHeight = document.documentElement.clientHeight;
	   if (myHeight > document.documentElement.scrollHeight) {
	      scrollHeight = myHeight;
	   } else {
		  scrollHeight = document.documentElement.scrollHeight;   
	   }
   } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
       //IE 4 compatible
       myWidth = document.body.clientWidth;
       myHeight = document.body.clientHeight;
	   if (myHeight > document.body.scrollHeight) {
	      scrollHeight = myHeight;
	   } else {
		  scrollHeight = document.body.scrollHeight;   
	   }
   }
   
   return("var winwidth = "+myWidth+";var winheight = "+myHeight+";var scrollheight = "+scrollHeight+";");
}
// -->
// GET IMAGE SIZE
function getImgSize(imgSrc,side) {
   var newImg = new Image();
   newImg.src = imgSrc;
   var height = newImg.height;
   var width = newImg.width;
   if (side == 'x') {
      return(width);
   } 
   if (side == 'y') {
      return(height);
   }
}

// -->
// CHECK IF VALID EMAIL
function checkemail(field) {
	var x = document.getElementById(field).value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return('1');
	else return('2');
}
// -->
// CHECK IF VAR IS A NUMBER
function isnumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
      }
   }
   if (!sText) {
      IsNumber = false;   
   }
   return IsNumber;   
}
// -->
// CHECK IF VAR IS AN INTEGER
function isinteger(sText) {
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
      }
   }
   if (!sText) {
      IsNumber = false;   
   }
   return IsNumber;   
}
// -->
// GET TEXT BOX CONTENT AND DUMP INTO FIELD
function gootext_get(boxnum,fieldname) {
   var oEditor = FCKeditorAPI.GetInstance('gooeditor'+boxnum);
   // FORMAT DATA
   var text;
   text = oEditor.GetXHTML();
   var re = new RegExp('<div><style[^<]+</style></div>', 'gi');
   RegExp.multiline = true;
   text = text.replace(re, '');
   var re = new RegExp('<style[^<]+</style>', 'gi');
   RegExp.multiline = true;
   text = text.replace(re, '');
   text = goocleanword(text);
   //text = escape(text);
   document.getElementById(fieldname).value=text;
}
// -->
// GET TEXT BOX CONTENT AND DUMP INTO FIELD
function gootext_set(boxnum,fieldname) {
   var oEditor = FCKeditorAPI.GetInstance('gooeditor'+boxnum);
   // FORMAT DATA
   var text;
   text = oEditor.GetXHTML();
   var re = new RegExp('<div><style[^<]+</style></div>', 'gi');
   RegExp.multiline = true;
   text = text.replace(re, '');
   var re = new RegExp('<style[^<]+</style>', 'gi');
   RegExp.multiline = true;
   text = text.replace(re, '');
   text = goocleanword(text);
   document.getElementById(fieldname).value=text;
   oEditor.SetHTML(text);
   //oEditor.EditorDocument.body.style.cssText += 'color: #322805; background-color: #F7C928;' ;
   //oEditor.InsertHtml('yay!');

}
// -->
// SETUP TEXT EDITOR
function gootexteditor(toolbar,texteditor) {
	var height='';
	var randomnumber=Math.floor(Math.random()*99999);
	var csspath='/css/te/'+randomnumber+'/main.css';
	if (eval('CKEDITOR.instances.'+texteditor)) {
	   CKEDITOR.remove(eval('CKEDITOR.instances.'+texteditor));
	}
	var toolbar_name;
	if (!texteditor) {
		alert('Text Editor Error');
		return;	
	}
	if (toolbar==1) { 
		toolbar_name='Goozmo'; 
		height="300";
	} else if (toolbar==2) {
		toolbar_name='GoozmoBasic';
		height="200";
	} else {
		toolbar_name='GoozmoBasic';
		height="200";
	}
	CKEDITOR.replace(texteditor,
	{
		toolbar_GoozmoBasic : [ [ 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike','-','Link','Unlink','Image','Flash','-','FontSize','Paste','PasteFromWord', 'not existing' ] ],
		toolbar_Goozmo : [['Source','-','Templates'],
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
	['Link','Unlink','Anchor','Maximize'],
    '/',
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
    '/',
    ['Styles','Format','Font','FontSize'],
    ['TextColor','BGColor'],
    ['Maximize', 'ShowBlocks'] ],
		toolbar : toolbar_name,
		dialog_backgroundCoverColor : '000000',
		colorButton_enableMore : true,
		resize_enabled : false,
		contentsCss : csspath,
		skin : 'goozmo',
		height : height,
		filebrowserBrowseUrl : '/goodirector/contentdirector/contentdirector_texteditor.php',
		filebrowserWindowWidth : '5%',
        filebrowserWindowHeight : '5%'
	});
}
// GET TEXT EDITOR DATA
function gootexteditor_get(field,texteditor) {
	document.getElementById(field).value=eval('CKEDITOR.instances.'+texteditor+'.getData();');
}
// CLEAN WORD CODE
function goocleanword(html)
{
	
	html = html.replace(/<\/br>/gi, '' ) ;
	//var html = oNode.innerHTML ;

	/*html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;
	html = html.replace(/<o:p>.*?<\/o:p>/g, '&nbsp;') ;
	
	// Remove mso-xxx styles.
	html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ;

	// Remove margin styles.
	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, '' ) ;
	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
	html = html.replace( /\s*MARGIN: 0in 0in 0pt\s*;/gi, '' ) ;
	html = html.replace( /\s*MARGIN: 0in 0in 0pt\s*"/gi, "\"" ) ;

	html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' ) ;
	html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;

	//html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ;
	html = html.replace( /\s*tab-stops:[^"]/gi, '' ) ; // ADD * BEFORE /gi

	// Remove empty styles.
	html =  html.replace( /\s*style="\s*"/gi, '' ) ;
	
	html = html.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
	
	html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
	
	// Remove Lang attributes
	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	
	html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
	
	html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;

	// Remove XML elements and declarations
	html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;
	
	// Remove Tags with XML namespace declarations: <o:p><\/o:p>
	html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;
	
	// Remove comments [SF BUG-1481861].
	html = html.replace(/<\!--.*-->/g, '' ) ;

	html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;

	html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;

		// The original <Hn> tag send from Word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">
		html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' ) ;

		// Word likes to insert extra <font> tags, when using MSIE. (Wierd).
		html = html.replace( /<(H\d)><FONT[^>]*>(.*?)<\/FONT><\/\1>/gi, '<$1>$2</$1>' );
		html = html.replace( /<(H\d)><EM>(.*?)<\/EM><\/\1>/gi, '<$1>$2</$1>' );

		html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;
		html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;
		html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;
		html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;
		html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;
		html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;

		html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ;

		// Transform <P> to <DIV>
		var re = new RegExp( '(<P)([^>]*>.*?)(<\/P>)', 'gi' ) ;	// Different because of a IE 5.0 error
		html = html.replace( re, '<div$2<\/div>' ) ;*/

	return html ;
}
// -->
// GET RADIO BUTTON VALUE
function gooradiobutton(radioObj,form) {
	var radioObj = document.forms[form].elements[radioObj];
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
// -->
// GET USPS DATA
function goouspsapi(zip,pounds,ounces,length,height,width,shiptype) {
   goojax_load_data('/googlobal/api/usps_api.php','shipdata='+zip+','+pounds+','+ounces+','+length+','+height+','+width+','+shiptype);	
}
// -->
// GET SELECTION BOX DATA
function googetselectionbox(opt,varset) {
   var sel = getSelected(opt);
   var strSel = "";
   for (var item in sel)       
      strSel += sel[item].value + ",";
   document.getElementById(varset).value = strSel;
}
// -->
// DROP DOWN MENU SYSTEM
/*var menuwidth='165px' //default menu width
var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
   document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
   function getposOffset(what, offsettype){
      var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
      var parentEl=what.offsetParent;
      while (parentEl!=null){
         totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
         parentEl=parentEl.offsetParent;
      }
      return totaloffset;
   }
   function showhide(obj, e, visible, hidden, menuwidth){
      if (ie4||ns6)
         dropmenuobj.style.left=dropmenuobj.style.top="-500px"
         if (menuwidth!=""){
            dropmenuobj.widthobj=dropmenuobj.style
            dropmenuobj.widthobj.width=menuwidth
         }
         if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
            obj.visibility=visible
         else if (e.type=="click")
            obj.visibility=hidden
         }
   function iecompattest(){
      return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
   }
   function clearbrowseredge(obj, whichedge){
      var edgeoffset=0
      if (whichedge=="rightedge"){
         var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
         dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
         if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
            edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
         }
      else{
         var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
         var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
         dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
         if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
            edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
         if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
            edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
         }
      }
      return edgeoffset
   }
   function populatemenu(what){
      if (ie4||ns6)
      dropmenuobj.innerHTML=what.join("")
   }
   function dropdownmenu(obj, e, menucontents, menuwidth){
      if (window.event) event.cancelBubble=true
      else if (e.stopPropagation) e.stopPropagation()
      clearhidemenu()
      dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
      populatemenu(menucontents)
   if (ie4||ns6){
      showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
      dropmenuobj.x=getposOffset(obj, "left")
      dropmenuobj.y=getposOffset(obj, "top")
      dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
      dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
   }
   return clickreturnvalue()
}
function clickreturnvalue(){
   if (ie4||ns6) return false
   else return true
}
function contains_ns6(a, b) {
   while (b.parentNode)
   if ((b = b.parentNode) == a)
      return true;
      return false;
}
function dynamichide(e){
   if (ie4&&!dropmenuobj.contains(e.toElement))
   delayhidemenu()
   else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
   delayhidemenu()
}
function hidemenu(e){
   if (typeof dropmenuobj!="undefined"){
   if (ie4||ns6)
   dropmenuobj.style.visibility="hidden"
}
}
function delayhidemenu(){
   if (ie4||ns6)
   delayhide=setTimeout("hidemenu()",disappeardelay)
}
function clearhidemenu(){
   if (typeof delayhide!="undefined")
   clearTimeout(delayhide)
}
if (hidemenu_onclick=="yes")
document.onclick=hidemenu*/
// -->

// CLOSE OUT SYSTEM COOKIES
function gooCloseSysCookies() {
   var cookienames = "goocd_pagenum,goocd_filterct1,goocd_filterct3,goocd_filterct4,goocd_filterct5,goocd_folderid,goocd_searchtype,goocd_searchvalue,goocd_sort";
   var cookienames_sp = cookienames.split(",");
   for (i=0;i<=cookienames_sp.length;i++) {
      gooCreateCookie(cookienames_sp[i],"",-1);	
   }
}

// COOKIE FUNCTIONS
function gooCreateCookie(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 gooReadCookie(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 gooEraseCookie(name) {
	gooCreateCookie(name,"",-1);
}
// DRAG DROP SYSTEM
function goo_getdraglist(table,row,field) {
	var rows = table.tBodies[0].rows;
	var idlist='';
	for (var i=0; i<rows.length; i++) {
		rowsp=rows[i].id.split("_");
		if (rowsp[1]) idlist += rowsp[1]+"|"; else idlist += rowsp[0]+"|";
	}
	document.getElementById(field).value=idlist;
}

function goostopRKey(evt) { 
  var evt = (evt) ? evt : ((event) ? event : null); 
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
  if ((evt.keyCode == 13) && (node.type=="text"||node.type=="password"))  {return false;} 
} 

//document.onkeypress = goostopRKey;

function goosubmitenter(myfield,e, callback) {
   var keycode;
   if (window.event) keycode = window.event.keyCode;
   else if (e) keycode = e.which;
   else return true;
	
   if (keycode == 13) {
      callback();
	  return false;
   } else
	   return true;
}
