var YUE = YAHOO.util.Event;
var YUD = YAHOO.util.Dom;

function naviMouseOver(e) {
  this.src = 'images/nav/' + this.id + '_active.jpg';
}
function naviMouseOut(e) {
  this.src = 'images/nav/' + this.id + '.jpg';
}
function inputFocus(e) {
  if (this.value == this.alt) {
    this.value = '';
  }
}
function inputBlur(e) {
  if (this.value == '') {
    this.value = this.alt;
  }
}
function clickButton(e) {
  window.location.href = this.parentNode;
  YUE.stopEvent(e);
}

function print_r(theObj){ // DEV ONLY!
  if(theObj.constructor == Array || theObj.constructor == Object){
    document.write("<ul>");
    for(var p in theObj){
      if(theObj[p].constructor == Array || theObj[p].constructor == Object){
        document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>");
        print_r(theObj[p]);
        document.write("</ul>");
      } else {
        document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>");
  }
}

// altes
function rowOverEffect(object) { // account.php
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) { // account.php
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function disable_submit() { // checkout_confirmation.php
  document.getElementsByName("orderbutton")[0].disabled = 'disabled';
}

function session_win() { // login.php
  window.open("<?php echo tep_href_link(FILENAME_INFO_SHOPPING_CART); ?>","info_shopping_cart","height=460,width=430,toolbar=no,statusbar=no,scrollbars=yes").focus();
}

function popupWindow(url) { // product_info.php
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function popupcvc(url) { // product_info.php
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=400,height=450,screenX=150,screenY=150,top=150,left=150')
}

var selected; // checkout_coupon.php, checkout_payment_address.php
function selectRowEffect(object, buttonSelect) { // checkout_coupon.php, checkout_payment_address.php
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');
    } else {
      selected = document.all['defaultSelected'];
    }
  }

  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;

// one button is not an array
  if (document.checkout_address.address[0]) {
    document.checkout_address.address[buttonSelect].checked=true;
  } else {
    document.checkout_address.address.checked=true;
  }
}

function check_form_optional(form_name) { // checkout_payment_address.php
  var form = form_name;

  var firstname = form.elements['firstname'].value;
  var lastname = form.elements['lastname'].value;
  var street_address = form.elements['street_address'].value;

  if (firstname == '' && lastname == '' && street_address == '') {
    return true;
  } else {
    return check_form(form_name);
  }
}

var submitter = null; // checkout_coupon.php
function submitFunction() { // checkout_coupon.php
   submitter = 1;
}

/* DDB - 041031 - Form Field Progress Bar */ // product_info.php
/***********************************************
* 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) { // product_info.php
  // 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){ // product_info.php
  obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
