// -------------------------------------------------------------------------------//
// PAGE START FUNCTIONS                                                           //
// -------------------------------------------------------------------------------//
function startpage(section) {
	changeCSS();
	checkCookies();
	checkDebug();
	
	if(section == undefined){
		section = generic;
	}
	
	section(); //this will launch the relevant page functions
}

// -------------------------------------------------------------------------------//
// GOOGLE ANALYTICS                                                               //
// -------------------------------------------------------------------------------//
if ((TrackingCode == undefined) || (TrackingCode == "")){
	var TrackingCode = "UA-15331786-1";
}

if ((ClientCode == undefined) || (ClientCode == "")){
	var ClientCode = "none";
}

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
var hndl = window.setTimeout("StartTracking()", 100);

function StartTracking(){
if (typeof(_gat) == 'object')
{
window.clearTimeout(hndl);
	var firstTracker = _gat._getTracker(TrackingCode);
	firstTracker._initData();
	firstTracker._trackPageview();
	if(ClientCode != "none"){
		var secondTracker = _gat._getTracker(ClientCode);
		secondTracker._setDomainName("none");
		secondTracker._setAllowLinker(true);
		secondTracker._initData();
		secondTracker._trackPageview();
	}
} else {
hndl = window.setTimeout("StartTracking()", 1000);
}
}

// -------------------------------------------------------------------------------//
// GOOGLE ANALYTICS - LINK TRACKING                                               //
// -------------------------------------------------------------------------------//
function LinkTracking(address, category, action, label){
	var firstTracker = _gat._getTracker(TrackingCode);
	firstTracker._trackEvent(category, action, label);
	if(ClientCode != "none"){
		var secondTracker = _gat._getTracker(ClientCode);
		secondTracker._trackEvent(category, action, label);
	}
	setTimeout(function(){
		window.open(address.href);
	}, 100);
}

// -------------------------------------------------------------------------------//
// CHANGE CSS                                                                     //
// -------------------------------------------------------------------------------//
function changeCSS() {	
	var browserSheet = "";
	var systemSheet = "";
	var allSheets = "";
	var sheetLocation = "http://"+document.domain+"/includes/css/";
	var headID = document.getElementsByTagName("head")[0];  
	var browserNode = document.createElement("link");
	browserNode.type = "text/css";
	browserNode.rel = "stylesheet";
	var systemNode = document.createElement("link");
	systemNode.type = "text/css";
	systemNode.rel = "stylesheet";
	
	if (navigator.userAgent.toLowerCase().indexOf('opera/9.80') > -1) {
		// ARE USING OPERA 10 SO ADD STYLESHEET (ABOVE IS USER AGENT, BUT ACTUAL VERSION IS 10)
		browserSheet = "group-opera.css";
	}
	
	if (navigator.userAgent.toLowerCase().indexOf('linux') > -1) {
		if (navigator.userAgent.toLowerCase().indexOf('opera/9') > -1) {
			//ARE USING OPERA 9 FOR UBUNTU SO ADD STYLESHEET
			browserSheet = "group-opera-linux.css";
		}	
	}
	
	if (navigator.userAgent.toLowerCase().indexOf('firefox/2') > -1) {
		if (navigator.userAgent.toLowerCase().indexOf('macintosh') > -1) {
			// ARE USING FIREFOX 2 FOR MAC SO ADD STYLESHEET
			browserSheet = "group-firefox2-mac.css";
		} else if (navigator.userAgent.toLowerCase().indexOf('linux') > -1) {
			// ARE USING FIREFOX 2 FOR UBUNTU SO ADD STYLESHEET
			browserSheet = "group-firefox2-linux.css";
		} else {
			// ARE USING FIREFOX 2 SO ADD STYLESHEET
			browserSheet = "group-firefox2.css";
		}
	}
	
	if (navigator.userAgent.toLowerCase().indexOf('msie 6') > -1) {
		// ARE USING INTERNET EXPLORER 6 SO ADD STYLESHEET
		browserSheet = "group-ie6.css";
	}	

	if (navigator.userAgent.toLowerCase().indexOf('msie 7') > -1) {
		// ARE USING INTERNET EXPLORER 7 SO ADD STYLESHEET
		browserSheet = "group-ie7.css";
	}
	
	if (navigator.userAgent.toLowerCase().indexOf('linux') > -1) {
		systemSheet = "group-ubuntu.css";
	} 
	
	if (browserSheet != "") {
		allSheets = sheetLocation+browserSheet;
		browserNode.href = allSheets;
		browserNode.id = "browser-stylesheet";
		headID.appendChild(browserNode);
	}
	
	if (systemSheet != "") {
		allSheets = sheetLocation+systemSheet;
		systemNode.href = allSheets;
		systemNode.id = "system-stylesheet";
		headID.appendChild(systemNode);
	}
}

