// Copyright Acro Media Inc. 1998-2006, www.acromediainc.com

function copyrightYear(){
	if(document.getElementById('insertYear')) document.getElementById('insertYear').innerHTML = new Date().getFullYear();
}


function externalLinks(){
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external") anchors[i].target = "_blank";
	}
}



//Checks to see if safari is on, boolean
var detect = navigator.userAgent.toLowerCase();
var safStatus,thestring;
function checkSafari(){
	if (checkIt('safari')) safStatus = true;
	else safStatus = false;
	function checkIt(string){
		place = detect.indexOf(string) + 1;
		return place;
	}
}


siteOnLoad = function (){
	checkSafari();
	copyrightYear();
	externalLinks();
	replaceBox.init();
}

function addLoadEvent(func){
	var oldOnLoad = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}
	else{
		window.onload = function(){
			oldOnLoad();
			func();
		}
	}
}

function fillNeededInformation(){
	var elem;
	elem = document.getElementById('billToPostal');
	if(elem){
		elem.value = document.getElementById('mailPostal').value;
	}
	elem = document.getElementById('billToAddress');
	if(elem){
		elem.value = document.getElementById('mailAddress').value;
	}
}

addLoadEvent(siteOnLoad);


var replaceBox = {
	indicator: "jsReplace",
	inactive: "inputDead",
	init: function (){
		var allInputs = document.getElementsByTagName('input');
		for(var x = 0; x < allInputs.length; x++){
			if(allInputs[x].className && allInputs[x].className.indexOf(this.indicator) > -1){
				var obj = allInputs[x];
				obj.initialCSS = obj.className;
				obj.className = obj.initialCSS + " " + this.inactive;
				obj.initialString = obj.value;
				obj.onfocus = replaceBox.focus;
				obj.onblur = replaceBox.blur;
			}
		}
	},
	blur: function (){
		if(this.value == ""){
			this.value = this.initialString;
			this.className = this.initialCSS + " " + replaceBox.inactive;
		}
	},
	focus: function (){
		if(this.value == this.initialString){
			this.value = "";
			this.className = this.initialCSS;
		}
	}
}

/** clears a users login cookies.
*/
function clearLoginCookies(){
	setCookie('phpbb2mysql_sid', '', 0, '/', '');
	setCookie('phpbb2mysql_data', '', 0, '/', '');
}

/** sets a cookie with the provided values.
*/
function setCookie(name, value, expires, path, domain, secure){
	var curCookie = name + "=" + escape(value) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

/** retrieve a cookie
*/
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = 0 + dc.indexOf(prefix);
	if (begin == -1){
		return 0;
	}
	begin += prefix.length;
	var end = 0 + document.cookie.indexOf(";", begin);
	if (end == -1){
		end = dc.length;
	}
	return unescape(dc.substring(begin, end));
}


function submitMultiple(){
	var event = document.getElementById("event");
	var eventChoices = document.getElementById("eventChoices");
	var downloadFile = document.getElementById("downloadFile");
	var priceCont = document.getElementById("priceCont");
	var price = document.getElementById("price");
	var conferenceDate = document.getElementById("conferenceDate");

	if((event) && (eventChoices)){
		if(downloadFile){
			if(eventChoices.options[eventChoices.selectedIndex].value.indexOf("MP3") < 0){
				downloadFile.value = "";
			}
		}
		if((priceCont) && (price)){
			var prices = priceCont.getElementsByTagName("input");
			price.value = prices[eventChoices.selectedIndex].value;
		}
		event.value = eventChoices.options[eventChoices.selectedIndex].value;
		if(conferenceDate){
			if(conferenceDate.style.display != "none"){
				event.value += " "+ conferenceDate.options[conferenceDate.selectedIndex].value;
			}
		}
	}
	document.forms.pay.submit();
}

function toggleDates(option){
	var conferenceDate = document.getElementById("conferenceDate");
	if(conferenceDate){
		if(option.indexOf("Audio") > 0){
			conferenceDate.style.display = "";
		}
		else{
			conferenceDate.style.display = "none";
		}
	}
}