function deleteItem(page, msg){
	msg = msg ? msg : 'Are you sure you want to delete this item!';
	if(page != 'na'){
		var con = confirm(msg);
		if(con){
			window.location = page;	
		}
	}else{
		alert('Sorry cannot delete item!');
	}
}
function deleteItems(form, msg){
	msg = msg ? msg : 'Are you sure you want to delete this item!';
	var con = confirm(msg);
	if(con){
		form.submit();
	}
}
function addOption(t, name){
	if(t){
		var parent = document.getElementById(t);
	}else{
		var parent = document.getElementById('sup_options');
	}
	var number = parseInt(parent.getElementsByTagName('label').length);
	
	var label = document.createElement('label');
	label.innerHTML = (number+1)+" ";
	
	name = name ? name : "item_options[]";
	if(browser == 'IE'){
		var input_tag = document.createElement('<input name="'+name+'" />');
	}else{
		var input_tag = document.createElement('input');
		input_tag.setAttribute('name',name);
	}
	
	input_tag.setAttribute('type','text');
	input_tag.setAttribute('size','32');
	
	var a = document.createElement('a');
	a.setAttribute('href','javascript:void(0);');
	a.setAttribute('onclick',"removeOption(this)");
	a.innerHTML = "remove";
	
	label.appendChild(input_tag);
	label.innerHTML += " ";
	label.appendChild(a);
	parent.appendChild(label);	
}
function removeOption(t){
	parent = t.parentNode;
	items = parent.getElementsByTagName('label');	
	var con = confirm('Are you sure you want to remove this option.');	
	if(con && items){
		parent.parentNode.removeChild(parent);
	}
}
function selectAll(form, t){
	checked = t.checked ? true : false;
	checkboxes = form.elements;
	for(i=0; i<checkboxes.length; i++){
		if(checkboxes[i].type == 'checkbox' && checkboxes[i].name != "msg_auto_rsvp[]" && checkboxes[i].name != "msg_text" && checkboxes[i].name != "msg_email" && checkboxes[i].name != "msg_both") 
		{
			checkboxes[i].checked = checked;	
		}
	}	
}
function loadTeam(t){
	loadpage('_msg_team_members.php?team_id='+t, 'team');
}
function emailScoreboard(){
	fields = document.item_edit_form.elements;
	for(i=0;i<fields.length;i++){
		if(fields[i].name == 'item_id[]' && fields[i].checked == true){
			document.member_email_form.item_ids.value += fields[i].value+",";
		}
	}
}
function showHide(t, type){
	obj = document.getElementById(t);
	if(obj.style.display == 'none'){
		obj.style.display = type;	
	}else{
		obj.style.display = 'none';	
	}
}
// -------- IE image flicker bug fix ------------//
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
function browseDetect(){
	var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	if(isInternetExplorer == false){
		cn = 'notIE';				//not IE
	}else{
		cn = 'IE';				//is IE
	}
	return cn;
}
browser = browseDetect();
/* beginning of fade div object*/
/*
	id = id of element; 
	initOpac = initial opacity of element; 
	tarOpac = target opacity when finished; 
	speed = the rate at which it fades 1 being the fastest 10+ being slowest
	func = function to call when finished fading
*/
fade = function(id, initOpac, tarOpac, speed, func, params){
	this.obj = document.getElementById(id);
	this.initOpac = initOpac;
	this.tarOpac = tarOpac;
	if(func && params){
		this.func = func(params);		
	}else if(func){
		this.func = func;
	}else{
		this.func = null;
	}
	if(speed){
		this.speed = speed;
	}else{
		this.speed = 2;
	}
	this.obj.style.opacity = this.initOpac/100;
	this.obj.style.filter = 'alpha(opacity='+this.initOpac+')';
	this.check();
}
fade.prototype = {
	check:function(){
		if(this.initOpac < this.tarOpac){
			t = this;
			fadeIn_int = setInterval("t.fadeIn()", 20);
		}else if(this.initOpac > this.tarOpac){
			t = this;
			fadeOut_int = setInterval("t.fadeOut()", 20);
		}
	},
	fadeIn:function(){
		var i = Math.ceil((this.tarOpac-(this.obj.style.opacity*100))/this.speed)+(this.obj.style.opacity*100);
		this.obj.style.opacity = i/100;
		this.obj.style.filter = 'alpha(opacity='+i+')';
		if(i >= this.tarOpac){
			clearInterval(fadeIn_int);
			if(this.func){ this.func(); }
		}
	},
	fadeOut:function(){
		var i = Math.floor((this.tarOpac - (this.obj.style.opacity*100))/this.speed)+(this.obj.style.opacity*100);
		this.obj.style.opacity = i/100;
		this.obj.style.filter = 'alpha(opacity='+i+')';
		if(i<= this.tarOpac){
			clearInterval(fadeOut_int);
			if(this.func){ this.func(); }
		}
	}
}
/* end of fade object */
overlay = function(url){
	if(browser == 'IE'){
		selects = document.getElementsByTagName('select');
		for(i=0;i<selects.length;i++){
			selects[i].style.visibility = 'hidden';	
		}
	}
	div = document.createElement('div');	
	div.setAttribute('id','overlay');
	document.body.appendChild(div);
	new fade('overlay',0,70,1,content,url);
}
content = function(url){
	div2 = document.createElement('div');
	div2.setAttribute('id','overlay_content');
	document.body.appendChild(div2);
	div2.style.opacity = 0;
	div2.style.filter = 'alpha(opacity=0)';
	loaded_content = new net.ContentLoader(url,'overlay_content');	
	myInt = setInterval("loadContent(loaded_content.data)",250);
}
loadContent = function(t){
	if(t != null){
		clearInterval(myInt);
		div = document.getElementById('overlay_content');
		div.style.margin = "-"+div.scrollHeight/2+'px  0 0 -'+div.scrollWidth/2+'px';
		if(browser == "IE"){
			new fade('overlay_content',0,100,1);
		}else{
			new fade('overlay_content',0,100,3);
		}
	}
}
closeContent = function(){
	if(browser == 'IE'){
		selects = document.getElementsByTagName('select');
		for(i=0;i<selects.length;i++){
			selects[i].style.visibility = 'visible';	
		}
	}
	if(browser == "IE"){
		new fade('overlay_content',100,0,1,closeBack);
	}else{
		new fade('overlay_content',100,0,3,closeBack);
	}
}
closeBack = function(){
	document.getElementById('overlay_content').innerHTML = "";
	document.body.removeChild(document.getElementById('overlay_content'));
	new fade('overlay',60,0,1,removeDiv);
}
removeDiv = function(){
	document.body.removeChild(document.getElementById('overlay'));
}
pleaseWait = function(t){
	t.value = "Submitting, Please Wait...";	
}
userUsername = function(t){
	if(document.add_member_form.user_username.value == ""){
		document.add_member_form.user_username.value = t.value;	
	}
}