//<![CDATA[


function isValidEmailAddress(addr) {
    var re;
    re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
    if (re.test(addr) == true)
       return true;
    else
      return false;
}
function playMovie(id){
	if (dragging)return false;
	//alert(file);
	var mov = '<iframe src="http://player.vimeo.com/video/'+id+'?title=1&amp;byline=0&amp;portrait=0&amp;autoplay=1" width="667" height="375" frameborder="0"></iframe>'; 
	mov+='<img src="img/closebox.png" alt="Close" onclick="closePlayer()" />';
	//document.getElementById('player').innerHTML=mov;
	$('#player').html(mov);
	$('#player').fadeIn();
	return false;
}
function closePlayer(){
	$('#player').html('');
	$('#player').fadeOut();
}

function aMod_popup(){
	 var as,i,islink;
    // grab all links, loop over them;
    as=document.getElementsByTagName('a');
    for(i=0;i<as.length;i++){
        // check which link has a coord attribute, and send this one to popup
        var re = /\d[x]\d/;
        var coord = as[i].getAttribute('coords');         
        if(coord!='' && re.test(coord) == true){
            as[i].setAttribute('coords','');
            var split = coord.split('x');
            var w = split[0];
            var h = split[1];
            var link = as[i].getAttribute('href'); 
            as[i].setAttribute('onclick',"return openWin('"+link+"',"+w+","+h+")"); 
        }
    }
}

function aMod_externalLink(){    
    var as,i,islink;
    // grab all links, and loop over them
    as=document.getElementsByTagName('a');
    for(i=0;i<as.length;i++){
        // take the link's href
        islink=as[i].href; 
        // and check if it contains the current location 
        var host = new String(window.location.hostname);
        rExp = /www./gi;
        domain = host.replace(rExp, "");

        if(islink.indexOf(domain)==-1 && islink.indexOf('javascript:')==-1){
            if(!as[i].getAttribute('title'))as[i].setAttribute('title',islink);
            as[i].setAttribute("target","_blank"); 
        } 
    }
}
///////// SCRIPTS ///////

$(document).ready(function() {
	if($('#still').length){
		$("#slideshow").royalSlider({
			captionShowEffects:["moveleft", "fade"],
			directionNavAutoHide: true,
			imageScaleMode:"none",
			imageAlignCenter:true,
			keyboardNavEnabled:true,
			slideshowEnabled: true,
			slideshowAutoStart:true,
			slideshowDelay:2300	
		});
	}else if( $('#films').length){
		dragging=false;
		$("#slideshow").royalSlider({
			captionShowEffects:["moveleft", "fade"],
			directionNavAutoHide: true,
			imageScaleMode:"none",
			keyboardNavEnabled:true,
			beforeSlideChange: function(){dragging=true;},
			afterSlideChange: function(){dragging=false;}
		});
	}  
});
//]]>