// -------------------------------------------------------------------------------//
// BROWSER DETECTION                                                              //
// -------------------------------------------------------------------------------//
function browserDetection() {
	var BrowserDetect = {
		init: function () {
			this.browser = this.searchString(this.dataBrowser) || "Unknown";
			this.version = this.searchVersion(navigator.userAgent)
				|| this.searchVersion(navigator.appVersion)
				|| "0";
			this.OS = this.searchString(this.dataOS) || "Unknown";
		},
		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.userAgent, subString: "LittleSnapper", identity: "LittleSnapper"},
			{string: navigator.vendor, subString: "Apple", identity: "Safari", versionSearch: "Version"},
			{prop: window.opera, identity: "Opera"},
			{string: navigator.vendor, subString: "iCab", identity: "iCab"},
			{string: navigator.vendor, subString: "KDE", identity: "Konqueror"},
			{string: navigator.vendor, subString: "Camino", identity: "Camino"},
			{string: navigator.userAgent, subString: "Firefox", identity: "Firefox"},
			// 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.userAgent, subString: "iPhone", identity: "iPhone/iPod"},
			{string: navigator.platform, subString: "Linux", identity: "Linux"}
		]
	};
	BrowserDetect.init();

	//Increments by one on every occurance where the browser being used is not in the list of working browsers
	var redirectCount = 0;
	
	//An array containing all the working browsers	
	browsers = new Array('Firefox','Explorer','Chrome','Opera','Camino','Konqueror','Safari','LittleSnapper') ;
	browserlowest = new Array('2','6','4','9','2','4','3','1') ;

	//For loop goes through the array and adds one to the counter everytime the browsers is not equal to the current array item
	for (i=0; i < browsers.length; i++) {
		if (BrowserDetect.browser != browsers[i]) {
			redirectCount++;
		} else if (BrowserDetect.version < browserlowest[i]) {
			setCookie('referrerAddress',window.location);
			window.location = 'http://www.i-studentgroup.com/alert/english/website.html';
		}
	}
	
	//If the counter is not equal to the lenght of the array it means the browser being use is not permitted and will redirect
	if (redirectCount == browsers.length) {
		setCookie('referrerAddress',window.location);
		window.location = 'http://www.i-studentgroup.com/alert/english/website.html';
	}
}

// -------------------------------------------------------------------------------//
// COOKIE FUNCTIONS                                                               //
// -------------------------------------------------------------------------------//
function checkCookies() {
	debugMode = getCookie('debugMode');
	browserForced = getCookie('forceBrowser');
	if ((debugMode != "true") && (browserForced != "true")) {
		browserDetection();
 	}
}

function getCookie(c_name) {
	var nameEQ = c_name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) {
			return c.substring(nameEQ.length,c.length);
		}
    }
    return null;
	
}

function setCookie(c_name,value,expiry) {
	var exdate=new Date();
	var path="/";
	exdate.setDate(exdate.getDate()+expiry);
	
	document.cookie=c_name+"="+escape(value)+((expiry=="")?";expires="+exdate.toGMTString():"")+((path)?";path="+path:"");
}

