//Startpage video player is size L
size = "L";
player = "video";

function setSize(theWrapper, thesize) { 
	var tmp = document.getElementById(theWrapper);
	if (tmp) { 
		var theWidth = 305;
		var theHeight = 224;
		var unitStr = "px";

		if( thesize=='S' ) {          
			tmp.className="player_video_small";
			theWidth = 305; 
			theHeight = 120; /*113*/
			unitStr = 'px';			
			document.getElementById('links_video').style.margin = "78px 0 0 0";
		}  
		else {
			tmp.className="player_video";
	     	if (player == "video" )
			{				
				document.getElementById('links_video').style.margin = "180px 0 0 0";
			}
		}
	}	
	sizeWrap(theWrapper, theWidth, theHeight, unitStr);
	size = thesize;	                       
 }


function sizeWrap(theWrapper, theWidth, theHeight, unitStr) { 
	var tmp = document.getElementById(theWrapper);
	if (tmp) { 
		if (! unitStr) { var unitStr = 'px'; }
		tmp.style.width = parseInt(theWidth)+unitStr; 
		tmp.style.height = parseInt(theHeight)+unitStr; 
	}
}


function initplayer() {
	//Initiate video player
	var flashvars = {
			file:"flash/playlist_youtube.xml", 
			autostart:"true",
			controlbar:"over", 
			repeat:"true",
			image:"flash/preview.jpg",
			backcolor:"000000",
			frontcolor:"E1E1E1",
			lightcolor:"cf55b3"					
	}
	var params = {                   
			allowfullscreen:"false", 
			allowscriptaccess:"always",
			wmode:"transparent"
	}
	var attributes = {
			id:"player1",  
			name:"player1"
	}
	swfobject.embedSWF(BASE_URL + "flash/videoplayer.swf", "videoholder", "100%", "100%", "7", false, flashvars, params, attributes);
	
	// Initiate audio player
	var flashvars = {
			file:"flash/playlist_music.xml", 
			autostart:"true",
			repeat:"true",
			image:"flash/preview.jpg",
			backcolor:"0x000000",
			frontcolor:"0xE1E1E1",
			lightcolor:"0xcf55b3",
			playlist:"above",
			playlistsize:"92",
			thumbsinplaylist:"false",
			displayheight:"0"
							
	}
	var params = {                   
			allowfullscreen:"false", 
			allowscriptaccess:"always",
			wmode:"transparent"
	}
	var attributes = {
			id:"player2",  
			name:"player2"
	}
	swfobject.embedSWF(BASE_URL + "flash/mp3player.swf", "audioholder", "305", "120", "7", false, flashvars, params, attributes);
	
	
	// Initiate  main flash
	var flashvars = {
							
	}
	var params = {                   
			allowfullscreen:"false", 
			allowscriptaccess:"always",
			wmode:"transparent"
	}
	var attributes = {
			id:"mainflash",  
			name:"mainflash"
	}
	swfobject.embedSWF(BASE_URL + "flash/dondiablo.swf", "flashholder", "980", "825", "7", false, flashvars, params, attributes);
}


function switchplayer(type){
	if(type=='music'){		
		document.getElementById('links_video').style.margin = "75px 0 0 0";
		try{
			player1.sendEvent('MUTE','true');
			} catch(e){}
		try{
			player1.sendEvent('PLAY','false');
			} catch(e){}		 		
		document.getElementById('player_video').style.display = "none";			
		document.getElementById('player_audio').style.display = "block";	
		
		player = "audio";
	}
	else{		
		if(size == "L"){
			document.getElementById('links_video').style.margin = "180px 0 0 0";	
		}
		document.getElementById('player_video').style.display = "block";			
		document.getElementById('player_audio').style.display = "none";			
		try{
			player1.sendEvent('PLAY','true');
			} catch(e){}			
		player = "video";	
	}	
}	


function guestbook() {
	leftPos = (screen.width / 2) - 400;
	topPos = (screen.height / 2) - 200;
	guestbookWindow = window.open("http://dondiablo.write2me.nl", "guestbook", "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,width=660,height=500,left="+leftPos+",top="+topPos);
	guestbookWindow.focus();
}


function popup( url, width, height )
{
	var iLeft = (screen.width - width) / 2 ;
	var iTop  = (screen.height - height) / 2 ;

	var sOptions = "resizable=yes,dependent=yes,scrollbars=yes," ;
	sOptions += ",width=" + width ;
	sOptions += ",height=" + height ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	window.open( url, "FCKBrowseWindow", sOptions ) ;
}


var PositionX = 100;
var PositionY = 100;
var defaultWidth  = 100;
var defaultHeight = 100;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}
var optNN='scrollbars=no, status=yes, width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no, status=yes, width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle,imageTitle2){
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	with (imgWin.document){
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');
		writeln('if (isIE){');
		writeln('window.resizeTo(100,100);');
		writeln('width=10+document.images[0].width;');
		writeln('height=59+document.images[0].height;');
		
		writeln('window.resizeTo(width,height);}');
		writeln('if (isNN){');
		writeln('window.innerWidth=document.images["George"].width;');
		writeln('window.innerHeight=document.images["George"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle2+'";}');
		writeln('</sc'+'ript>');
		if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle(); self.focus()">')
		else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		writeln('<img name="George" src="'+imageURL+'" alt="'+imageTitle+'" onClick="window.close();" style="display: block; cursor: pointer;"></body></html>');
		close();
	}
}

function getRadioValue()
{
 theRadioValue = 0;    
 for (var i=0; i < document.signup_frm.gender.length; i++)
  {
	 if (document.signup_frm.gender[i].checked) 
	 { 
		  theRadioValue = document.signup_frm.gender[i].value;
		  break;
	 }
  }  
  return theRadioValue;
}

function show_unsubscribe()
{
  document.getElementById('mailinglist_content').style.display = 'none';
  document.getElementById('mailinglist_unsubscribe').style.display = 'block';
}

function error_back()
{
  document.getElementById('mailinglist_error').style.display = 'none';
  document.getElementById('mailinglist_content').style.display = 'block';
}

function mailinglistXmlhttpPost(url, query)
{
    var xmlHttpReq = false;
    var self = this;
    
    // Mozilla/Safari
    if (window.XMLHttpRequest)
    {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject)
    {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    self.xmlHttpReq.open('POST', url, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function()
    {
      if(self.xmlHttpReq.readyState == 4)
      {
        var type = self.xmlHttpReq.responseText.split('|');
        
        switch(type[0])
        {
          default:
            alert(type[1]);
            break;
          
          case 'succes=2':
            alert(type[1]);
            document.getElementById('mailinglist_unsubscribe').style.display = 'none';
            document.getElementById('mailinglist_content').style.display = 'block';
            break;
          
          case 'succes=1':
            document.getElementById('mailinglist_content').style.display = 'none';
            document.getElementById('mailinglist_succes').style.display = 'block';
            break;
          
          case 'error=3':
          case 'error=2':
            alert(type[1]);
            break;
          
          case 'error=1':
            document.getElementById('mailinglist_content').style.display = 'none';
            document.getElementById('mailinglist_error').style.display = 'block';
            document.getElementById('error_text').innerHTML = type[1];
            break;
        }
      }
    }
    
    self.xmlHttpReq.send(query);
}