/*
  $Id: main.js,v 1.1.1.1 2005/12/03 21:36:11 max Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
  
  Moved from general.js.php to here
*/

function couponpopupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
function over(id) {
  var img = document.getElementById(id);
  img.src = "templates/Original/images/base_button/"+id+"2.jpg"
}
function out(id) {
  var img = document.getElementById(id);
  img.src = "templates/Original/images/base_button/"+id+".jpg"
}
function popup(url, name, width, height)
{
settings=
"toolbar=yes,location=yes,directories=yes,"+
"status=no,menubar=no,scrollbars=yes,"+
"resizable=yes,width="+width+",height="+height;

MyNewWindow=window.open(url,name,settings);
}
function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=100,height=100,screenX=100,screenY=100,top=100,left=100')
}
function popupOrder(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=600,height=400,screenX=150,screenY=150,top=150,left=150')
}

function swapImageDiv(inventory_type, product_id) {
  JsHttpRequest.query(
    "ajax_product_info.php",              // backend address
    { inventory_type: inventory_type, product_id: product_id}, // parameters
    function(result, errors) {
      if(result['str'] != 'default' && result['str'] !='') {
//        document.getElementById("imagesPrev").innerHTML = result['str'];
        document.prodimage.src = result['med_img_str'];
      } else {
//        document.getElementById("imagesPrev").innerHTML = document.getElementById("imagesPrev_tmp").innerHTML
        document.prodimage.src = document.getElementById("img_orig").innerHTML;
      }
      document.getElementById("popup_href").href = result['popup_href'];
      //position();
    }, true
  );
}

function onProdListInventChange(inventory_type, product_id) {
  JsHttpRequest.query(
    "ajax_product_list.php",              // backend address
    { inventory_type: inventory_type, product_id: product_id}, // parameters
    function(result, errors) {
      document.getElementById('product_list_img_' + product_id).src = result['str'];
      //position();
    }, true
  );
}

function checkListOptions(product_id) {
  var cObj = document.getElementById('id_qty_' + product_id);
  var flag = true;
  if (cObj != null && cObj != undefined) {
    if (cObj.selectedIndex == 0) {
      flag = false;
    }
  }
  if (!flag) alert("Please select colour or size");
  return flag;
}

function createShippingSession(value) {
  JsHttpRequest.query(
    "ajax_shipping.php",              // backend address
    { value: value }, // parameters
    function(result, errors) {

    }, true
  );
}