
// General

function showIfHidden(id, millisec) {
  if(document.getElementById(id).style.opacity == null || document.getElementById(id).style.opacity == 0) {
	changeOpacity(id,0);
	document.getElementById(id).style.visibility = 'visible';
    opacityFade(id, 0, 100, millisec);
  }
} 

function opacityFade(id, opacStart, opacEnd, millisec) {
  var speed = Math.round(millisec / 100);
  var timer = 0;
  if(opacStart > opacEnd) {
    for(i = opacStart; i >= opacEnd; i--) {
      setTimeout("changeOpacity('" + id + "'," + i + ")",(timer * speed));
      timer++;
    }
  } else if(opacStart < opacEnd) {
    for(i = opacStart; i <= opacEnd; i++)
    {
      setTimeout("changeOpacity('" + id + "'," + i+ ")",(timer * speed));
      timer++;
    }
  }
}

function changeOpacity(id,opacity) {
	var s = document.getElementById(id).style;
	s.opacity = opacity/100;
	s.MozOpacity = opacity/100;
	s.KhtmlOpacity = opacity/100;
	s.filter = 'alpha(opacity='+opacity+')';
}



// AGE CHECK....

function openlegal(url)
{
	var pop = window.open(url, "LEGAL", "width=500,height=400,scrollbars=1,resizable=1,menubar=0");
	pop.focus();
}



// JOIN NOW functions...

var selectedCharacter=null;
var selectedCliche=null;
var clicheIDs = new Array();

function joinnowPreload(character,language) {
	temp1 = new Image();
	temp1.src = 'images/ring_'+character+'_hover.jpg';
	temp2 = new Image();
	temp2.src = 'images/ring_'+character+'_selected_'+language+'.jpg';
}

function ringNormal(language) {
	if(selectedCharacter==null)	document.getElementById('ring').src='images/ring.jpg';
	else						document.getElementById('ring').src='images/ring_'+selectedCharacter+'_selected_'+language+'.jpg';
}

function ringHover(character) {
	if(selectedCharacter==null)	document.getElementById('ring').src='images/ring_'+character+'_hover.jpg';
}

function ringSelect(character,language) {
	selectedCharacter = character;
	selectedCliche = null;
	document.getElementById('ring').src='images/ring_'+selectedCharacter+'_selected_'+language+'.jpg';
	document.getElementById('joinnow_cliches_instructions').style.display = 'none';
	//changeOpacity('joinnow_cliches_instructions', 100);
	document.getElementById('joinnow_cliches_selection').style.visibility = 'visible';
	for(var i=0; i<clicheIDs.length; i++) {
		document.getElementById('cliche_text_line_'+clicheIDs[i]).style.visibility = 'hidden';
		changeOpacity('cliche_text_'+clicheIDs[i],100);
	}
	if(character != 'a') document.getElementById('cliche_list_a').style.display = 'none';
	if(character != 'b') document.getElementById('cliche_list_b').style.display = 'none';
	if(character != 'c') document.getElementById('cliche_list_c').style.display = 'none';
	if(character != 'd') document.getElementById('cliche_list_d').style.display = 'none';
	if(character != 'e') document.getElementById('cliche_list_e').style.display = 'none';
	if(character != 'f') document.getElementById('cliche_list_f').style.display = 'none';
	document.getElementById('cliche_list_'+character).style.display = 'block';
	document.getElementById('joinnow_cliches_join').style.visibility = 'hidden';
}

function clicheSelect(id) {
	selectedCliche = id;
	for(var i=0; i<clicheIDs.length; i++) {
		if(clicheIDs[i] != id) {
			document.getElementById('cliche_text_line_'+clicheIDs[i]).style.visibility = 'hidden';
			changeOpacity('cliche_text_'+clicheIDs[i],40);
		}
	}
	document.getElementById('cliche_text_line_'+id).style.visibility = 'visible';
	changeOpacity('cliche_text_'+id,100);
	document.getElementById('joinnow_cliches_join').style.visibility = 'visible';
	document.getElementById('joinnow_cliche_id').value = id;
}

function clicheMouseOver(id) {
	document.getElementById('cliche_text_line_'+id).style.visibility = 'visible';
}

function clicheMouseOut(id) {
	if(id == selectedCliche) return;
	document.getElementById('cliche_text_line_'+id).style.visibility = 'hidden';
}

function submitStatement() {
	if(selectedCliche && selectedCharacter) {
		document.getElementById('form').submit();
	}
}






// Home Teaser...

function showTeaser() {
	document.getElementById('start_nolabeltaskforce').src='images/start_nolabeltaskforce_hover.jpg';
}

function hideTeaser() {
	document.getElementById('start_nolabeltaskforce').src='images/start_nolabeltaskforce.jpg';
}

function startPreload() {
	temp1 = new Image();
	temp1.src = 'images/start_nolabeltaskforce_hover.jpg';
}

// Browser detect...

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	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.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.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// 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();
