/*
	Opens a new browser window with dimensions based on "type."  Custom dimensions may be used if "type" is an object containing width and height parameters.
	
	Parameters:
	Name	Type			Default		Description
	url		string						The URL location
	type	string/object				A string containing the class name, or an object containing specific width and height
	name	string						The name to assign to the window
	
	Returns:
	Type	Description
	void
*/
function openWindow(url, type, name) {
	if(!name) {
		name = "";
	}
	
	if(type && type.width && type.height) {
		window.open(url, name, "width=" + type.width + ", height=" + type.height + ", scrollbars, resizable");
	} else if(type) {
		var width = 800;
		var height = 600;
		switch(type) {
			case "small":
				width = 320;
				height = 240;
				break;
			case "medium":
				width = 640;
				height = 480;
				break;
			case "large":
				width = 800;
				height = 600;
				break;
		}
		if(type == "new") {
			window.open(url, name);
		} else {
			window.open(url, name, "width=" + width + ", height=" + height + ", scrollbars, resizable");
		}
	} else {
		window.open(url, name);
	}
}

//Initialize link behavior based on class names or href.
function initLinks() {
	var links = document.getElementsByTagName("a");
	for(var x = 0; x < links.length; x++) {
		if(links[x].href.indexOf("/video/") != -1) {
			links[x].onclick = function () {
				openWindow(this.href, "video", "large");
				return false;
			};
		}
	}
}

function initSite() {
	initLinks();
}

window.onload = initSite;
