// Open new windows as target="_blank"
function externallinks () {
   if ( document.getElementsByTagName ) {
      var links = document.getElementsByTagName ( 'a' );
      for (var i = 0; i < links.length; i++ ) {
         var link = links[i];
         if ( ( link.getAttribute ( 'href' ) ) && ( link.getAttribute ( 'rel' ) == 'external' ) ) {
            link.target = '_blank';	
			link.onclick = function() {
				if(vidplayer){
					vidplayer.pauseVidPlayer();
				}
			}
         }
		 	 
		//Add gallery popup
		 if( ( link.getAttribute ( 'href' ) ) && link.className == 'photogallerypopup' ){
			link.onclick = function(){
				galleryPopup(this.getAttribute('href'));
				return false;
			}
		 }
		 //Add wallpaper popup
		 if( ( link.getAttribute ( 'href' ) ) && link.className == 'wallpaperpopup' ){
			link.onclick = function(){
				wallpaperPopup(this.getAttribute('href'));
				return false;
		//Pause video when opening new window		
		

			}
		 }
      }
   }
}

/*
Swap image and add onmouseover and onmouseout event
*/

function addMenuEvent(id){
	var menu = document.getElementById(id);
	var li = menu.getElementsByTagName('li');
	for(var i=0; i<li.length; i++){
		if(li[i].className.indexOf('selected') == -1){
			li[i].onmouseover = function(){
				this.className +=  ' over';
			}

			li[i].onmouseout = function(){
				this.className = this.className.replace("over", "");
			}
		}
	}
}

function wallpaperPopup(url){
	window.open(url,'wallpaper','width=800,height=600');
}

function galleryPopup(url){
	window.open(url,'photo_gallery','width=660,height=575');
	return false;
}

function addVideoPlayer(){
	var so = new SWFObject('media/flash/videoplayer.swf', 'flashplayer','397', '272', '8','#000000');
	so.addParam("quality", "high");
	so.addParam("allowScriptAccess", "always");
	so.addParam("wmode", "transparent");
	so.write("flashplayer");
}