// Attach handler to window load event
Event.observe(window, 'load', init, false);

function init() {
  // Attach handler to form's submit event
  Event.observe('add_cart1', 'submit', loadCart);
}

function loadCart(e) 
	{
	  //var proceduresChecked = Form.getInputs("doctorForm", "checkbox", "procedures[]").findAll(function(item) { return item.checked; }).pluck("value"); 
	  //var countriesChecked = Form.getInputs("doctorForm", "checkbox", "countries[]").findAll(function(item) { return item.checked; }).pluck("value");	  
	  //var pars = 'procedures=' + escape(proceduresChecked) + '&countries=' + escape(countriesChecked);	   
	  //var myAjax = new Ajax.Updater('response', 'ajaxServer.php', {method: 'get', parameters: pars});
	  //http://www.preseo.com/products2/cart.php?color=Full_Color_Front,_Black_Back**0*0*0*0*0*0*0**0*0*0*0*0*0*0**0*0*0*0*0*0*0**0*0*0*0*0*0*0&paper=14_PT**0*0*0*0*0*0*0**0*0*0*0*0*0*0**0*0*0*0*0*0*0**0*0*0*0*0*0*0&finishing=UV_Coated**24*38*54*109*164*219*274&turnaround=2-4_Biz_Days**0*0*0*0*0*0*0**0*0*0*0*0*0*0**0*0*0*0*0*0*0**0*0*0*0*0*0*0&quantity=1000&select_array=color,paper,finishing,turnaround,quantity&the_weight=0.07&price=34.29&action=put&stati=0&item_id=28&keep_count=5&the_markup=30&the_markup_type=1&rawdog=24&bigdog=34.285714285714285
	  //var pars = 'price=' + escape($F('paper'));
	  //var ele = form.getInputs()
	 //var ele = form.getInputs().pluck("value")
	 //var ele = form.getInputs('hidden').pluck("value");
	 //var ele = form.getInputs('text').pluck("value");
	 var ele = Form.serialize('add_cart1');	  
	 //var pars = 'address=' + escape($F('color'));	 
	 //var shot = $(input).getValue(); ;
	 //var ele = $F('color');
	 //alert(ele);
	 
	 Dialog.confirm({url: "saveCookie.php?"+ele+"", options: {method: 'get'}}, 
	 		{width:350, className: "alphacube", okLabel: "Checkout Now", cancelLabel:"Continue Shopping", ok:showCart, cancel: redirectPage})
	 
	 //Dialog.alert({url: "showCart.php", options: {method: 'get'}}, 
       //     {className: "alphacube", width:685, okLabel: "Close"});
	
	  Event.stop(e);
	}
	
function showCart()
	{
		//alert("opoen");
		Windows.closeAllModalWindows();
		
		//Dialog.alert({url: "showCart.php", options: {method: 'get'}}, 
       	  //{className: "alphacube", width:685, okLabel: "Cancel Order", ok: redirectPageSame});
		var win = new Window({className: "alphacube", title: "", zIndex:101, top:80, left:100, width:695, height:575, url: "https://www.preseo.com/products2/showCart.php", showEffectOptions: {duration:1.5}})
		win.showCenter();
	}

function redirectPage()
	{
		window.location = "http://www.preseo.com/"
		Windows.closeAllModalWindows();		
	}

function redirectPageSame()
	{
		window.location.reload()		
	}
