function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}

function confirmDelete(the_thing, redirect)
{
	var txt = "This will delete the " + the_thing + ".\nAre you sure you want to do that?";
	if (confirm(txt))
	{
		location.replace(redirect);
	}
}

function SwitchContent()
{
	var form  = document.forms[0];
	var id    = form.id.value;
	var obj   = form.obj_id.value;

	if (obj == '')
	{
		obj = 1;
	}

	form.action = "/admin/packs/list/id:" + id + "/obj:" +  obj;
	form.method = "POST";
	//return;
	form.submit();
}

function move(direction)
{
	var form  = document.forms[0];
	direction.toLowerCase();

	if (direction == 'left')
	{
		form.direction.value = 'left';
		SwitchContent();
	}
	else if (direction == 'right')
	{
		form.direction.value = 'right';
		SwitchContent();
	}
	else
	{
		return false;
	}
}

function order(vertical)
{
	var form  = document.forms[0];
	vertical.toLowerCase();

	if (vertical == 'up')
	{
		form.vertical.value = 'up';
		SwitchContent();
	}
	else if (vertical == 'down')
	{
		form.vertical.value = 'down';
		SwitchContent();
	}
	else
	{
		return false;
	}
}

function initVideo(div, id, size)
{
	var w = 0;
	var h = 0;

	switch (size.toUpperCase())
	{
		case 'S':
			w = 320;
			h = 240;
		break;

		case 'L':
		default:
			w = 640;
			h = 480;
		break;
	}

	var s1 = new SWFObject(dir_swf + "mediaplayer.swf", "mediaplayer", w, h, "8");
	s1.addParam("wmode","opaque");
	s1.addParam("allowfullscreen","true");
	s1.addParam('allowscriptaccess','always');
	var ver = s1.installedVer;
	var size = 'gallery';

	if (ver.major < 8)
	{
		s1.useExpressInstall(dir_swf + 'expressinstall.swf');
	}
	else
	{
		if (ver.major<=9 && ver.minor==0 && ver.rev<115)
		{
			size = 'gallery';
			ext  = '.flv';
		}
		else
		{
			size = 'original';
			ext  = '.mov';
		}
		size = 'gallery';
		ext  = '.flv';
		var file = '/media.php/' + size + '/' + id + ext;
		s1.addVariable("file", file);
	}
	s1.addVariable("width",w);
	s1.addVariable("height",h);
	s1.addVariable("autostart",false);
	s1.addVariable("image",'/media.php/promo_gallery/' + id + '.jpg');
	s1.write(div);
}


function var_dump(obj)
{
	if(typeof obj == "object")
	{
		return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
	}
	else
	{
		return "Type: "+typeof(obj)+"\nValue: "+obj;
	}
}

var ajax = {
	req : null,
	loadRequest : function(url, method, which) {
		if (which == null) which = '';
		if (window.XMLHttpRequest) {
			this.req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			this.req = new ActiveXObject('Microsoft.XMLHTTP');
		}
		if (this.req) {
			this.req.onreadystatechange = function() {
				ajax.get(method, which);
			};
			this.req.open('GET', url, true);
			this.req.send(null);
		} else {
			return;
		}
	},
	get : function(method, which) {
		if (this.req.readyState == 4) {
			if (this.req.status == 200) {
				var m = eval(method);
				var s = (which == 'xml') ? this.req.responseXML : this.req.responseText;
				m(s);
			} else {
				//alert('There was a problem retrieving your request. ' + this.req.statusText);
			}
		}
	}
}

