/* 
 * application.js
 * 
 * @desc: This is where all scripts specific to this cobrand/shop/application goes.
 */

/*
 * This function is used instead of window.onload().
		It executes when DOM is ready. It will not wait for images to load.
 * 
 * @dependencies: js-zlib.js
 */
function onDomReady() {
	
}

<!-- START -- Shopping Cart script -->
function writeItems() {
    var items = readCookies('scitems');
	var stuff = 'Shopping Bag (<span class="cartnum">' + items + '</span>';
    if (items) {
        if (items == 1) { 
	        document.write(stuff + ' item)' );
		} else {
		    document.write(stuff + ' items)' );
		}
    } else {
	    document.write('Shopping Bag (' + '0 items)' );
	}

}

function readCookies(name) {
	var cname = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(cname) == 0) return c.substring(cname.length,c.length) ;
	}
}

<!-- END -- Shopping Cart script-->
<!-- Label hiding / Search Box Code -->

function initOverLabels () {
  if (!document.getElementById) return;  	

  var label, id, field;

  // Set focus and blur handlers to hide and show 
  label = document.getElementById('srchlbl');
  field = document.getElementById('srchnput');
	
      // Change the applied id to hover the label 
      // over the form field.
      label.id = 'srchoverlbl';

      // Set handlers to show and hide labels.
      field.onfocus = function () {
        hideLabel(this.getAttribute('id'), true);
      };
      field.onblur = function () {
        if (this.value === '') {
          hideLabel(this.getAttribute('id'), false);
        }
      };

      // Handle clicks to LABEL elements (for Safari).
      label.onclick = function () {
        var id, field;
        id = this.getAttribute('for');
        if (id && (field = document.getElementById(id))) {
          field.focus();
        }
      };

  }

function hideLabel (field_id, hide) {
  var field_for;
  var label = document.getElementById('srchoverlbl');
 
  label.style.visibility = (hide) ? 'hidden' : 'visible';
  return true;
}


