/*
  $Id: general.js 151 2005-08-02 14:33:25Z mattice $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2005 osCommerce

  Released under the GNU General Public License
*/

function updateDatePullDownMenu(objForm, fieldName) {
  var pdmDays = fieldName + "_days";
  var pdmMonths = fieldName + "_months";
  var pdmYears = fieldName + "_years";

  time = new Date(objForm[pdmYears].options[objForm[pdmYears].selectedIndex].text, objForm[pdmMonths].options[objForm[pdmMonths].selectedIndex].value, 1);

  time = new Date(time - 86400000);

  var selectedDay = objForm[pdmDays].options[objForm[pdmDays].selectedIndex].text;
  var daysInMonth = time.getDate();

  for (var i=0; i<objForm[pdmDays].length; i++) {
    objForm[pdmDays].options[0] = null;
  }

  for (var i=0; i<daysInMonth; i++) {
    objForm[pdmDays].options[i] = new Option(i+1);
  }

  if (selectedDay <= daysInMonth) {
    objForm[pdmDays].options[selectedDay-1].selected = true;
  } else {
    objForm[pdmDays].options[daysInMonth-1].selected = true;
  }
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function checkBox(object) {
  document.account_newsletter.elements[object].checked = !document.account_newsletter.elements[object].checked;
}

function popupWindow(url, name, params) {
  window.open(url, name, params).focus();
}

function show(id) {;
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = 'block';
	}
	else {
		document.getElementById(id).style.display = 'none';
	}
}
function add_to_cart(id,products_id){
var cant=document.getElementById(id).value;
if(cant==''){ cant='0'; }
var url;
var minim_antal=document.getElementById('minim_antal').value;

if(parseInt(minim_antal)<=parseInt(cant)){
	document.getElementById("hidden_cant_total").value=cant;
	document.getElementById("cant_total").innerHTML=cant;
	url="add_to_cart.php?cant="+cant+"&products_id="+products_id;
	if(document.getElementById("print_select").value!='') url="add_to_cart.php?products_id="+products_id+"&print="+document.getElementById("print_select").value+"&cant="+cant;
	document.getElementById("iframe_add_to_cart").src=url;
}else{
	alert('Uw order komt niet overeen met het minimum te bestellen aantal');
	document.getElementById("quantity").value="";
	cant = '0';
	//return false;
	
	document.getElementById("hidden_cant_total").value=cant;
	document.getElementById("cant_total").innerHTML=cant;
	url="add_to_cart.php?cant="+cant+"&products_id="+products_id;
	if(document.getElementById("print_select").value!='') url="add_to_cart.php?products_id="+products_id+"&print="+document.getElementById("print_select").value+"&cant="+cant;
	document.getElementById("iframe_add_to_cart").src=url;
	document.getElementById("print_select").value='';
	add_printing_price(products_id);
}
}

function add_to_cart_multiple(id,products_id){
var cant=document.getElementById(id).value;
if(cant==''){ cant='0'; }
var total=document.getElementById("hidden_cant_total").value;
total=parseInt(total)+parseInt(cant)
if(document.getElementById("minus_input").value) total=total-parseInt(document.getElementById("minus_input").value);

var minim_antal=document.getElementById('minim_antal').value;
if(parseInt(minim_antal)<=parseInt(total)){
	document.getElementById("hidden_cant_total").value=total;
	document.getElementById("cant_total").innerHTML=total;
	//document.getElementById("print_select").options[0].selected=true;
	url="add_to_cart.php?cant="+total+"&products_id="+products_id;
	if(document.getElementById("print_select").value!='') url="add_to_cart.php?products_id="+products_id+"&print="+document.getElementById("print_select").value+"&cant="+total;
	document.getElementById("iframe_add_to_cart").src=url;
}else{
alert('Uw order komt niet overeen met het minimum te bestellen aantal');
	document.getElementById("quantity").value="";
	total = '0';
	//return false;

	document.getElementById("hidden_cant_total").value=total;
	document.getElementById("cant_total").innerHTML=total;
	//document.getElementById("print_select").options[0].selected=true;
	url="add_to_cart.php?cant="+total+"&products_id="+products_id;
	if(document.getElementById("print_select").value!='') url="add_to_cart.php?products_id="+products_id+"&print="+document.getElementById("print_select").value+"&cant="+total;
	document.getElementById("iframe_add_to_cart").src=url;
	//add_printing_price(products_id);
	document.getElementById("print_select").value='';
	add_printing_price(products_id);
}
}
function change_products(){
document.location.href='products.php?'+document.getElementById("select_color").value;
}
function add_printing_price(products_id){
var cant=document.getElementById("hidden_cant_total").value;
//alert("add_to_cart.php?products_id="+products_id+"&print="+document.getElementById("print_select").value+"&cant="+cant);
document.getElementById("iframe_add_to_cart").src="add_to_cart.php?products_id="+products_id+"&print="+document.getElementById("print_select").value+"&cant="+cant;
}