/*
  $Id: $

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

  Copyright (c) 2007 osCommerce

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License v2 (1991)
  as published by the Free Software Foundation.
*/

function refreshVariants() {
  var price = null;
  var availability = null;
  var model = null;

  for (c in combos) {
    id = null;

    variants_loop:
    for (group_id in combos[c]['values']) {
      for (value_id in combos[c]['values'][group_id]) {
        if (document.getElementById('variants_' + group_id) != undefined) {
          if (document.getElementById('variants_' + group_id).type == 'select-one') {
            if (value_id == document.getElementById('variants_' + group_id).value) {
              id = c;
            } else {
              id = null;

              break variants_loop;
            }
          }
        } else if (document.getElementById('variants_' + group_id + '_1') != undefined) {
          j = 0;

          while (true) {
            j++;

            if (document.getElementById('variants_' + group_id + '_' + j).type == 'radio') {
              if (document.getElementById('variants_' + group_id + '_' + j).checked) {
                if (value_id == document.getElementById('variants_' + group_id + '_' + j).value) {
                  id = c;
                } else {
                  id = null;

                  break variants_loop;
                }
              }
            }

            if (document.getElementById('variants_' + group_id + '_' + (j+1)) == undefined) {
              break;
            }
          }
        }
      }
    }

    if (id != null) {
      break;
    }
  }

  if (id != null) {
    price = combos[id]['price'];
    availability = productInfoAvailability;
    model = combos[id]['model'];
  } else {
    price = originalPrice;
    availability = productInfoNotAvailable;
    model = '';
  }

  document.getElementById('productInfoPrice').innerHTML = price;
  if (document.getElementById('productInfoAvailability')) document.getElementById('productInfoAvailability').innerHTML = availability;
  document.getElementById('productInfoModel').innerHTML = model;
}

jQuery(document).ready(function(){
	jQuery(document).bind("contextmenu",function(e){
		var tipXPI = e.pageX + 1;
		var tipYPI = e.pageY - 32;
		if (jQuery("#copyrightpi").length > 0) {
			jQuery("#copyrightpi").css("left", tipXPI).css("top", tipYPI).fadeIn("fast");
		} else {
			var error="Copyright &copy; <?php echo date('Y')?> Margeleonline.ro";
			jQuery("body").append('<div align="center" id="copyrightpi" style="cursor:default;font-weight:bold;z-index:1500; padding: 4px; position: absolute; width:230px; height: 20px; background: #FFFFFF; border: #000000 solid 1px">'+error+'</div>');
			jQuery("#copyrightpi").css("left", tipXPI).css("top", tipYPI).fadeIn("fast");
		}
		return false;
	});
	jQuery(document).click(function() {
		jQuery("#copyrightpi").remove();
	});
});

