function bookmark() {
	if(window.sidebar) { window.sidebar.addPanel(document.title, document.location, ""); }
	else if(window.external) { window.external.AddFavorite(document.location, document.title); }
	else { alert("Your browser may not support javascript bookmarking."); }
}
function email(domain, article) {
	document.location = "mailto:?body=http://www." + domain + ".com/article/" + article;
}
function font() {
	if(document.getElementById('logoImg').value) { 
		if(document.getElementById('logoImg').value == 10) { document.getElementById('logoImg').value = 14; }
		else {
			if(document.getElementById('logoImg').value == 14) { document.getElementById('logoImg').value = 18; }
			else {
				document.getElementById('logoImg').value = 10;
			}
		}
	}
	else { document.getElementById('logoImg').value = 14; }
	document.getElementById('articleText').style.fontSize = document.getElementById('logoImg').value + "pt";
	return false;
}
function adjust() {
	var ht1 = document.getElementById('featuresBox').offsetHeight;
	var ht2 = document.getElementById('headlineBox').offsetHeight;
}
function printLog(thisArticle) {
	document.getElementById('recommendLink').src = "/recommend/print/" + thisArticle;
	return false;
}
function writeMail(user, domain, text, repeat) {
 	document.write('<a href="mailto:' + user + '@' + domain + '">');
	if(repeat == 1) {
 		document.write(user + '@' + domain);
	}
	else {
		document.write(text);
	}
  	document.write('</a>');
}
function frameBust() {
	if(document.location != top.location) {
		top.location = document.location;
	}
}
function checkForm() {
	switch(document.keypressForm.pressed.value) {
		case "38+": case "38+38+": case "38+38+40+": case "38+38+40+40+": case "38+38+40+40+37+": case "38+38+40+40+37+39+": case "38+38+40+40+37+39+37+": case "38+38+40+40+37+39+37+39+": case "38+38+40+40+37+39+37+39+66+": case "38+38+40+40+37+39+37+39+66+65+":
			break;
		case "38+38+40+40+37+39+37+39+66+65+13+":
			document.cookie='konami'+'=1';
			document.location="index.php";
		default:
			document.keypressForm.pressed.value = "";
			break;
	}
}
function keyPress(whichKey) { 
	arrows=((whichKey.which)||(whichKey.keyCode));
	document.keypressForm.pressed.value = document.keypressForm.pressed.value + arrows + "+";
	checkForm();
}
function checkSubForm() {
	var radioLength = document.forms['subForm'].elements['delivery'].length;
	for(var i = 0; i < radioLength; i++) {
		if(document.forms['subForm'].elements['delivery'][i].checked){ checkVal = document.forms['subForm'].elements['delivery'][i].value; }
	}
	if(checkVal != 'address') {
		document.forms['subForm'].submit();
	}
	else {
		if(document.forms['subForm'].elements['name'].value == "") {
			var bad = 1;
			document.getElementById('subForm_name').style.backgroundColor = "yellow";
			document.getElementById('name_alert').style.display = "inline";
		}
		if(document.forms['subForm'].elements['address'].value == "") {
			var bad = 1;
			document.getElementById('subForm_address').style.backgroundColor = "yellow";
			document.getElementById('address_alert').style.display = "inline";
		}
		if(document.forms['subForm'].elements['city'].value == "") {
			var bad = 1;
			document.getElementById('subForm_city').style.backgroundColor = "yellow";
			document.getElementById('citystatezip_alert').style.display = "inline";
		}
		if(document.forms['subForm'].elements['state'].value == "") {
			var bad = 1;
			document.getElementById('subForm_state').style.backgroundColor = "yellow";
			document.getElementById('citystatezip_alert').style.display = "inline";
		}
		if(document.forms['subForm'].elements['zip'].value == "") {
			var bad = 1;
			document.getElementById('subForm_zip').style.backgroundColor = "yellow";
			document.getElementById('citystatezip_alert').style.display = "inline";
		}
		if(bad != 1) {
			document.forms['subForm'].submit();
		}
	}
}


//Color fading script by Michael Leigeber.

// main function to process the fade request //
function colorFade(id,element,start,end,steps,speed) {
  var startrgb,endrgb,er,eg,eb,step,rint,gint,bint,step;
  var target = document.getElementById(id);
  steps = steps || 20;
  speed = speed || 20;
  clearInterval(target.timer);
  endrgb = colorConv(end);
  er = endrgb[0];
  eg = endrgb[1];
  eb = endrgb[2];
  if(!target.r) {
    startrgb = colorConv(start);
    r = startrgb[0];
    g = startrgb[1];
    b = startrgb[2];
    target.r = r;
    target.g = g;
    target.b = b;
  }
  rint = Math.round(Math.abs(target.r-er)/steps);
  gint = Math.round(Math.abs(target.g-eg)/steps);
  bint = Math.round(Math.abs(target.b-eb)/steps);
  if(rint == 0) { rint = 1 }
  if(gint == 0) { gint = 1 }
  if(bint == 0) { bint = 1 }
  target.step = 1;
  target.timer = setInterval( function() { animateColor(id,element,steps,er,eg,eb,rint,gint,bint) }, speed);
}

// incrementally close the gap between the two colors //
function animateColor(id,element,steps,er,eg,eb,rint,gint,bint) {
  var target = document.getElementById(id);
  var color;
  if(target.step <= steps) {
    var r = target.r;
    var g = target.g;
    var b = target.b;
    if(r >= er) {
      r = r - rint;
    } else {
      r = parseInt(r) + parseInt(rint);
    }
    if(g >= eg) {
      g = g - gint;
    } else {
      g = parseInt(g) + parseInt(gint);
    }
    if(b >= eb) {
      b = b - bint;
    } else {
      b = parseInt(b) + parseInt(bint);
    }
    color = 'rgb(' + r + ',' + g + ',' + b + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
    target.r = r;
    target.g = g;
    target.b = b;
    target.step = target.step + 1;
  } else {
    clearInterval(target.timer);
    color = 'rgb(' + er + ',' + eg + ',' + eb + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
  }
}

// convert the color to rgb from hex //
function colorConv(color) {
  var rgb = [parseInt(color.substring(0,2),16), 
    parseInt(color.substring(2,4),16), 
    parseInt(color.substring(4,6),16)];
  return rgb;
}