
 function EventWorker() {
   this.addHandler = EventWorker.addHandler;
 }


 EventWorker.addHandler = function (eventRef, func) {
  var eventHandlers = eval(eventRef);
  if (typeof eventHandlers == 'function') {
   eval(eventRef + " = function(event) {eventHandlers(event); func(event);}");  
  } else {
   eval(eventRef + " = func;");
  }
 }


 function getElementsByClass(node,searchClass,tag) {
   var classElements = new Array();
   var els = node.getElementsByTagName(tag); // use "*" for all elements
   var elsLen = els.length;
   var pattern = new RegExp("\\b"+searchClass+"\\b");
   for (i = 0, j = 0; i < elsLen; i++) {
     if ( pattern.test(els[i].className) ) {
       classElements[j] = els[i];
       j++;
     }
   }
   return classElements;
 }


 function firstRealSib(obj) {
   var output = obj;
   while (output == obj || output.nodeType == 3) {
      output = output.nextSibling;
   }
   return output;
 }

 function firstRealChild(obj) {
   var output = obj.firstChild;
   while (output.nodeType == 3) {
      output = output.nextSibling;
   }
   return output;
 }


function slide_toggle(obj) {
// Moz. or IE
   var control = firstRealChild(obj);
   var target = firstRealSib(obj);
   if(target.style.left == '-5000px' || target.style.left == '') {
      antihideleft(target);
      if (control.firstChild) control.firstChild.data='-';
   } else {
      hideleft(target);
      if (control.firstChild) control.firstChild.data='+';
   }
}


function hideleft(obj) {
   var myAnim = new YAHOO.util.Anim(obj, { height: { to: 0 } }, .4, YAHOO.util.Easing.easeOut);
   myAnim.onComplete.subscribe(function(){ obj=this.getEl();obj.style.height = 'auto';obj.style.left = '-5000px';obj.style.position = 'absolute';});
   myAnim.animate(); 
}

function antihideleft(obj) {
   var start_height = obj.offsetHeight;
   obj.style.height = '0px';
   obj.style.overflow = 'hidden';
   obj.style.left = '0px';
   obj.style.display = 'block';
   obj.style.position = 'relative';
   var myAnim = new YAHOO.util.Anim(obj, { height: { to: start_height } }, .4, YAHOO.util.Easing.easeOut);
   myAnim.animate(); 
}


ieHover = function() {
var ieULs = document.getElementById('nav').getElementsByTagName('ul');
/** IE script to cover <select> elements with <iframe>s **/
for (j=0; j<ieULs.length; j++) {
ieULs[j].innerHTML = ('<iframe security="restricted" src="/design/ezwebin/blank.html" scrolling="no" frameborder="0"></iframe>' + ieULs[j].innerHTML);

	var ieMat = ieULs[j].firstChild;
		ieMat.style.width=ieULs[j].offsetWidth+"px";
		ieMat.style.height=ieULs[j].offsetHeight+"px";	
		ieULs[j].style.zIndex="99";
}

	var ieLIs = document.getElementById('nav').getElementsByTagName('li');
	for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
		ieLIs[i].onmouseover=function() {this.className+=" iehover";}
		ieLIs[i].onmouseout=function() {this.className=this.className.replace(' iehover', '');}
	}}

if (window.attachEvent) window.attachEvent('onload', ieHover);

fauxselect = function() {
   var uls = getElementsByClass(document, 'selectReplacement', 'UL');
   for (i in uls) {
   ul = uls[i];
   if (window.attachEvent) ul.onmouseover = function() {
      this.className += ' selHover';
    }
   if (window.attachEvent) ul.onmouseout = function() {
      this.className =
        this.className.replace(new RegExp(" selHover\\b"), '');
    }
   var opts = ul.getElementsByTagName('li');
   for (var i=0; i<opts.length; i++) {
   var li = opts[i]; 
      if (window.attachEvent) li.onmouseover = function() {
        this.className += ' selHover';
      }
      if (window.attachEvent) li.onmouseout = function() {
        this.className =
          this.className.replace(new RegExp(" selHover\\b"), '');
      }
      if (i>0) li.onclick = function() {document.flagform.reason.value = this.innerHTML;ajax_flagme();showwarns(this, 0)}
   }
   }
}