// -------------------------------------------------------------------------------//
// DEBUG MODE FUNCTIONS                                                           //
// -------------------------------------------------------------------------------//
function checkDebug() {
	if (document.location.href.indexOf('enableDebug') > -1) {
		enableDebug();
	} else if (document.location.href.indexOf('disableDebug') > -1) {
		disableDebug();
	}
}

function enableDebug() {
	setCookie('debugMode','true',1);
	alert("DEBUG ENABLED");
}

function disableDebug() {
	setCookie('debugMode','false',-1);
	alert("DEBUG DISABLED");
}

// -------------------------------------------------------------------------------//
// FORCE BROWSER FUNCTIONS                                                        //
// -------------------------------------------------------------------------------//
function forceBrowser() {
	setCookie('forceBrowser','true');
	var referrer = unescape(getCookie('referrerAddress'));
	if (referrer.indexOf('www.') < 0) {
		referrer = referrer.split('http://');
		referrer = "http://www."+referrer[1];
	}
	window.location = referrer;
}

// -------------------------------------------------------------------------------//
// PAGE FUNCTIONS                                                                 //
// -------------------------------------------------------------------------------//
function homepage(){	
	startXML();
	preloadimages();
	swapbackground(dayno);
	swapthumbs(weekno);	
	checkpage();
	if (navigator.userAgent.toLowerCase().indexOf('msie 6') > -1) {
		ie6hidemore();
		supersleight.run();
	}
}

// -------------------------------------------------------------------------------//
// PNG TRANSPARENCY                                                               //
// -------------------------------------------------------------------------------//
var supersleight	= function() {	
	var root = false;
	var applyPositioning = true;
	
	// Path to a transparent GIF image
	var shim			= 'includes/javascript/clear.gif';
	
	// RegExp to match above GIF image name
	var shim_pattern	= /includes\/javascript\/clear\.gif$/i;	
	
	var fnLoadPngs = function() { 
		if (root) {
			root = document.getElementById(root);
		}else{
			root = document;
		}
		for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
			// background pngs
			if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
				bg_fnFixPng(obj);
			}
			// image elements
			if (obj.tagName=='IMG' && obj.src.match(/\.png$/i) !== null){
				el_fnFixPng(obj);
			}
			// apply position to 'active' elements
			if (applyPositioning && (obj.tagName=='A' || obj.tagName=='INPUT') && obj.style.position === ''){
				obj.style.position = 'relative';
			}
		}
	};

	var bg_fnFixPng = function(obj) {
		var mode = 'scale';
		var bg	= obj.currentStyle.backgroundImage;
		var src = bg.substring(5,bg.length-2);
		if (obj.currentStyle.backgroundRepeat == 'no-repeat') {
			mode = 'crop';
		}
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
		obj.style.backgroundImage = 'url('+shim+')';
	};

	var el_fnFixPng = function(img) {
		var src = img.src;
		var objClass = img.className;
		if(objClass.indexOf('hiddenElement') > -1){
			var tmpImg = new Image();
			tmpImg.src = img.src;			
			img.style.width = tmpImg.width + "px";
			img.style.height = tmpImg.height + "px";
			delete tmpImg;
		} else {
			img.style.width = img.width + "px";
			img.style.height = img.height + "px";
		}
		
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		img.src = shim;
	};
	
	var addLoadEvent = function(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			};
		}
	};
	
	return {
		init: function() { 
			addLoadEvent(fnLoadPngs);
		},
		
		limitTo: function(el) {
			root = el;
		},
		
		run: function() {
			fnLoadPngs();
		}
	};
}();

// -------------------------------------------------------------------------------//
// READ MORE TOGGLE                                                               //
// -------------------------------------------------------------------------------//
function readmore(id) {
	for(i=1; i<5; i++){
		var readmorelink = document.getElementById('readmore'+i+'-link');
		var readmoretext = document.getElementById('readmore'+i);
		var hidemorelink = document.getElementById('hidemore'+i+'-link');
		
		if(i == id){
			readmorelink.style.display = 'none';
			hidemorelink.style.display = 'block';
			$(readmoretext).slideDown("slow");
		} else {
			readmorelink.style.display = 'block';
			hidemorelink.style.display = 'none';
			$(readmoretext).slideUp("slow");
		}
	}
	hideinfo(false);
	
	if (document.getElementById('info3').style.display == 'block' || document.getElementById('info3').style.display == '') {
		$('#info3').fadeOut("slow");
	}
	
	contentRefresh();
}

