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

// Show and Hide the Sections of <UL> and Help Bubbles on the Page
var dirDepth = "/";
var currentVisible = "";
var helpBubbleVisible = "";

function setVisible(section) {
	if(currentVisible){
		document.getElementById(currentVisible).style.display="none";
	}
	document.getElementById(section).style.display="block";
	currentVisible = section;
}

function wordsCheck_Vis() {
	if(document.getElementById('add_comment').style.display == "none"){
		document.getElementById('add_comment').style.display = "block";
		}
	else {
		document.getElementById('add_comment').style.display = "none";		
		}
	}

function showBubble(section) {
	if(helpBubbleVisible){
		document.getElementById(helpBubbleVisible).style.display="none";
	}
	document.getElementById(section).style.display="block";
	helpBubbleVisible = section;
}

// Show and Hide Sections of the Page
var Element = {
	check : function (target) {
		document.getElementById(target).checked=true;
	},
	uncheck : function (target) {
		document.getElementById(target).checked=false;
	},
	show : function (target) {
		document.getElementById(target).style.display='block';
	},
	show2: function (target) {
		document.getElementById(target).style.display='block';
	},
	hide : function (target) {
		document.getElementById(target).style.display='none';
	},
	change : function(target, text){
		document.getElementById(target).innerHTML = text;
	}
}

function onOver(){
	this.src = imgOvers[this.number].src;
}
function onOut(){
	this.src = imgOuts[this.number].src;
}

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

function externalLinks() {
	if(!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.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();
}

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

addLoadEvent(siteOnLoad);

function formatCurrency(amount){
	var i = parseFloat(amount);
	if(isNaN(i)){ i = 0.00; }

	var minus = '';
	if(i < 0){ minus = '-'; }

	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;

	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;

	return s;
}

/*-------------------------------------
|	Toggle Checkbox (hidden radios)
+------------------------------------*/
function toggleBox(setCheck, feature) {
	if(setCheck.checked == true) {
		document.getElementById(feature).value = "yes";
	}
	else {
		document.getElementById(feature).value = "no";
	}
} //toggleBox


//Change which thankyou page the user goes to, depending on selected package.
function thanksChange(thanksVal) {
	if (thanksVal == "toUpload") {
		document.getElementById('thanksPage').value = "/tm_wizard_thankyou_up.htm";
	}
	if (thanksVal == "noUpload") {
		document.getElementById('thanksPage').value = "/tm_wizard_thankyou.htm";
	}
}

//Change which thankyou page the user goes to, depending on selected package. [For Copyright]
function thanksChangeCR(thanksVal) {
	if (thanksVal == "toUpload") {
		document.getElementById('thanksPage').value = "/wizard_thankyou_up.htm";
	}
	if (thanksVal == "noUpload") {
		document.getElementById('thanksPage').value = "/wizard_thankyou.htm";
	}
}

//6.x IE FlyOver Fixaroo
sfHover = function() {
  if(typeof(document.getElementById("navTabs"))!= "undefined" && document.getElementById("navTabs") != null){
  	var sfEls = document.getElementById("navTabs").getElementsByTagName("LI");
  	for (var i=0; i<sfEls.length; i++) {
  		sfEls[i].onmouseover=function() {
  			this.className+=" sfhover";
  		}
  		sfEls[i].onmouseout=function() {
  			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
  		}
  	}
  }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);




// Create a select box with the a start and end year
function createSelectYear(divID, startYear, endYear, name, selectID, selectClass, elementStyle){
	if(endYear == "currentYear"){
		var d=new Date();
		endYear = d.getFullYear();
	}
	var output = "";
	output += "\n<select name=\"" + name + "\" id=\"" + selectID + "\" class=\"" + selectClass + "\" style=\"" + elementStyle + "\">\n";
	for(i=endYear; i>=startYear; i--){
		output += "\t<option value=\""+ i +"\">" + i + "</option>\n";
	}
	output += "</select>\n";
	document.getElementById(divID).innerHTML = output;
}

/*
	<img src="https://www.emjcd.com/u?AMOUNT=<AMOUNT>&CID=<ENTERPRISEID>&OID=<OID>
	&TYPE=<ACTIONID>&CURRENCY=<CURRENCY>&METHOD=IMG" height="1" width="20">
*/
function tracker(){
	var imgTracker = document.getElementById("CJ");
	var typeID = document.getElementById("typeID");
	var amount = document.getElementById ("workingAmount");
	var orderID = document.getElementById ("workingOrderID");
		
	imgTracker.src = "https://www.emjcd.com/u?AMOUNT=" + amount.value + "&CID=1507252&OID=" + orderID.value + "&TYPE=" + typeID.value + "&CURRENCY=USD&METHOD=IMG";		
}
