function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; } 
}
function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}


// generic.js

// LINK ICONS
// http://particletree.com/features/preview-your-links
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//

function initLinkPreview(){
	var links = document.getElementsByTagName("a");

	for (i=0; i<links.length; i++){
	var currentLink = links[i];
		
		var	images = currentLink.getElementsByTagName("img");
		
	 	// Check if the link is an image. We don't want icons next to images.
		if (images.length == 0){
			var linkHref = currentLink.href;
			checkLinks(linkHref, currentLink)
		}
	}
}

function checkLinks(linkHref, currentLink){
	var linkHrefParts = linkHref.split(".");
	
	// extension is the last element in the LinkSplit array
	var extension = linkHrefParts[linkHrefParts.length - 1];
	
	// In some browsers there is a "/" placed after the link. removes the "/"
	extension = extension.replace("/","");
	
	if( extension in { doc:1, pdf:1, ppt:1, txt:1, xls:1, zip:1 } ){
		append(currentLink, extension );
	}
}

function append(currentLink, extension){
	currentLink.className = extension;
}





// UNOBTRUSIVE POPUPS
// http://www.multiblah.com
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//

// declare variables
var aLinks;
var i;
var url;

function initPopups() {
	if (!document.getElementById) return
	aLinks = document.getElementsByTagName('a');
	for (i = 0; i < aLinks.length; i++) {
		// use multiple classes here for windows with different properties
		if (aLinks[i].className == 'popup') {
			aLinks[i].onclick = function() {
				url = this.href;
				// call different functions here for windows with different properties
				openPopup(url);
				return false;
			}	
		}
	}
}

// popupWindow functions
function openPopup(url) {
	window.open(url, 'popupwindow', 'width=375,height=350,scrollbars=no,status');
	return false;
}





// ONLOAD
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//

window.onload = function() {
	initLinkPreview();
	initPopups();
}