function hidemore(ignore) {
	for(i=1; i<5; i++){
		var readmorelink = document.getElementById('readmore'+i+'-link');
		var readmoretext = document.getElementById('readmore'+i);
		var hidemorelink = document.getElementById('hidemore'+i+'-link');
		readmorelink.style.display = 'block';
		hidemorelink.style.display = 'none';
		$(readmoretext).slideUp("slow");
	}
	
	if ((document.getElementById('info3').style.display == 'none' || document.getElementById('info3').style.display == '') && ignore != false) {
		$('#info3').fadeIn("slow");
	}
}

function ie6hidemore() {
	for(i=1; i<5; i++)	{
		var readmorelink = document.getElementById('readmore'+i+'-link');
		var readmoretext = document.getElementById('readmore'+i);
		var hidemorelink = document.getElementById('hidemore'+i+'-link');
		readmorelink.style.display = 'block';
		hidemorelink.style.display = 'none';
		readmoretext.style.display = 'none';
	}
	$('#info1').fadeIn("slow");
	$('#info1').fadeOut("slow");
	
	$('#info3').fadeIn("slow");
}

// -------------------------------------------------------------------------------//
// INFO TOGGLE                                                                    //
// -------------------------------------------------------------------------------//
function showinfo(id) {
	hidemore(false);
	for(i=1; i<8; i++){
		var showinfotext = document.getElementById('info'+i);
		if(i == id) {
			$(showinfotext).fadeIn("slow");
		} else {
			$(showinfotext).fadeOut("slow");
		}
	}
	if (id == 4 || id == 6) {
		$('#box1').fadeOut("slow");
		$('#box2').fadeOut("slow");
		$('#box3').fadeOut("slow");
		$('#box4').fadeOut("slow");
	} else {
		$('#box1').fadeIn("slow");
		$('#box2').fadeIn("slow");
		$('#box3').fadeIn("slow");
		$('#box4').fadeIn("slow");
	}
}

function hideinfo(ignore) {
	for(i=1; i<8; i++){
		var showinfotext = document.getElementById('info'+i);
		
		if (i != 3) {
			$(showinfotext).fadeOut("slow");
			$('#box1').fadeIn("slow");
			$('#box2').fadeIn("slow");
			$('#box3').fadeIn("slow");
			$('#box4').fadeIn("slow");

			if (ignore != false) {
				$('#info3').fadeIn("slow");
			}
		}
	}
}

// -------------------------------------------------------------------------------//
// QUERY STRING                                                                   //
// -------------------------------------------------------------------------------//
var pagecheck = document.location.search;
 
if (pagecheck[0]='?') {
	pagecheck = pagecheck.substr(1, pagecheck.length-1);
	if (pagecheck.indexOf('week=') > -1) {
		var weekno = pagecheck.substr(5, pagecheck.length-1);
	}
}

function checkpage() {	
	if (pagecheck == 'contact') {
		showinfo('2');
	} else if (pagecheck == 'readmore') {
		readmore('1');
	} else if (pagecheck == 'jobs') {
		showinfo('6');
	} else if (pagecheck == 'social-facebook') {
		showinfo('7');
	}
}

// -------------------------------------------------------------------------------//
// DATE FUNCTIONS                                                                 //
// -------------------------------------------------------------------------------//
// used to get the day of the week
var date = new Date();
var day = Math.round(date.getDay());
var dayno = day++;
	
// used to get the week number	
function y2k(number) {
	return (number < 1000) ? number + 1900 : number;
}

