// JavaScript Document

  function RefreshCheckout() {
	
    var bval = document.checkout.billto.options[document.checkout.billto.selectedIndex].value;
    var sval = document.checkout.shipto.options[document.checkout.shipto.selectedIndex].value;
	var pval = 'costcenter'/*document.checkout.method.options[document.checkout.method.selectedIndex].value*/;
	
	var shval = null;
	
	for (i = 0; i < document.checkout.shipping.length; i++)
	{
		if (document.checkout.shipping[i].checked==true)
			shval = document.checkout.shipping[i].value;
	}
	
	var redir = "index.php?page=checkout&bill=" + bval + "&ship=" + sval + "&method=" + pval + "&sh=" + shval;
	
    window.location = redir;

  }
  
  
  function manageAddress() {
	  
	var type = document.typeselect.type.options[document.typeselect.type.selectedIndex].value;
	
	var redir = "index.php?page=manage&type=" + type;
	
	window.location = redir;
  }
  
  function cartcheck() {
	  
	var des = document.convert.destination.options[document.convert.destination.selectedIndex].value;
	var ex = document.convert.exchange.options[document.convert.exchange.selectedIndex].value;
	
	var redir = "index.php?page=cart&ex=" + ex + "&des=" + des;
	
	window.location = redir;
  }
  
  
  /* Hides and Displays Div Blocks for Pay Methods in Checkout */
  function togglePayMethod(element) {
	
	/* Sets Element1 and Element2 */
	if ( element == 'creditcard' ) {
		element1 = document.getElementById(element);
		element2 = document.getElementById('costcenter');
	}
	else {
		element1 = document.getElementById(element);
		element2 = document.getElementById('creditcard');
	}
	
	if ( element1.style.display != 'none' ) {
		element1.style.display = 'none';
		element2.style.display = 'block';
	}
	else {
		element1.style.display = 'block';
		element2.style.display = 'none';
	}
  }
  
  /* Hides and Displays Div Blocks for Order Details Account Information */
  function toggleOrders(element) {
	
	/* Resets all other orders to hide */
	var array = document.getElementsByTagName('div');
	var name, id, remove;
	for ( var i = 0; i < array.length; i++ ) {
		name = array[i].className;
		if ( name == 'detail' ) {
			id = array[i].id;
			remove = document.getElementById(id);
			/*remove	= document.getElement(remove);*/
			if ( id != element ) {
				remove.style.display = 'none';
			}
		}
	}
	
	/* Deals with element selected */
	element = document.getElementById(element);
	if ( element.style.display != 'none' ) {
		element.style.display = 'none';
	}
	else {
		element.style.display = 'block';
	}
  }
  
  function showSpan ( id ) {
	var element = document.getElementById ( 'top_' + id + '_show' );
	element.style.display = 'block';
  }
  
  function hideSpan ( id ) {
	var element = document.getElementById ( 'top_' + id + '_show' );
	element.style.display = 'none';
  }
  

	/***********************************************
	* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
	* This notice MUST stay intact for legal use
	* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
	***********************************************/
	
	/* Modified to support Opera */
	function bookmarksite(title,url){
		if (window.sidebar) // firefox
			window.sidebar.addPanel(title, url, "");
		else if(window.opera && window.print){ // opera
			var elem = document.createElement('a');
			
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();
		} 
		else if(document.all) // ie
			window.external.AddFavorite(url, title);
	}
