// Nav Menu
function sad_browser() {
		open('update_browser.php');
}

// New Rollover
function tdRoll(e,state) {
//    e.style.backgroundColor = state?'#E6e6e6':'#ffffff';
//    e.style.color = state?'#CCCC99':'#707070';
//    e.style.backgroundColor = state?'#CCCC99':'#ffffff';
    e.style.backgroundColor = state?'#d77d6b':'#ffffff';
    e.style.color = state?'#000000':'#707070'; 
}

function draw_div(menu_name, on_off) {
	if (document.getElementById(menu_name)) { // DOM3 = IE5, NS6
		 div_obj = document.getElementById(menu_name);
		 div_obj.style.visibility = on_off;
	} else if (!document.getElementById){
		sad_browser();
	}
}

function show_layer(name,elements,element_set){
	for(i=1;i<=elements;i++){
		tmp = element_set + i;
		if ( tmp == name){
			draw_div(name, 'visible');
		} else {
			draw_div(tmp, 'hidden');
		}
	}
}

// Image Preloader
function preloadImages() {
  var preImages=new Array();
  var tmp;
	for (i=0; i < preloadImages.arguments.length; i++){
      preImages[i]=document.createElement('img');
//		preImages[i]=new Image()
		preImages[i].src=preloadImages.arguments[i]
	}
}

// Window Popup
function popupWin(page, width, height) {
	winprops = "toolbar=0,status=1,scrollbars=1,resizable=1,width=" + width + ", height=" + height;
	popup = window.open( page, "popup", winprops);
	popup.focus();
//   return true;
}

function popupWinReturn(page, width, height) {
	winprops = "toolbar=0,status=1,scrollbars=1,resizable=1,width=" + width + ", height=" + height;
	popup = window.open( page, "popup", winprops);
	popup.focus();
   return true;
}



// Only allow numbers, return, and backspace in a text field.  Usage: onKeyPress="return only_numbers(event);"
function only_numbers(event) {
	var key;
	if (window.event) {
		key = window.event.keyCode;
	} else if (event) {
		key = event.which;
	} else {
		return true;
	}
	if(key >= 48 && key <= 57 || key == 8 || key == 13) {
		return true;
	} else {
		return false;
	}
}

// Image Swapper
function glow(img) {
  if (window.glowing) deglow();
	img.src=img.src.replace('_off','_on'); 
	window.glowing=img;
}

function deglow(){ 
	if (!window.glowing) return;
	glowing.src=glowing.src.replace('_on','_off'); 
	glowing=null;
}

function newWindow(page, width, height, scrollb) {
	winprops = "location=no,menubar=no,toolbar=no,status=no,scrollbars=" + scrollb + ",resizable=yes,marginwidth=0,marginheight=0,width=" + width + ", height=" + height;
	popup = window.open(page,"popup", winprops);
	popup.focus();
	
    return false;
}

function setText() {

	var now = new Date;
	var tagSeconds = now.getSeconds();
	
	var tagImage = '';
	var tagSize = '';
	var tagText = '';
	for (i=0; i<Form2.radImage.length; i++) {
		if (Form2.radImage[i].checked) {
			tagImage = Form2.radImage[i].value;
			switch (i) {
				case 0:
				tagSize = 'width="300" height="60"';
				break;
				case 1:
				tagSize = 'width="300" height="60"';
				break;
				case 2:
				tagSize = 'width="100" height="60"';
				break;
				default:
				tagSize = '';
				break;
			}
		}
	}
	if (tagImage == '') {
		alert('No image selected, please select an image');
		return false;
	}
	if (tagSeconds >= 0 && tagSeconds < 30) {
		tagText = '<a href="http://www.victor-garber.com/"><img src="' + tagImage + '" ' + tagSize + ' border="0" alt="www.victor-garber.com" title="www.victor-garber.com" /></a>';
	}
	if (tagSeconds >= 30 && tagSeconds < 60) {
		tagText = '<a href="http://www.victor-garber.com/"><img src="' + tagImage + '" ' + tagSize + ' border="0" alt="VICTOR GARBER - UnOfficial Website" title="VICTOR GARBER - UnOfficial Website" /></a>';
	}
		
	Form2.strAltText.value = tagText;
}