function showwarns(obj, id) {
    while (obj.className != 'attribute-name' &&  obj.className != 'flagme') {
	obj = obj.parentNode;
    }
    if (obj.className == 'attribute-name') obj = obj.nextSibling;
    if (obj.style.display == 'block') {
    obj.style.display = 'none';	
    } else {
    obj.style.display = 'block';	
    }
    document.flagform.node_id.value = id;
}

var cur_tab=0;
tab_root = 0;

function set_blog_tabs() {
    if (tab_root == 0) {
	 var first_tab = document.getElementById('blog_tab_0');
        tab_root=first_tab.parentNode.parentNode.parentNode.parentNode.parentNode;
        tab_root.style.height = first_tab.parentNode.parentNode.firstChild.offsetHeight+ 'px';
    }
    tabs=getElementsByClass(tab_root,'dir-switch-title','H2');
    for (i in tabs) {
        tabs[i].onmouseover = function() { if (this.id.replace(/blog_tab_/,'') != cur_tab) {
			this.parentNode.parentNode.className = 'dir-switch selected';
			document.getElementById('blog_tab_'+cur_tab).parentNode.parentNode.className = 'dir-switch';
			cur_tab=this.id.replace(/blog_tab_/,'');
			tab_root.style.height = this.parentNode.parentNode.firstChild.offsetHeight+ 'px';} };
    }
}

var cur_vbn_tab=0;
vbn_tab_root = 0;

function set_vidbynode_tabs() {
    if (vbn_tab_root == 0) {
	 var first_tab = document.getElementById('vbn_tab_0');
        vbn_tab_root=first_tab.parentNode.parentNode;
    }
    tabs=getElementsByClass(vbn_tab_root,'vidbytab_tab','H3');
    for (i in tabs) {
        tabs[i].onmouseover = function() { 
            if (this.id.replace(/vbn_tab_/,'') != cur_vbn_tab) {
			this.parentNode.className = 'vidytab_tab_holder selected';
			document.getElementById('vbn_tab_'+cur_vbn_tab).parentNode.className = 'vidytab_tab_holder';
			cur_vbn_tab = this.id.replace(/vbn_tab_/,'');
            }
        }
    }
}

function setup_vote_box(id) {
	vote_box_root=document.getElementById(id);
	vote_box_root.onmouseover = function() {this.className="vote_box vote_hover"};
	vote_box_root.onmouseout = function() {this.className="vote_box"};
	vote_divs = getElementsByClass(vote_box_root,'vote_div','DIV');
	for (i in vote_divs) {
	    vote_divs[i].onclick = function() {this.parentNode.parentNode.submit();}
	    vote_divs[i].onmouseover = function() {
		 my_vote_divs=this.parentNode.childNodes;
		 my_class_name = 'vote_div selected';
		 for (xx in my_vote_divs) {
		     if (xx < 5) {
	            my_vote_divs[xx].className = my_class_name;
	            if (my_vote_divs[xx] == this) {
	                my_class_name = 'vote_div';
	                this.parentNode.parentNode.eZVoteCollectorValue.value = parseInt(xx) + 1;
	            }
	            }
	        }
	    }
	}
}

function ajax_flagme(){
	var ajaxRequest;
	try{
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var flag_response = ajaxRequest.responseText;
			if (flag_response) {alert('Your complaint has been submitted. Thank you!');} else {alert('Request transmission error - please contact an administrator.');}
		}
	}
	ajaxRequest.open("GET", "/flagimage/submit/" + document.flagform.node_id.value + '/' + document.flagform.reason.value, true);
	ajaxRequest.send(null); 
}


var TopShoePromoShow, TopShoePromoHide

function initTopShoePromo() {
	TopShoeImage = document.getElementById('featurepair');
	TopShoePromo = document.getElementById('top_shoe_promo');
	if (TopShoePromo) {
		TopShoePromoShow = new YAHOO.util.Anim(TopShoePromo, { top: { to: 23 } }, 1, YAHOO.util.Easing.easeOut);
		TopShoePromoHide = new YAHOO.util.Anim(TopShoePromo, { top: { to: -30 } }, 1, YAHOO.util.Easing.easeOut);
		TopShoeImage.onmouseover=function(){TopShoePromoShow.animate();};
		document.getElementById('header').onmousemove=function(){TopShoePromoHide.animate();};
		document.getElementById('nav').onmousemove=function(){TopShoePromoHide.animate();};
	}
}

EventWorker.addHandler("window.onload", initTopShoePromo );