function loadRequest(url, method, which) {
	this.method = method;
	this.which = (which == null) ? '' : which;
	if (window.XMLHttpRequest) {
		this.req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		this.req = new ActiveXObject('Microsoft.XMLHTTP');
	}
	if (this.req) {
		var _this = this;
		this.req.onreadystatechange = function() {
			_this.processReq();
		};
		this.req.open('GET', url, true);
		this.req.send(null);
	} else {
		return;
	}
}
loadRequest.prototype.processReq = function() {
	if (this.req.readyState == 4) {
		if (this.req.status == 200) {
			var m = eval(this.method);
			var s = (this.which == 'xml') ? this.req.responseXML : this.req.responseText;
			m(s);
		} else {
			//alert('There was a problem retrieving your request. ' + this.req.statusText);
		}
	}
}


var getEventDay = {
	open : function(day) {
		ajax.loadRequest('/ajax.php/events/day/day:' + day, 'getEventDay.show');
	},
	show : function(str)
	{
		var o1 = document.getElementById('modalBody');
		if (!o1) return;
		var o2 = document.getElementById('modalPage');
		if (!o2) return;

		o1.innerHTML = str;

		window.onscroll = function () { o2.style.top = document.body.scrollTop; };
		o2.style.display ='block';
		o2.style.top = document.body.scrollTop;

	},
	close : function() {
		var o = document.getElementById('modalPage');
		if (!o) return;
		o.style.display ='none';
	}
}


/**
 *
 * @access public
 * @return void
 **/

function loadKevinSubNav() {
	var obj = document.getElementById('n2');
	if (!obj) return;
	var o = document.getElementById('kevin');
	if (!o) return;
	obj.onmouseover = o.onmouseover = function() {
		obj.style.display = 'block';
		o.style.display = 'block';
	}
	obj.onmouseout = o.onmouseout = function() {
		o.style.display = 'none';
	}
}

function loadIssuesSubNav() {
	var obj = document.getElementById('n3');
	if (!obj) return;
	var o = document.getElementById('issues');
	if (!o) return;
	obj.onmouseover = o.onmouseover = function() {
		obj.style.display = 'block';
		o.style.display = 'block';
	}
	obj.onmouseout = o.onmouseout = function() {
		o.style.display = 'none';
	}
}

function loadNeighborSubNav() {
	var obj = document.getElementById('n4');
	if (!obj) return;
	var o = document.getElementById('neighbor');
	if (!o) return;
	obj.onmouseover = o.onmouseover = function() {
		obj.style.display = 'block';
		o.style.display = 'block';
	}
	obj.onmouseout = o.onmouseout = function() {
		o.style.display = 'none';
	}
}

function loadActionSubNav() {
	var obj = document.getElementById('n5');
	if (!obj) return;
	var o = document.getElementById('action');
	if (!o) return;
	obj.onmouseover = o.onmouseover = function() {
		obj.style.display = 'block';
		o.style.display = 'block';
	}
	obj.onmouseout = o.onmouseout = function() {
		o.style.display = 'none';
	}
}

function SmartLink(url)
{
    var f = document.getElementById('hkw');
    var r = url
    for (i=0; i<f.elements.length; i++)
    {
           if (f.elements[i].type != 'hidden'
               && f.elements[i].type != 'submit'
               && typeof(f.elements[i].value) == 'string'
               && f.elements[i].name.ucFirst() != f.elements[i].value
              )
           {
            r += "/" + encodeURIComponent(decodeURI(f.elements[i].name.replace(/\./g, "[DOT]"))) + ':' + encodeURIComponent(decodeURI(f.elements[i].value.replace(/\./g, "[DOT]")));
           }
    }
    window.location = r;
}

function GetAlerts()
{
	var f = document.getElementById('hkw');
	if (!f)
	{
		//alert('f');
		return;
	}
	var n = document.getElementById('name');
	if (!n)
	{
		//alert('n');
		return;
	}
	var e = document.getElementById('email');
	if (!e)
	{
		//alert('e');
		return;
	}

	if (e.value=='' || e.value=='Email')
	{
		alert("Whoops! Please enter your email then try again.");
	}
	else
	{
		f.submit();
	}
}

String.prototype.ucFirst = function () {
   return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}





var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


