/*-------------------------------------------------------------------
 General stuff
-------------------------------------------------------------------*/
//function gid(name) {
//	return document.getElementById(name);
//}




/*-------------------------------------------------------------------
Player javascript API
-------------------------------------------------------------------*/
function StopMovie() { 
    thisMovie('vid2').StopPlay();
};
function StartMovie() { 
    thisMovie('vid2').Play();
};
function getUpdate(typ,pr1,pr2,swf) {
	if(typ == "state" && swf == "jstest") {
		gid('stateshow').innerHTML = pr1;
	}
};
function loadFile(swf,obj) {
	thisMovie(swf).loadFile(obj); 
};
function PlayNewMovie(swf,movie) {
    thisMovie(swf).StopPlay();
	thisMovie(swf).LoadMovie(0, movie);
};
function NewFile(movie) {
    //show/hide hole details
    //   
    //Play movie
    
    thisMovie('vid2').StopPlay();
	thisMovie('vid2').LoadMovie(0, movie);
};
function NextHole() {
    //show/hide hole details
    //   
    //Play movie
    newhole= parseInt(document.form1.currentHole.value) + 1;
    maxhole= parseInt(document.form1.MaxHole.value)
    if (newhole>maxhole)
    {newhole=1;}
    OpenNewHole(newhole);
};
function PreviousHole() {
    //show/hide hole details
    //   
    //Play movie
    newhole= parseInt(document.form1.currentHole.value) -1;
    maxhole= parseInt(document.form1.MaxHole.value)
    if (newhole==0)
    {newhole=maxhole;}
    OpenNewHole(newhole);
};
function OpenNewHole(hole) {
    //show/hide hole details
    //   
    //Play movie
   
    if (hole==99)
        {//document.form1.currentHole.value = 1;
       
         movietoplay=  document.form1.DefaultFile.value; 
         }
    else
    {  
        document.form1.currentHole.value = hole;
        
        movietoplay='images/video/hole'+hole+'.swf';
        
     }   
        for (var x = 1; x <= 18; x++)
           {
           
            if (x==hole)
               {document.getElementById('details_'+x).style.display = 'block';
               }
            else
                {document.getElementById('details_'+x).style.display = 'none';
                
                }
            
           }
        
        thisMovie('vid2').StopPlay();
        
	    thisMovie('vid2').LoadMovie(0, movietoplay);
	    
	
};
function getLength(swf) { 
	var len = thisMovie(swf).getLength(); 
	alert('the length of the playlist is: '+len);
};
function addItem(swf,obj,idx) {
	thisMovie(swf).addItem(obj,idx);
};
function removeItem(swf,idx) {
	thisMovie(swf).removeItem(idx);
};
function itemData(swf,idx) { 
	var obj = thisMovie(swf).itemData(idx);
	var txt = "";
	for(var i in obj) { 
		txt += i+": "+obj[i]+"\n";
	}
	alert(txt);
};
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
		
		
	} else {
	
		return document[movieName];
	}
};
var tracing = true;
function printTrace(str) {
	if(tracing == true) {
		var itm = gid('tracecode');
		var txt = itm.innerHTML + str + '\n';
		itm.innerHTML = txt;
		itm.scrollTop = itm.scrollHeight;
	}
};
function toggleTrace() {
	if (tracing == true) { 
		tracing = false;
	} else { 
		tracing = true;
		var itm = gid('tracecode');
		itm.innerHTML = '';
	}
};
var configobj;
var playlistobj;
function printConfig() {
	tracing = false; 
	var cfg = thisMovie('mpl').getConfig();
	configobj = cfg;
	printData(cfg);
}
function printPlaylist() {
	tracing = false;
	var ply = thisMovie('mpl').getPlaylist();
	playlistobj = ply;
	var txt = "";
	for(var i=0; i<ply.length; i++) {
		txt += i+":\n";
		for(var itm in ply[i]) {
			txt += "-> "+itm+": "+ply[i][itm]+"\n";
		}
	}
	var itm = gid('tracecode');
	itm.innerHTML = txt;
}
function printData(cfg) { 
	var txt = "";
	for(var itm in cfg) {
		txt += itm+": "+cfg[itm]+"\n";
	}
	var itm = gid('tracecode');
	itm.innerHTML = txt;
}

