
/**********************************************************************************************
***********************************************************************************************
**                                                                                           **
**  PIMSAT | Institute of Higher Education                                                   **
**  Version 1.0                                                                              **
**                                                                                           **
**  http://www.pimsat-khi.edu.pk                                                             **
**                                                                                           **
**  Copyright 2010 (C) SW3 Solutions                                                         **
**  http://www.sw3solutions.com                                                              **
**                                                                                           **
**  ***************************************************************************************  **
**                                                                                           **
**  Project Manager:                                                                         **
**                                                                                           **
**      Name  :  Muhammad Tahir Shahzad                                                      **
**      Email :  mtahirshahzad@hotmail.com                                                   **
**      Phone :  +92 333 456 0482                                                            **
**      URL   :  http://mts.sw3solutions.com                                                 **
**                                                                                           **
***********************************************************************************************
**********************************************************************************************/

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();


//alert(BrowserDetect.browser + " " + BrowserDetect.version);
// PLEASE NOTE: THIS SCRIPT REQUIRES MOOTOOLS v1.11 TO RUN

//This script is run once the DOM has loaded, no need to wait for images etc to load.
window.addEvent('domready', function()
{
	if (!(BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7))
	{
		//Set The Initial Variables
		var boxNormal = 117, boxSmall = 83, boxFull = 350, boxHeight = 380, boxFontSize = 12, containerHeight = 385, boxSpeed = 1000;

		//HIDE JAVASCRIPT WARNING
		//We hide the Javascript warning as if this is run the browser must have Javascript enabled
		var JsWarning = $("JsWarning");
		JsWarning.setStyle("display","none");

		//ALTER STYLES
		//These functions alter styles that are set in the style sheet

		//Reset the width of the boxes so that they are all closed initially, also change height
		var cu_box_init = $$("#MenuBoxes .box");
		cu_box_init.each(function(myInitBox, h){
			myInitBox.setStyle("width",boxNormal);
			myInitBox.setStyle("height",boxHeight);
		});


		//Resize container height
		var cu_box_container = $("MenuContainer");
		cu_box_container.setStyle("height",containerHeight);

		//ADD THE ROLLOVER EVENTS TO THE COLUMNS		
		var MenuBoxes = $$("#MenuBoxes .box");

		//Create new fx
		var fx = new Fx.Elements(MenuBoxes, {wait: false, duration: boxSpeed, transition: Fx.Transitions.Cubic.easeOut});

		//loop through the columns
		MenuBoxes.each(function(box, i) {
			//OnMouseEnter Events
			box.addEvent("mouseenter", function(event) {
				//Change the display state of the content of rolled column and hide others 
				var o = {};
				o[i] = {width: [box.getStyle("width").toInt(), boxFull]}
				MenuBoxes.each(function(other, j) {
					if(i != j) {
						var w = other.getStyle("width").toInt();
						if(w != boxSmall) o[j] = {width: [w, boxSmall]};
					}
				});
				fx.start(o);
			});
		});

		//OnRollOut Events	
		$("MenuBoxes").addEvent("mouseleave", function(event) {
			var o = {};
			MenuBoxes.each(function(box, i) {
				o[i] = {width: [box.getStyle("width").toInt(), boxNormal]}
			});
			fx.start(o);
		})
	}
});