// for site specific functions. either grab js from code-library.js or write your own.






























/* =================================================================== */
// function to add events crossbrowser
// from: http://www.dustindiaz.com/rock-solid-addevent/
// uncomment the EventCache lines if using EventCache function from code lib
function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

// use only with addEvent function
// this is here to clear the event cache to prevent memory leaks
// for more info:  http://novemberborn.net/javascript/event-cache
var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();
addEvent(window,'unload',EventCache.flush);
/* =================================================================== */

function SetUniqueRadioButton(nameregex, current)
{
	re = new RegExp(nameregex);
	for(i = 0; i < document.forms['aspnetForm'].elements.length; i++)
	{
		elm = document.forms['aspnetForm'].elements[i];
		if (elm.type == 'radio')
		{
			if (re.test(elm.name))
			{
			elm.checked = false;
			}
		}
	}
	current.checked = true;
}

function ClearRadioButton(nameregex)
{
	re = new RegExp(nameregex);
	for(i = 0; i < document.forms['aspnetForm'].elements.length; i++)
	{
		elm = document.forms['aspnetForm'].elements[i];
		if (elm.type == 'radio')
		{
			if (re.test(elm.name))
			{
			elm.checked = false;
			}
		}
	}
}

$(document).ready(function () {

	// launch all rel=external into new windows
	$('a[rel="external"]').click(function(){
		window.open(this.href);
		return false;
	});




	$(".sessClick").attr("href","javascript:void(0);").click(function() {
		ClearRadioButton('rptSessionDayItem.*dayItems*');
	});
	
	/*

	$('ul.dayItems li ul li ul li label').each(function(){
		var session_id = $(this).parent().children("input").val();
   		$(this).qtip({
			content: { text: 'Loading...' },
			api: {
				beforeShow: function() {
					var url = 'http://' + document.domain + '/Oneshield.Userconf.Web/registration/session-description.aspx?id=' + session_id;
					if (url != '') {
						this.loadContent(url);
					}
				},
				onContentLoad: function() {
					
				}
			},
			style: { 
				width: 400,
				padding: 5,
				background: '#E0E5F0',
				color: '#5872AD',
				border: {
				width: 7,
				radius: 5,
				color: '#E0E5F0'
				},
				tip: 'bottomLeft',
				name: 'dark' // Inherit the rest of the attributes from the preset dark style
			},
			position: {
				corner: {
				target: 'topLeft',
				tooltip: 'bottomLeft'
				},
				adjust: {
					x: 15,
					y: 0
				}
			},
			show: 'mouseover',
			hide: 'mouseout'
		});
	});
	
	$('.sessionLink').each(function(){
		var session_id = $(this).attr("href").replace("#","");
   		$(this).qtip({
			content: { text: 'Loading...' },
			api: {
				beforeShow: function() {
					var url = 'http://' + document.domain + '/Oneshield.Userconf.Web/registration/session-description.aspx?id=' + session_id;
					if (url != '') {
						this.loadContent(url);
					}
				},
				onContentLoad: function() {
					
				}
			},
			style: { 
				width: 400,
				padding: 5,
				background: '#E0E5F0',
				color: '#5872AD',
				border: {
				width: 7,
				radius: 5,
				color: '#E0E5F0'
				},
				tip: 'bottomLeft',
				name: 'dark' // Inherit the rest of the attributes from the preset dark style
			},
			position: {
				corner: {
				target: 'topLeft',
				tooltip: 'bottomLeft'
				},
				adjust: {
					x: 15,
					y: 0
				}
			},
			show: 'mouseover',
			hide: 'mouseout'
		});
	});
	*/
});