function openWindow(type,param)
{
	//alert(type);	
	if (type == 'printReceipt')
	{
		url='/checkout/confirmOrder.phtml?p=1';
		options='toolbar=0,location=0,menubar=0,width=750,height=500'
		newWindow=window.open(url,'a',options);
		newWindow.print();
	}
	if (type == 'printReceiptOrderHistory')
	{
		url='/myaccount/viewOrder.phtml?p=1&order_id='+param;
		options='toolbar=0,location=0,menubar=0,width=750,height=500'
		newWindow=window.open(url,'a',options);
		newWindow.print();
	}
	if (type == 'shippingRequest')
	{
		url='/popup/shippingRequest.phtml';
		options='toolbar=0,location=0,menubar=0,width=650,height=600'
		newWindow=window.open(url,'a',options);
		//newWindow.print();
		//newWindow.Focus();
	}
	if (type == 'ccid')
	{
		url='/popup/ccid.phtml';
		options='toolbar=0,location=0,menubar=0,width=400,height=400'
		var newWindowTest=window.open(url,'newWindowTest',options);
		//newWindow.print();
		//newWindowTest.Focus();
		return false;
	}
	
}


function change_options(pin,selected_value,cart_id,position)
{
	
	f=document.forms['cartUpdateMain'];
	f.active_position.value=position;		
	cart_id=f.active_cart_id.value;
	next_position=position+1;	
	if (selected_value != 0)
	{
		
	  	
	    if (f.elements['option_' + cart_id + '_' + next_position])
	    {	
		  	url="/cart/ajax_output.phtml?pin=" + pin + "&current_selection=" + selected_value + "&pos="+position;
				
			http.open("GET", url, true);
	
	  		http.onreadystatechange = handleHttpResponseOptions;
	
	  		http.send(null);
	    }	
	}
	else
	{
		if (f.elements['option_' + cart_id + '_' + next_position])
			f.elements['option_' + cart_id + '_' + next_position].length=1;
		
		
	}
	return;

		
}
function handleHttpResponseOptions() 
{
	
	if (http.readyState == 4) 
  	{

    	f=document.forms['cart'];
    	pos=f.active_position.value;
    	next_pos=pos+1;
    	
    	cart_id=f.active_cart_id.value;
    	
    	//alert(f.active_cart_id.value);
		available_options=http.responseText;
		//alert(available_options);
		active_selectbox=f.elements['option_' + cart_id + '_' + next_position];
		temp=available_options.split("!!");
		active_selectbox.options.length=temp.length-1;
		//active_selectbox.options[0]=new Option("","");
		for (i=1;i<temp.length;i++)
		{
			current_offset=i-1;
			active_selectbox.options[i] = new Option(temp[current_offset],temp[current_offset])
			
			
		}
		//alert(available_makes);
		
		//var root_node = available_makes.getElementsByTagName('make').item(2);
		/*
		f.elements['make'].options.length = available_makes.getElementsByTagName('make').length+1;
		f.elements['make'].options[0] = new Option("", "")
		for (i=1;i<available_makes.getElementsByTagName('make').length+1;i++)
		{	
			var root_node = available_makes.getElementsByTagName('make').item(i-1);
			f.elements['make'].options[i] = new Option(root_node.firstChild.data, root_node.firstChild.data)
			//alert(root_node.firstChild.data);
		}
		if (f.elements['make'].value == '')
		{

			f.elements['model'].options.length = 1;
			f.elements['model'].options[0] = new Option("", "")

		}
		*/
    

  }

}	
function getHTTPObject() {

  var xmlhttp;

  /*@cc_on

  @if (@_jscript_version >= 5)

    try {

      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    }

  @else

  xmlhttp = false;

  @end @*/

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

    try {

      xmlhttp = new XMLHttpRequest();

    } catch (e) {

      xmlhttp = false;

    }

  }

  return xmlhttp;

}

var http = getHTTPObject(); // We create the HTTP Object

function verify_quantities(f)
{
	for(i=0;i<f.elements.length;i++)
	{
//		if (f.elements[i].name)
//			alert(f.elements[i].name.substring(0,7));
		if (f.elements[i].type == 'text' && f.elements[i].name.substring(0,8) == 'cart_qty')
		{
			
			var quantity_reg_exp=/^\d{1,}$/
			if (quantity_reg_exp.exec(f.elements[i].value) == null)
			{
				alert("Please enter a number for quantity.");
					
				f.elements[i].focus();
				return false;
			}
			if (f.elements[i].value == 0)
			{
				alert("Please enter a quantity above zero.");
				f.elements[i].focus();
				return false;
			}
			
		}	
		
		
	}
	f.action2.value='update_quantities';
	f.submit();
	
	
}	

