function openPrintable() 
{
	popup = window.open("printable.htm", "popup", "width=800,height=600,scrollbars=yes,menubar=yes");
} 
	
// Button Rollovers
function goLite(FRM,BTN)
{
   window.document.forms[FRM].elements[BTN].style.color = "#a1c27e";
   window.document.forms[FRM].elements[BTN].style.borderColor = "#a1c27e";
}

function goDim(FRM,BTN)
{
   window.document.forms[FRM].elements[BTN].style.color = "#ffffff";
   window.document.forms[FRM].elements[BTN].style.borderColor = "#d6d6d6";
}

// NAV ROLLOVERS
	function r_closelast(){
		document.lastM.style.visibility='hidden' ;
		document.lastMB.style.visibility='hidden' ;
		document.lastMH.style.visibility='hidden' ;}
		
	function r_openmenu(name){
		if(document.lastM){
			if(document.lastM!=document.getElementById(name)) document.getElementById(name+"Highlight").style.top=0 ;
			r_closelast() ;}
		menu=document.getElementById(name) ;
		menu.style.visibility='visible' ;
		var divs=menu.childNodes ;
		var icntr=0 ;
		for(i=0;i<divs.length;i++){
			if(divs[i].className=="menuI"){
				divs[i].style.top = icntr*24 ;
				icntr++ ;}}
		menu.style.height=icntr*24 ;
		document.getElementById(name+"Back").style.visibility='visible' ;
		document.getElementById(name+"Highlight").style.visibility='visible' ;
		document.lastM=menu ;
		document.lastMB=document.getElementById(name+"Back") ;
		document.lastMH=document.getElementById(name+"Highlight") ;}
		
	function r_menuitem(index){
		document.lastM.style.visibility='visible' ;
		document.lastMB.style.visibility='visible' ;
		var divs=document.lastM.childNodes ;
		var icntr=0 ;
		for(i=0;i<divs.length;i++){
			if(divs[i].className=="menuI"){
				icntr++ ;
				if(index==icntr){
					//Found clicked item...
					document.lastMH.style.top=parseInt(divs[i].style.top) ;}}}}
					
	// function r_highlight(name, updown)
		// {document.getElementById(name).src="images/top-"+updown+".gif" ;}
		
	function r_highlight(name, updown){
		if (updown == "up") document.getElementById(name).src=document.getElementById(name).src.replace("down","up");
		else document.getElementById(name).src=document.getElementById(name).src.replace("up","down");}

function open_window(url)
		{			
		var logpage = '';
		eval("logpage = window.open(url, 'Display1', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0, width=658, height=410, left=300,top=200');");	  
		}
function open_window2(url)
		{			
		var logpage = '';
		eval("logpage = window.open(url, 'Display1', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0, width=658, height=410, left=300,top=200');");	  
		}
		
		
		
	function clickButton(btn) {
		if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
			document.getElementById(btn).click();
			return false;
		} 
    	else return true;
	}

	function viewPhoto(id, width, height, title)
   {
      if (id != "0") {
      view = window.open("viewer.htm?id="+id, id, "width="+width+",height="+height+",scrollbars=no,toolbar=no,status=no,resizable=no,menubar=no,location=no");
      view.focus();
      }
   }
 
function showPhoto(obj_photo,id,width,height,text) {
	document.getElementById(obj_photo).src = "../photos/display.aspx?"+id+"_360_0.jpg";
	document.getElementById(obj_photo).alt = text;
	document.getElementById(obj_photo).parentNode.href = "../photos/display.aspx?"+id+"_" + width + "_" + height + ".jpg";
	
	if (document.getElementById('fv_photos_lbl_image_title'))
        document.getElementById('fv_photos_lbl_image_title').innerText = text;
}

function showRelatedPhoto(obj_photo,id,width,height,text) {
	while(obj_photo.indexOf(":") > -1) {
		obj_photo = obj_photo.replace(':','_');
	}
	document.getElementById(obj_photo).src = "../photos/display.aspx?"+id+"_138_0.jpg";
	document.getElementById(obj_photo).alt = text;
	document.getElementById(obj_photo).parentNode.href = "javascript:viewPhoto(" + id + "," + width + "," + height + ",'" + text + "');";
}

   function setCost() {		
	var id = setCost.arguments[1].replace(":", "_").replace(":", "_").replace(":", "_");
		document.getElementById(id).innerHTML =  setCost.arguments[setCost.arguments[0].selectedIndex + 2];
		   
   }
   
   function jumpGroup(obj) {
	 document.location.href = "catalog.aspx?group="+obj.options[obj.selectedIndex].value;
   }




function showPreOrder() {
	alert('This item is a pre-order. Items offered for pre-order are in high demand, but by reserving yours you are guaranteed to be the first to own it. Your credit card will not be charged until it ships. The delivery date for pre-orders varies and is only an estimate. Please check the item\'s description for more information.');
}



function showSwatchTitle(title, space) {
	if (title == "") {
		document.getElementById("swatch_title").innerHTML = "&nbsp;";
	}
	else {
		space = 44 * space;
		image = "<img src='../images/blank.gif' height='2' width='"+space+"'>";
		document.getElementById("swatch_title").innerHTML = "&nbsp;"+image+"<span class='alert'>"+title+"</span>";
	}
}

function showPhotoTitle(title) {
	if (title == "") {
		document.getElementById("photo_title").innerHTML = "&nbsp;";
	}
	else {
		document.getElementById("photo_title").innerHTML = "&nbsp;<span class='alert'>"+title+"</span>";
	}
}
function emailPageLink() {
	urlAddress = window.location.href;
	pageName = document.title;
	
	efpopup = window.open("http://linux.virtualatlantic.com/common/pk_emailfriend.php?url="+urlAddress+"&title="+pageName, "efpopup", "width=400,height=300,scrollbars=no,menubar=no");
}

function openWindow(url,win)
{
  view = window.open(url, "", win);
  view.focus();
}

function hov(loc,cls)
{
if(loc.className)
  loc.className=cls;
}

// JavaScript Document
function validateForm(val_form) {
  validated = true;
  
  arr_fields = val_form["va_fields"].value.split(";");

  i=0;
  while (i < arr_fields.length)
  {
    arr_field = arr_fields[i].split(":");
	this_field = arr_field[0];
	
    if (((arr_field[2] == "text") && (val_form[this_field].value == "")) || ((arr_field[2] == "email") && ((val_form[this_field].value.indexOf(".") < 0) || (val_form[this_field].value.indexOf("@") < 0) || (val_form[this_field].value == "(name@domain.com)"))) || (arr_field[2] == "checkbox" && !val_form[this_field].checked)) {

	alert(arr_field[1] + " is required. This field must be validated before the form can be submitted.");
      val_form[arr_field[0]].focus();
      validated = false;
	  break;
    }
    i++;
  }
  return validated;
}

function validateLength(keywords) {
  validated = true;

  if (keywords.length < 3) {
    validated = false;
    alert("You must enter at least 3 characters!");
  }
  
  
  return validated;
}
  