function getWeek(year,month,day) {
    var when = new Date(year,month,day);
    var newYear = new Date(year,0,1);
    var offset = 7 + 1 - newYear.getDay();
    if (offset == 8) offset = 1;
    var daynum = ((Date.UTC(y2k(year),when.getMonth(),when.getDate(),0,0,0) - Date.UTC(y2k(year),0,1,0,0,0)) /1000/60/60/24) + 1;
    var weeknum = Math.floor((daynum-offset+7)/7);
    if (weeknum == 0) {
        year--;
        var prevNewYear = new Date(year,0,1);
        var prevOffset = 7 + 1 - prevNewYear.getDay();
        if (prevOffset == 2 || prevOffset == 8) weeknum = 53; else weeknum = 52;
    }
    return weeknum;
}

var now = new Date();

if (weekno == null) {
	var weekno = getWeek(y2k(now.getYear()),now.getMonth(),now.getDate());
}
if (dayno == 0) {
	weekno--;
	dayno = 7;
}

// -------------------------------------------------------------------------------//
// XML FUNCTIONS                                                                 //
// -------------------------------------------------------------------------------//
var noXML;

var accredday1;
var accredday2;
var accredday3;
var accredday4;
var accredday5;
var accredday6;
var accredday7;

function startXML() {
	var XMLURL = "images/week"+weekno+"/accreditations.xml";
	noXML = false;
	
	if (window.XMLHttpRequest) {
	  	xhttp = new XMLHttpRequest();
	} else {
		try {
			xhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xhttp = null;
			}
		}
	}
	
	xhttp.open("GET",XMLURL,false);
	xhttp.send(null);
	xmlDoc = xhttp.responseXML;
	
	if(xmlDoc == null) {
		noXML = true;
		XMLURL = "images/week0/accreditations.xml";
	
		if (window.XMLHttpRequest) {
	  	xhttp = new XMLHttpRequest();
		} else {
			try {
				xhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (E) {
					xhttp = null;
				}
			}
		}
		xhttp.open("GET",XMLURL,false);
		xhttp.send("");
		xmlDoc=xhttp.responseXML;
	}
	
	accredday1 = xmlDoc.getElementsByTagName("ImageAccreditation")[0].childNodes[0].nodeValue;
	accredday2 = xmlDoc.getElementsByTagName("ImageAccreditation")[1].childNodes[0].nodeValue;
	accredday3 = xmlDoc.getElementsByTagName("ImageAccreditation")[2].childNodes[0].nodeValue;
	accredday4 = xmlDoc.getElementsByTagName("ImageAccreditation")[3].childNodes[0].nodeValue;
	accredday5 = xmlDoc.getElementsByTagName("ImageAccreditation")[4].childNodes[0].nodeValue;
	accredday6 = xmlDoc.getElementsByTagName("ImageAccreditation")[5].childNodes[0].nodeValue;
	accredday7 = xmlDoc.getElementsByTagName("ImageAccreditation")[6].childNodes[0].nodeValue;
}

// -------------------------------------------------------------------------------//
// IMAGE SPECIFIC                                                                 //
// -------------------------------------------------------------------------------//
var intransition = false;

function swapbackground(dayno){
	if(intransition == false){
		if (noXML == true) {
			var image = "url(http://www.i-studentgroup.com/images/week0/backgrounds/day"+dayno+".jpg) no-repeat";
		} else {
			var image = "url(http://www.i-studentgroup.com/images/week"+weekno+"/backgrounds/day"+dayno+".jpg) no-repeat";
		}
		
		var accred = document.getElementById('accredtext');accred.style.display = 'none';
		
		if(dayno == 1){
			accred.innerHTML = "<p>"+accredday1+"</p>";
		} else 	if(dayno == 2){
			accred.innerHTML = "<p>"+accredday2+"</p>";
		} else 	if(dayno == 3){
			accred.innerHTML = "<p>"+accredday3+"</p>";
		} else 	if(dayno == 4){
			accred.innerHTML = "<p>"+accredday4+"</p>";
		} else 	if(dayno == 5){
			accred.innerHTML = "<p>"+accredday5+"</p>";
		} else 	if(dayno == 6){
			accred.innerHTML = "<p>"+accredday6+"</p>";
		} else if(dayno == 7){
			accred.innerHTML = "<p>"+accredday7+"</p>";
		} else {
			accred.innerHTML = "<p></p>";
		}
		
		for(i=1; i<=7; i++){
			if(i == dayno){
				imgname = "thumb"+i;			
				img = document.getElementById(imgname);
				img.style.borderColor = "#FFFFFF"
			} else {
				imgname = "thumb"+i;
				img = document.getElementById(imgname);
				img.style.borderColor = "#182F4D"
			}
		}	
		
		document.getElementById('background-above').style.background = image;
			
		intransition = true;
		
		$('#background-above').fadeIn(500, function() {
			document.getElementById('background-below').style.background = document.getElementById('background-above').style.background;
			document.getElementById('background-above').style.display = 'none';
			intransition = false;
			accred.style.display = 'block';
		});
	}
}

