	var GB_ANIMATION = true;
$(document).ready( function() {
   

		$("a.greybox,a.graybox").click(function(){
			var t = $(this).attr('title'); //Gets the title
			var href = $(this).attr('href'); //Gets the link to the image
			var index = href.indexOf('?'); //Finds the querystring
			index++; //moves the index beyond the questionmark
			var qs = new Querystring(href.substr(index)); //splits new querystring from href-querystring
			var width = qs.get("popup-width") || 400; //Get the width of the image, 400px if no value
			var height = qs.get("popup-height") || 400; //Get the height from the query, 400 if no value
			var type = qs.get("popup-type"); //Get type image|iframe
			if(width < 100){ width = 400;} //If the width of the image is less than 100px, then set the width to default
			if(height < 100){ height = 400;} //If the height of the image is less than 100px, then set the height to default
			GB_show(t,$(this).attr('href'), width, height, type); //Call graybox function
			return false; //Do not follow the link
		 });


	
    $("a.popup").click( function() {

    		var qs = new Querystring($(this).attr('href'))
			var width = qs.get("popup-width") || null;
			var height = qs.get("popup-height") || null;
			var screen_width = (screen.width * 0.8);
			var screen_height = (screen.height * 0.8);

    	if( (width != null && height != null) && (width != 0 && height != 0) )
    	{
			window.open( $(this).attr('href'), '_blank', 'width=' + width + ',height=' + height+ ',resizable=1,scrollbars=1,location=1,toolbar=1,menubar=1,status=1' );
    	}
    	else
    	{
    		
    		window.open( $(this).attr('href'), '_blank', 'width='+screen_width+',height='+screen_height+',resizable=1,scrollbars=1,location=1,toolbar=1,menubar=1,status=1' );
    	}
        return false;
    });

});


function OpenPopUp(PURL, PProp) {
	Prop = PProp.substr(6, PProp.length);
	Prop = Prop.substr(0,(Prop.length - 1));
	var WHArr  = new Array();
	WHArr = Prop.split(',');
	if (WHArr[0] > 0 && WHArr[1] > 0) {
		window.open(PURL, 'NewWin', 'width=' + WHArr[0] + ',height=' + WHArr[1]+ ',resizable=1');
	} else {
		window.open(PURL, 'NewWin', '');
	}
}

function GoToLink(Where,URL,Type) {
	if (Where == "External") {
		LURL = URL;
	} else if (Where == "File") {
		LURL = 'File.php?FileID=' + URL + '&SiteID=<?=$SiteID?>';
	} else {
		LURL = 'CM.php?PageID=' + URL;
	}

	if (Type == "Pop" || Where == "File") {
		window.open(LURL, 'NewLink', '');
	} else {
		this.location.href = LURL;
	}
}

function GoToLinkSized(Where,URL,Width,Height) {
	if (Where == "External") {
		LURL = URL;
	} else if (Where == "File") {
		LURL = 'File.php?FileID=' + URL + '&SiteID=<?=$SiteID?>';
	} else {
		LURL = 'CM.php?PageID=' + URL;
	}

	if (Width > 0 || Height > 0) {
		window.open(LURL, 'NewLink', 'width=' + Width + ',height=' + Height + ',scrollbars=2');
	} else {
		window.open(LURL, 'NewLink', '');
	}
}

/* */
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};

	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;
	
// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split(/&|&amp;/); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}
