// JavaScript Document
// quick procemethods for simple div toggling
// by Joe Melberg - Techism.com
// uses script.acul.us and dollar functions

var jm_fastfade_current ="image_space";

function jm_fastfade(to) {
			oFrom = $(jm_fastfade_current);
			oTo = $(to);
			//alert ("from " + oFrom + "oTo " + oTo);
			oTo.style.display = "block";
			new Effect.Parallel([new Effect.BlindUp(oFrom ,{sync:true}),new Effect.BlindDown(oTo,{sync:true})]);
			jm_fastfade_current = oTo;
}

var newWindow;
function viewNewWindow(url,height, width) {
	newWindow=window.open(url,'name','height=' + height +',width=' + width + ',resizable=yes,scrollbars=yes');
	if (window.focus) { 
		newWindow.focus()
	}
}
function printNewWindow(url) {
	newWindow=window.open(url,'name','height=640,width=800,resizable=yes,scrollbars=yes');
	if (window.focus) {
		newWindow.focus()
	}
	newWindow.print();
}

function calculateGrandTotal(total) {
	var grandTotal;
	
	gratuity = parseFloat(document.getElementById("checkoutFinalize_GRATUITY").value);
	if(gratuity < 0) gratuity = -(gratuity);
	grandTotal = total + gratuity;
	document.getElementById("checkoutFinalize_GRANDTOTAL").value = grandTotal.toFixed(2);
}

// Clears a form after confirmation, 
// and returns focus to first element
function clearForm(form) {
	
	if(confirm("Are you sure you want to clear this form?")) {	 
		var i, j; 
		var first_text;
		// go through the entire Form Object
		for (i = 0; i < form.length; i++) {
		  //alert('form.elements[' + i + '] \n\n' + '<INPUT TYPE="' + form.elements[i].type + '">');

	    // if the element isn't a button, hidden, submit, or reset then set the VALUE to ""
	    if (form.elements[i].type != 'button' && form.elements[i].type != 'hidden' &&
	          form.elements[i].type != 'submit' && form.elements[i].type != 'reset') {
	          form.elements[i].value = "";
	
						if(!first_text) first_text = form.elements[i].id;
      }
	    // if the element is a radio button or a checkbox then uncheck the Object if it is checked
	    if (form.elements[i].type == 'radio' || form.elements[i].type == 'checkbox')
	          form.elements[i].checked = false;

	    // if the element is a select Object then assign it new text values
		  // if (form.elements[i].type == 'select-one' || form.elements[i].type == 'select-multiple') {
		  //  	 for (j = 0; j < form.elements[i].length; j++) {
		  //    	   form.elements[i].options[j].text = " Item 1" + j + " ";
		  //     }
		  //  	 form.elements[i].options[0].selected = true; 
		  // }
		}                               
		// remove all inline errors
		var errors = $$('div.error');
		errors.each(function(elem){
			//call helper function to do other cool stuff
		  //elem = updateElementWithCoolStuff(elem);
			//elem.invoke('removeClassName','error');
			elem.remove();
		});
		// Return focus to first element
		$(first_text).activate(); //alert(first_text);
	} 
}


  


    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        map.setUIToDefault();
      }
    }


