/* Start jQuery functions */
if (typeof(jQuery) != "undefined") {	
	 $(function() {
		
		/*** External links ***/
		$('a[rel="external"]').click(function(e){
			var url = 	$(this).attr("href");													  
			var name = url;											  
			return normalWin(url,name);
		});
		
		/*** OSC website popup ***/
		// Version 1.2 - Max size added, scrollbars set to auto (JC)
		$("a[href^='https://service.gemoney.com.au']").click(function(e){
			var url = 	$(this).attr("href");													  
			var name = url.substring(url.lastIndexOf("/"), url.length);											  
			return fullscreenWin(url,name);
		}); 
		/*** Feedback form popup ***/
		$('a[rel="#feedbackFrm"]').click(function(e) { 
			var w = 470;
			var h  = 500;
			var feedbackWin = window.open($(this).attr("href"),'Feedback', 'width='+w+',height='+h+',top='+(screen.height/2-h/2)+',left='+(screen.width/2-w/2));
			if (feedbackWin && feedbackWin.open) {
				feedbackWin.focus();
				return false;
			}
			
    	});
		
		/*
		TODO: Overlay
		$("body").append("<div class='overlay' id='feedbackFrm'></div>");
		// if the function argument is given to overlay, it is assumed to be the onBeforeLoad event listener 
		$("a[rel='#feedbackFrm']").overlay(function() {  
			// grab wrapper element inside content 
			var wrap = this.getContent().find("div.overlay-wrap"); 
			// load only for the first time it is opened 
			if (wrap.is(":empty")) { 
				wrap.load(this.getTrigger().attr("href")); 
			} 
		});*/ 
	}); 
}
/* End jQuery functions */

function normalWin(url,name) {
	var normWin = null;
	if (typeof(name) == "undefined") {
		 var name = window.location.hostname;
	}
	var normWin = window.open(url,name);
				
	if (normWin && normWin.open) {
		// Provide focus
		normWin.focus();
		return false;
	} 
}

function fullscreenWin(url,name){
	var fullWin = null;
	if (typeof(name) == "undefined") {
		 var name = window.location.hostname;
	}
	var fullWin = window.open(url,name,'fullscreen=yes,scrollbars=auto');
				
	if (fullWin && fullWin.open) {
		// Provide focus
		fullWin.focus();
		return false;
	} 
}
