
function step(stepTo) {
	var form = document.register;
	switch (stepTo) {
		case "defaultlinks":
			form.submit();
			break;
		case "customlinks":
			form.submit();
			break;
		case "confirm":
			if (selectedLink.length == max_custom_links) {
				var submitLinks = "";
				for (var k = 0; k < selectedLink.length; k++) {
					if (k > 0) {submitLinks += "|";}
					submitLinks += selectedLink[k];
				}
				form.hiddenLinks.value = submitLinks;
				form.submit();
			} else {
				alert("Please select "+max_links+" custom links before pressing Continue.");
			}
			break;
		case "email":
			form.submit();
			break;
		case "register":
			if (form.email.value == "") {
				alert("Your email address is required.");
			} else {
				var validate = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				if (validate.test(form.email.value)) {form.submit();}
				else {alert("The email address provided is invalid.");}
			}
			break;
	}
}
function updateColor(selectedColor) {
	var form = document.register;
	if (selectedColor == "") {var name = form.color.value;}
	else {var name = selectedColor;}
	form.hiddenColor.value = form.color.value;
	document.getElementById('previewLogo').src = 'http://www.getfrog.com/'+dbimage+color[name];
	document.getElementById('previewHex').style.backgroundColor = '#'+hex[name];
}
function lockMenu(box, menu) {	
	var checkbox = document.getElementById(box);
	var dropdown = document.getElementById(menu);
	if (checkbox.checked) {dropdown.disabled = true;}
	else {dropdown.disabled = false;}
}
function resetPreviewLinks() {
	for (var j = total_default; j < 9; j++) {
		var icon = document.getElementById('link_'+j);
		if (name = selectedLink[j-total_default]) {
			if (thisStep == "customlinks") {
				var displayIcon = '<a href="javascript:removeLink(\''+name+'\')"><img src="http://www.getfrog.com/'+dbimage+customLink[name]+'" alt="" title="Click to Remove" width="55" height="50" border="0"></a>';
			} else {
				var displayIcon = '<img src="http://www.getfrog.com/'+dbimage+customLink[name]+'" alt="" width="55" height="50" border="0">';
			}
			icon.innerHTML = displayIcon;
		} else {
			icon.innerHTML = '<img src="http://www.getfrog.com/'+dbimage+'link_240w_BLANK.jpg" alt="" width="55" height="50" border="0">';
		}
	}
}
function resetSelectedLinks() {
	for (var j = 0; j < selectedLink.length; j++) {
		var name = selectedLink[j];
		for (var i = 0; i < categoryOption.length; i++) {
			var category = categoryOption[i];
			if (document.getElementById("ADD "+category+" "+name)) {
				hideLayer("icon_ADD "+category+" "+name);
				showLayer("icon_REMOVE "+category+" "+name);
				hideLayer("link_ADD "+category+" "+name);
				showLayer("link_REMOVE "+category+" "+name);
				hideLayer("ADD "+category+" "+name);
				showLayer("REMOVE "+category+" "+name);
			}
		}
	}
}
function addLink(name) {
	if (selectedLink.length == max_custom_links) {
		alert("You've selected the maximum "+max_links+" custom links!\nTo remove a link, click its icon in the live preview.");
	} else {
		selectedLink.push(name);
		for (var i = 0; i < categoryOption.length; i++) {
			var category = categoryOption[i];
			if (document.getElementById("ADD "+category+" "+name)) {
				hideLayer("icon_ADD "+category+" "+name);
				showLayer("icon_REMOVE "+category+" "+name);
				hideLayer("link_ADD "+category+" "+name);
				showLayer("link_REMOVE "+category+" "+name);
				hideLayer("ADD "+category+" "+name);
				showLayer("REMOVE "+category+" "+name);
			}
		}
		resetPreviewLinks();
	}
}
function removeLink(name) {
	for (var j = 0; j < selectedLink.length; j++) {
		if (name == selectedLink[j]) {selectedLink.splice(j,1)}
	}
	for (var i = 0; i < categoryOption.length; i++) {
		var category = categoryOption[i];
		if (document.getElementById("ADD "+category+" "+name)) {
			hideLayer("icon_REMOVE "+categoryOption[i]+" "+name);
			showLayer("icon_ADD "+categoryOption[i]+" "+name);
			hideLayer("link_REMOVE "+categoryOption[i]+" "+name);
			showLayer("link_ADD "+categoryOption[i]+" "+name);
			hideLayer("REMOVE "+categoryOption[i]+" "+name);
			showLayer("ADD "+categoryOption[i]+" "+name);
		}
	}
	resetPreviewLinks();
}

function changeTab(category) {
	for (var i = 0; i < categoryOption.length; i++) {
		var current = categoryOption[i];
		var tab = document.getElementById('TAB '+current);
		if (category == current) {
			showLayer('CAT '+current);
			tab.innerHTML = current;
			tab.style.backgroundColor = '#D1202A';
		} else {
			hideLayer('CAT '+current);
			tab.innerHTML = '<a href="javascript:changeTab(\''+current+'\')">'+current+'</a>';
			tab.style.backgroundColor = '#AE0F19';
		}
	}
}

function showLayer(whichLayer) {
	if (document.getElementById) {var style2 = document.getElementById(whichLayer).style;}	// standards
	else if (document.all) {var style2 = document.all[whichLayer].style;}					// old msie versions
	else if (document.layers) {var style2 = document.layers[whichLayer].style;}				// nn4
	style2.display = "inline";
}
function hideLayer(whichLayer) {
	if (document.getElementById) {var style2 = document.getElementById(whichLayer).style;}	// standards
	else if (document.all) {var style2 = document.all[whichLayer].style;}					// old msie versions
	else if (document.layers) {var style2 = document.layers[whichLayer].style;}				// nn4
	style2.display = "none";
}

function postload(imageArray) {
	for (var i in imageArray) {
		var imageObj = new Image();
		imageObj.src = dbimage+imageArray[i];
	}
}

// --- CENTERED POPUP ----------------------------------------------------------- //

function copyright() {openPopWin('http://www.getfrog.com/library/copyright.htm', 520, 292,'','cen','cen');}

// Copyright 1999 - 2002 by Ray Stott, Pop-up Windows Script ver 2.0
// OK to use if this copyright is included
// Script is available at http://www.crays.com/jsc

var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = 5  // default, pixels from screen left to window left
  var d_winTop = 5   // default, pixels from screen top to window top
  winName = "popWin" + winCount++ //unique name for each pop-up window
  closePopWin()           // close any previously opened pop-up window
  if (openPopWin.arguments.length >= 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  if (openPopWin.arguments.length == 6)  // location specified
    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
  else
    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
  popWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures)
}
function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
}
function getLocation(winWidth, winHeight, winLeft, winTop){
  var winLocation = ""
  if (winLeft < 0)
    winLeft = screen.width - winWidth + winLeft
  if (winTop < 0)
    winTop = screen.height - winHeight + winTop
  if (winTop == "cen")
    winTop = (screen.height - winHeight)/2 - 20
  if (winLeft == "cen")
    winLeft = (screen.width - winWidth)/2
  if (winLeft>0 & winTop>0)
    winLocation =  ",screenX=" + winLeft + ",left=" + winLeft + ",screenY=" + winTop + ",top=" + winTop
  else
    winLocation = ""
  return winLocation
}

// ------------------------------------------------------------------------------ //