//------------------------------------------------------------------------
// common javascript functions for the warriors php application
//------------------------------------------------------------------------

 var agt=navigator.userAgent.toLowerCase();
 var is_safari = agt.indexOf("safari")!=-1;

//------------------------------------------------------------------------

function ShowFlash(file,width,height)
{
 document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">');
 document.write('<param name="movie" value="' + file + '">');
 document.write('<param name="quality" value="high">');
 document.write('<embed src="' + file + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>');
 document.write('</object>');
}

//------------------------------------------------------------------------

function ReadCookie(name)
{
 var cookievalue = "";
 var search = name + "=";
  if(document.cookie.length > 0)
   { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
     { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookievalue = unescape(document.cookie.substring(offset, end))
     }
   }
  return cookievalue;
}

//------------------------------------------------------------------------

function WriteCookie(name, value, minutes)
{
 var expire = "";
 expire = new Date((new Date()).getTime() + minutes * 60000);
 expire = "; expires=" + expire.toGMTString();
 document.cookie = name + "=" + escape(value) + expire;
}

 function startdiv(idval,w){
  var s = document.write ('<div id="'+idval+'"><table width="'+w+'" border="0" cellpadding="0" cellspacing="0" class="mt">');
 }
 function enddiv(){
  var s = document.write ("</table></div>");
 }
 function bi(link,div,name){
  var s = document.write ("<tr><td onClick=\"lnk('"+link+"');\" onMouseOver=\"menuovr('"+div+"','"+pn(name)+"',this);\" onMouseOut=\"menuout('"+div+"',this);\" class=\"nav2\">"+name+"</td></tr>");
 }
 function pn(name){
  var s=name;if(s.indexOf("<")>0) {return(s.slice(0,s.indexOf("<")-1));}return(s);
 }
 function lnk(link){
  internal_clicked = true;
  window.open(link,'_self');
 }
 function mainovr(div,status){
  if(is_safari){
   bHover=status;window.status=status;setDD(div,status,false);}
  else{
   bHover=status;window.status=status;setTimeout('setDD(\'' + div + '\', \'' + status + '\', false)',300);}
 }
 function mainout(div){
  bHover='';window.status='';setDDTimeout(div);
 }
 function menuovr(div, link, item){
  window.status=link;item.style.backgroundColor='#339900';setDD(div,'',true);
 }
 function imgovr(div){
 }
 function menuout(div, item){
  setDDTimeout(div);item.style.backgroundColor='#03512c';
 }
 function smenuovr(div, link, item){
  window.status=link;item.style.backgroundColor='#03512c';setDD(div,'',true);
 }
 function smenuout(div, item){
  setDDTimeout(div);item.style.backgroundColor='#03512c';
 }
 function findDiv(n, d) { 
  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=findDiv(n,d.layers[i].document);
   if(!x && document.getElementById) x=document.getElementById(n); return x;
 }
 function tNav() {  
  var i,p,v,obj,args=tNav.arguments;
   for (i=0; i<(args.length-2); i+=3) if ((obj=findDiv(args[i]))!=null) { v=args[i+2];
     if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
     obj.visibility=v; }    
 }
 function hideDDs(sect) {
  tNav('index_submenu','','hide');
  tNav('team_submenu','','hide');
  tNav('history_submenu','','hide');
  tNav('schedules_submenu','','hide');
  tNav('paddle_submenu','','hide');
  tNav('gallery_submenu','','hide');
  tNav('links_submenu','','hide');
  tNav('members_submenu','','hide');
  tNav('contact_submenu','','hide');
  showElement('SELECT');
  showElement('OBJECT');
  showElement('EMBED');
 }
 function hideDD(sect) {
  tNav(sect,'','hide');hideDDs(sect);
 }
 var secSet = null;
 var activeTimer = null;
 var bHover = '';
 var img = '';
 function setDD(sect, windowStatusVal, bshow) {
  hideDDs(sect);
  if ((bHover==windowStatusVal)||(bshow)){
   tNav(sect,'','show');
   if (secSet != null) window.clearTimeout(secSet);  
   hideElement('SELECT', document.all[sect]); 
   hideElement('OBJECT', document.all[sect]); 
   hideElement('EMBED', document.all[sect]); 
  }
 }
 function setDDTimeout(sect){
  if (secSet != null) window.clearTimeout(secSet);
  secSet = window.setTimeout('hideDD("' + sect + '")',200);
 }
 function hideElement( elmID, overDiv ) {
   if(document.all) {
     for(i = 0; i < document.all.tags( elmID ).length; i++) {
       obj = document.all.tags( elmID )[i];
       if(!obj || !obj.offsetParent) continue;
       objLeft   = obj.offsetLeft - overDiv.offsetParent.offsetLeft;
       objTop    = obj.offsetTop;
       objParent = obj.offsetParent;
       while(objParent.tagName.toUpperCase() != 'BODY') {
         objLeft  += objParent.offsetLeft;
         objTop   += objParent.offsetTop;
         objParent = objParent.offsetParent;}
       objHeight = obj.offsetHeight;
       objWidth  = obj.offsetWidth;
       if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
       else if((overDiv.offsetParent.offsetTop + overDiv.offsetHeight + 20) <= objTop);
       else if(overDiv.offsetParent.offsetTop >= eval(objTop + objHeight));
       else if(overDiv.offsetLeft >= eval(objLeft + objWidth));
       else {
         obj.style.visibility = 'hidden';
       }
     }
   }
 }
 function showElement(elmID) {
   if(document.all) {
     for(i = 0; i < document.all.tags( elmID ).length; i++) {
       obj = document.all.tags(elmID)[i];
       if(!obj || !obj.offsetParent) continue;
       obj.style.visibility = '';
     }
   }
 }
