// SEARCH
//function checkEnter(e){ //e is event object passed from function invocation 
//	var characterCode //literal character code will be stored in this variable 
//	
//	if(e && e.which){ //if which property of event object is supported (NN4) 
//		e = e; 
//		characterCode = e.which; //character code is contained in NN4's which property 
//	} 
//	else{ 
//		e = event; 
//		characterCode = e.keyCode; //character code is contained in IE's keyCode property 
//	} 
//	
//	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key) 
//	//Action Goes Here 
//	(document.getElementById('searchtext').value=='Search' || document.getElementById('searchtext').value=='')?alert('Please Enter the Search Word'):location.href='/SearchResults.aspx?xsq='+document.getElementById('searchtext').value;
//	return false; 
//	} 
//	else{ 
//		return true; 
//	} 
//}
// Reference $ for jQuery


//SELECT DROPDOWN SKINNING
function SelectReplacement(obj) {
    $(obj).addClass('replaced')

    var ul = document.createElement('ul');
    $(ul).addClass('selectReplacement')
      var opts = obj.options;
      for (var i=0; i <opts.length; i++) {
        var selectedOpt;
        if (opts[i].selected) {
          selectedOpt = i;
          break;
        } else {
          selectedOpt = 0;
        }
      }

      for (var i=0; i<opts.length; i++) {
        var li = document.createElement('li');
        var txt = document.createTextNode(opts[i].text);
        li.appendChild(txt);
        li.selIndex = opts[i].index;
        li.selectID = obj.id;
        li.onclick = function() {
          selectMe(this);
      }

        if (i == selectedOpt) {
          li.className = 'selected';
          li.onclick = function() {
            this.parentNode.className += ' selectOpen';
            this.onclick = function() {
              selectMe(this);
            }
          }
        }

          $(li).live('mouseover', function () {
              $(this).addClass('hover')
          });

          $(li).live('mouseout', function () {
              $(this).removeClass('hover')
          });

        ul.appendChild(li);
      }
      // add the input and the ul
        $(obj).after(ul);
    }

    function selectMe(obj) {
      var lis = obj.parentNode.getElementsByTagName('li');
      for (var i=0; i<lis.length; i++) {
        if (lis[i] != obj) { // not the selected list item
          lis[i].className='';
          lis[i].onclick = function() {
            selectMe(this);
          }
       } else {
          setVal(obj.selectID, obj.selIndex);
          obj.className='selected';
          obj.parentNode.className = 
            obj.parentNode.className.replace(new RegExp(" selectOpen\\b"), '');
          obj.onclick = function() {
            obj.parentNode.className += ' selectOpen';
            this.onclick = function() {
              selectMe(this);
            }
          }
        }
      }
    }

    function setVal(objID, selIndex) {
        var obj = $('#' + objID + '');
        $(obj).attr("selectedIndex", selIndex);
        setTimeout('__doPostBack(\'' + objID + '\',\'\')', 0);
    }

    function GetSelectElements() {
         $('select').each(function(index) {
             SelectReplacement(this);
         });
         
    }
    
    function closeSel(obj) {
      // close the ul
    }


    $(document).ready(function () {
        (document.all && !window.print) ? null : GetSelectElements();
        $('.dropDownDescription').show();

        $('#printLink').click(function () {
            print();
            return false;
        });
    });


