/*function position(){
  h1 = document.getElementById("div1").offsetHeight;
  h2 = document.getElementById("div2").offsetHeight;
  h3 = document.getElementById("div3").offsetHeight;
  h4 = document.getElementById("div4").offsetHeight;
  h5 = document.getElementById("div5").offsetHeight;
  h6 = document.getElementById("div6").offsetHeight;
  h7 = document.getElementById("div7").offsetHeight;

  document.getElementById("div1").style.top = h7+"px";
  h47=h4+h7;
  document.getElementById("div2").style.top = h47+"px";
  h457=h4+h5+h7;
  document.getElementById("div3").style.top = h457+"px";
  h237=h2+h3-h7;
  document.getElementById("div4").style.top = -h237+"px";
  h37=h3-h7;
  document.getElementById("div5").style.top = -h37+"px";
  document.getElementById("div6").style.top = h7+"px";
  h123456=h1+h2+h3+h4+h5+h6;
  document.getElementById("div7").style.top = -h123456+"px";
}*/

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 popupWindow2(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=520,height=900,screenX=150,screenY=150,top=150,left=150')
}
function popupGlossaryWindow(url) {
window.open(url,'popupGlossaryWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=250,screenX=150,screenY=150,top=150,left=150')
}

function popupChart(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=400,screenX=150,screenY=150,top=150,left=150')
}


/* BEGIN_ISL option_type_feature_v1.71 */
/* DDB - 041031 - Form Field Progress Bar */
/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
***********************************************/
function textCounter(field,counter,maxlimit,linecounter) {
        // text width//
        var fieldWidth =  parseInt(field.offsetWidth);
        var charcnt = field.value.length;
        // trim the extra text
        if (charcnt > maxlimit) {
                field.value = field.value.substring(0, maxlimit);
        } else {
        // progress bar percentage
        var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
        document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
        document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
        // color correction on style from CCFFF -> CC0000
        setcolor(document.getElementById(counter),percentage,"background-color");
        }
}
function setcolor(obj,percentage,prop){
        obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
/* END_ISL option_type_feature_v1.71 */

function checkOptions() {
  var cObj = document.getElementById('id_qty');
  var flag = true;
  if (cObj != null && cObj != undefined) {
    if (cObj.options[cObj.selectedIndex].value == 0 || cObj.options[cObj.selectedIndex].value == 'out') {
      flag = false;
    }
  } else {
    var cElements = document.cart_quantity.getElementsByTagName("input");
    var cAr = Array();
    var counter = 0;
    for (var i=0;i<cElements.length;i++){
      if (cElements[i].type == 'radio' && cElements[i].id.indexOf("id_") > -1 ) {
        flag = false;
        if (cElements[i].checked) {
          flag = true;
          break;        
        }
      }
    }
  }
  if (!flag) alert("Please select an in-stock colour or size");
  return flag;
}

function NewWindow(url, myname, w, h, scroll, id)
{
   var winl = (screen.width - w) / 2;
   var wint = (screen.height - h) / 2;
   winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=1';
   if(id != null)
        url = url + id.selectedIndex;
   win = window.open(url, myname, winprops);
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function ChangeinnerHTML(layerid, htmlcode) {
    var statement = '';

    if (document.all)
          statement += "document.all['" + layerid + "'].innerHTML = '" + htmlcode + "';";
    else if (document.getElementById)
          statement += "document.getElementById('" + layerid + "').innerHTML = '" + htmlcode + "';";

    eval(statement);
}

function ValidNumber (str)
{
   return ! isNaN (str * 1);
}

function RoundPrice(nValue)
{
  return Math.round(nValue * 100) / 100;
}

function formatNumber(num)
{
  var s = new String(num);
  p=s.indexOf('.')
  n=s.indexOf(',')
  var j = Math.floor(num);
  var s1 = new String(j);
  if (p > 0 || n > 0) {
    if (p > 0) {
      s = s.replace('.', sep_dec);
    } else {
      s = s.replace(',', sep_dec);
    }
  }
  if (s1.length + 2 == s.length) {
    s = s + '0';
  }
  var n = Math.floor(s1.length/3);
  var i =1
  while (n > 1) {
    s = s.substring(0, s.indexOf(sep_dec)-(3*n)) + sep_th + s.substring(s.indexOf(sep_dec)-(3*n), s.length);
    n--;
  }
//  s = s.replace( /(?=(\d{3})+$)/g, sep_th);

  if (j == num) {
    s = s + sep_dec + '00';
  }

  s = symbol_left + s  + symbol_right;
  return s;
}

function UpdatePrice(price)
{
  viewprice = RoundPrice(price);
  totalprice = viewprice + "";
}

function Init ()
{
  initPriceAndCategories();
}

