// globals
var wait;

// a rel="external"
function externalLinks() {
	if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName('a');
		for (var i=0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'external') anchor.target = '_blank';
	}
}
// Captcher subscribers form
function subscribers(){
	$('#subscribers').submit(function(e){
		if(!$('#first_name').val() || !$('#last_name').val() || !$('#email').val()){
			alert('Please complete all required fields before continuing');
			e.preventDefault(); // Stop the form going anywhere
		}
	});
}
// Generic functionality
function generic(){
	// Pin the corner to the header
	//var tl = $.DIV();
	//$(tl).css({position: 'absolute',left:0,top:0,width:'5px',height:'5px',background: 'url(/images/interface/corner.gif) no-repeat'});
	//$('#header').append(tl);
}

// Multiple onload functionality
$(document).ready(function(){
	externalLinks();
	subscribers();
	generic();
});

function swapimg(slot,pic) {
	large = document.getElementById('slot');
	large.src = 'render/'+pic;
	}
	
function showhide(thediv) {
	if (document.getElementById(thediv).style.display=='block') {
		document.getElementById(thediv).style.display='none';
		}
	else {
		document.getElementById(thediv).style.display='block';
		document.getElementById(thediv).focus();
		}
	}
	
function openWindow(theURL,winName,winWidth,winHeight,otherFeatures) {
	var x = 0;
	var y = 0;
	x = (screen.availWidth - 12 - winWidth) / 2;
	y = (screen.availHeight - 48 - winHeight) / 2;
	if (otherFeatures != "") {otherFeatures = "," + otherFeatures}
	var features = "screenX=" + x + ",screenY=" + y + ",width=" + winWidth + ",height=" + winHeight+",top="+y+",left="+x+"'" + otherFeatures
	var NewWindow = window.open(theURL,winName,features);
	NewWindow.focus();
	}
	
function closedivs(except){
	$('div').each(function(){
		if(this.id && this.id.match(/pd_/)) {
			this.style.display = (this.id==except) ? 'block' : 'none';
			}
		});
	} 	