// JavaScript Document

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];}
}

var actElement = "a1";
function setClass(id){
	if(actElement!=""){
		document.getElementById(actElement).className = "collection";
	}
	document.getElementById(id).className = "collectionAct";
	actElement = id;
}


var actid='';
function activate(id){
	if(actid!=''){
		document.getElementById(actid).className='alink1l';
	}
	document.getElementById(id).className='alink2';
	actid=id;
}

function out(id){
	if(id!=actid){
		document.getElementById(id).className='alink1';
	}
}

function over(id){
	document.getElementById(id).className='alink2';
}

var actImgId = 'StAndrews';
function navimgover(id,text){
		switch(id){
			case 'StAndrews':filename = 'ST1.06.001_small.jpg';break;
			case 'TimeToPlay':filename = 'T1.06.001_small.jpg';break;
			case 'EagleHeart':filename = 'EH1.06.001_small.jpg';break;
			case 'BlackIron':filename = 'B3.06.001_small.jpg';break;
			case 'OrderOfMerit':filename = 'O2.06.001_small.jpg';break;
			case 'SeveBallesteros':filename = 'watch_seve_ballesteros.jpg';break;
			case 'rocourse':filename = 'royal_open_coruse.jpg';break;
			case 'habana':filename = 'royal_opem_habana.jpg';break;
			case 'royalopen':filename = 'royal_open.jpg';break;
			case 'roladies':filename = 'royal_open_ladies.jpg';break;
			case 'StAndrews2':filename = 'st_andrews2.jpg';break;
			case 'SeveBallesteros2':filename = 'seve2anim.jpg';break;
			default:filename='ST1.06.001.jpg';break;
		}
		if(id != 'StAndrews'){ 
			document.getElementById('imgspace').style.left = '1px';
		}
		else{
			document.getElementById('imgspace').style.left = '0px';
		}
		
		document.getElementById(id).src = document.getElementById(id).src.replace('_off','_on');
		document.getElementById('clockImg').src = '../images/uhren/'+filename;
		if(actImgId != id) navimgout(actImgId);
	
	document.getElementById('imglegend').innerHTML = text;
	actImgId = id;
}
function navimgout(id){	
	document.getElementById(id).src = document.getElementById(id).src.replace('_on','_off');
}


// Auto Switch, uses navimgover();
// Auto Switch Vars
var switchArray = Array("StAndrews","TimeToPlay","EagleHeart","BlackIron","OrderOfMerit");
var switchArrayText = Array("St Andrews Links","Time To Play","Eagle Heart","Black Iron","Order Of Merit");

var switchAct = 1;
var switchTime = 5; // Sek
var playInterval;

// Auto Switch Funcs
function initSwitchImage(){
	//playInterval = window.setInterval(function(){switchImage();},switchTime*1000);
}
function switchImage(){
	if(switchAct > switchArray.length-1){
		switchAct = 0;	
	}
	navimgover(switchArray[switchAct],switchArrayText[switchAct]);
	switchAct++;
}
function stopSwitchImage(number){
	playInterval = window.clearInterval(playInterval);
	switchAct = number;
}
function startSwitchImage(){
	if(playInterval == undefined){
		initSwitchImage();	
	}
}


// Popup function

function popup (id,ort,Fname) {
	//Fname =(arguments.length>2)? Fname: "Popup";
	//Fname =(Fname!="undefined")? Fname: "Popup";
	if(ort != "link"){
		url = "popup/"+ort+"/"+id+".html"
		fenster = window.open(url, Fname, "width=600,height=400,resizable=no,scrollbars=yes");
	}else{
		var screenWidth = screen.width;
		var screenHeight = screen.height;
		
		fenster = window.open(id, "Link", "width="+screenWidth+",height="+screenHeight+",toolbar=yes,location=yes,menubar=yes,scrollbars=yes,resizable=yes");
	}
	fenster.focus();
}
//-->