function swapthumbs(weekno){
	for(i=1; i<=7; i++){
		// change thumbs
		imgname = "thumb"+i;
		img = document.getElementById(imgname);
		if (noXML == true) {
			img.src = "http://www.i-studentgroup.com/images/week0/thumbs/day"+i+".jpg";
		} else {
			img.src = "http://www.i-studentgroup.com/images/week"+weekno+"/thumbs/day"+i+".jpg";
		}
	}
}

function preloadimages() {	
	var imageArray = new Array();
	for(i=1; i<=7; i++){
        var tmpImage = new Image();
		if (noXML == true) {
			tmpImage.src="http://www.i-studentgroup.com/images/week0/backgrounds/day"+i+".jpg";
		} else {
			tmpImage.src="http://www.i-studentgroup.com/images/week"+weekno+"/backgrounds/day"+i+".jpg";
		}
		imageArray[i-1] = tmpImage;
	}
		// PRELOAD ADDITIONAL IMAGES	
    var background = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/background.png');
    var background2 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/background2.png');
    var background3 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/background3.png');
    var background4 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/background4.png');
    var background5 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/background5.png');
    var top = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/top.png');
    var top2 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/top2.png');
    var top3 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/top3.png');
    var top4 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/top4.png');
    var bottom = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/bottom.png');
    var bottom2 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/bottom2.png');
    var bottom3 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/bottom3.png');
    var bottom4 = $('<img />').attr('src','http://www.i-studentgroup.com/images/boxes/bottom4.png');
    var arrowUp = $('<img />').attr('src','http://www.i-studentgroup.com/images/generic/arrow-up.png');
    var arrowDown = $('<img />').attr('src','http://www.i-studentgroup.com/images/generic/arrow-down.png');
    var clear = $('<img />').attr('src','http://www.i-studentgroup.com/includes/javascript/clear.gif');

}

// -------------------------------------------------------------------------------//
// DISABLE TEXT SELECTION ON LINKS                                                //
// -------------------------------------------------------------------------------//
$(document).ready(function(){
	$(function(){
		$.extend($.fn.disableTextSelect = function() {
			return this.each(function(){
				if($.browser.mozilla){//Firefox
					$(this).css('MozUserSelect','none');
				}else if($.browser.msie){//IE
					$(this).bind('selectstart',function(){return false;});
				}else{//Opera, etc.
					$(this).mousedown(function(){return false;});
				}
			});
		});
		$('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'
	});
});

// -------------------------------------------------------------------------------//
// CONTENT REFRESH                                                                //
// -------------------------------------------------------------------------------//
var startRefresh;

function contentRefresh(){
	if (navigator.userAgent.toLowerCase().indexOf('opera/9') > -1) {
		startRefresh = setInterval("refreshSite()", 100);
		setTimeout(finishRefresh(),600);
	}
}

function refreshSite(){
	var websiteContainer = document.getElementById('websites');
	websiteContainer.style.display = 'none';
	websiteContainer.style.display = 'block';
}

function finishRefresh(){
	clearInterval(startRefresh);
}

function openAppLink(num,name) {
	LinkTracking(document.getElementById("application-link"+num), 'i-studentgroup Home', 'App Advert', name);
}