function ChangeTab(selectedTab)
	{   if (selectedTab=='CourseTab')
	        {
	        document.getElementById('CourseInfo').style.display = 'block';
	        document.getElementById('CourseTab').className = 'selected';
	        document.getElementById('HoleInfo').style.display = 'none';
	        document.getElementById('HoleTab').className = '';
	         document.getElementById('HolevidButtons').style.display = 'none';
	        document.getElementById('CourseVidButtons').style.display = 'block';
	        document.getElementById('courseDescrip2').style.display = 'block';
	        OpenNewHole(99);
		    
		    }
	    else if (selectedTab=='HoleTab')
	        {
	        document.getElementById('CourseInfo').style.display = 'none';
	        document.getElementById('CourseTab').className = '';
	        document.getElementById('HoleInfo').style.display = 'block';
	        document.getElementById('HoleTab').className = 'selected';
	         document.getElementById('HolevidButtons').style.display = 'block';
	        document.getElementById('CourseVidButtons').style.display = 'none';
	        document.getElementById('courseDescrip2').style.display = 'none';
	        hole=document.form1.currentHole.value;
	        OpenNewHole(hole);
		    }
	    
	    
	    
	  }
function InitForm()
{
//   if (document.form1.pagetype.value = 'holes')
//    {hole=document.form1.currentHole.value; 
//        OpenNewHole(hole);}
//    else
//    {
//    OpenNewHole(99);}
   
   //use browser sniffing to determine if IE or Opera (ugly, but required)
var isOpera, isIE = false;
if(typeof(window.opera) != 'undefined'){isOpera = true;}
if(!isOpera && navigator.userAgent.indexOf('Internet Explorer')){isIE = true;}

//fix both IE and Opera (adjust when they implement this method properly)
if(isOpera || isIE){
  document.nativeGetElementById = document.getElementById;
  //redefine it!
  document.getElementById = function(id){
    var elem = document.nativeGetElementById(id);
    if(elem){
      //verify it is a valid match!
      if(elem.attributes['id'] && elem.attributes['id'].value == id){
        //valid match!
        return elem;
      } else {
        //not a valid match!
        //the non-standard, document.all array has keys for all name'd, and id'd elements
        //start at one, because we know the first match, is wrong!
        for(var i=1;i<document.all[id].length;i++){
          if(document.all[id][i].attributes['id'] && document.all[id][i].attributes['id'].value == id){
            return document.all[id][i];
          }
        }
      }
    }
    return null;
  };
}
   
   
    
 
    if (document.form1.pagetype.value = 'holes')
    {   
//        document.getElementById('CourseInfo').style.display = 'none';
//	      document.getElementById('CourseTab').className = '';
//	      document.getElementById('HoleInfo').style.display = 'block';
//	      document.getElementById('HoleTab').className = 'selected';
//	      document.getElementById('HolevidButtons').style.display = 'block';
//	      document.getElementById('CourseVidButtons').style.display = 'none';
//	      document.getElementById('header').style.display = 'none';
//	       
//	        OpenNewHole(99);
        
        hole=document.form1.currentHole.value; 
        OpenNewHole(hole);
        
	        }
	 else
	 {document.getElementById('CourseInfo').style.display = 'block';
	        document.getElementById('CourseTab').className = 'selected';
	        document.getElementById('HoleInfo').style.display = 'none';
	        document.getElementById('HoleTab').className = '';
	         document.getElementById('HolevidButtons').style.display = 'none';
	        document.getElementById('CourseVidButtons').style.display = 'block';
	        document.getElementById('header').style.display = 'block';
	        OpenNewHole(99);
		    
		    }
    
    
    }
    
function getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {
            return pair[1];
                }
            }
        }