function slide_up(id){
	var sl_up = new Effect.SlideUp(id, { duration: '0.25'});
}

function ship_country_select_observer(){
	if($('order_ship_country')){
		Event.observe('order_ship_country', 'change', function(){
			if(this.options[this.selectedIndex].value != 'US'){
				$('verification_value_hider').style.display = '';
			} else{
				$('verification_value_hider').style.display = 'none';
			}
		});
	}
}

function show_address_verification(){
	if($('address_verification')){
		var av_appear = new Effect.SlideDown('address_verification',{ duration: '0.25'});
	}
}

function update_shipping_method(selected_method){
	var methods = $$('.shipping_method_selection');
	for(var i=0;i<methods.length;i++){
		methods[i].removeAttribute("checked");
	}
	selected_method.setAttribute("checked","checked");
	$('review_form').submit();
}

function first(el){
  var ret = el.firstChild;
  while(ret.nodeType == 3){
    ret = ret.nextSibling;
  }
  
  return ret;
}

function prev(el){
  var ret = el.previousSibling;
  while(ret.nodeType == 3){
    ret = ret.previousSibling;
  }
  return ret;
}

function activate(a){
  a.className = a.className+" active";
}

function deactivate(a){
  if(a == undefined){
    var links = document.getElementsByTagName("a");
    for(var i=0;i<links.length;i++){
      if(links[i].className.match(/active/)){
        a = links[i];
      }
    }
    
    if(a == undefined) return;
  }
  
  if(a.className != undefined){
    a.className = a.className.replace(/active/g,"");
  }
}

function prepLinks(){
  var links = document.getElementsByTagName("a");

  for(var i=0;i<links.length;i++){
    var a = links[i];
    
    if(a.className == "navLink"){
      a.onmouseover = function(){
        deactivate();
        activate(this);
      };
      a.onmouseout = function(){
        deactivate();
      }
    }
  }
  
  var subnav = document.getElementsByTagName("li");
  for(var i=0;i<subnav.length;i++){
    if(subnav[i].firstChild.className == "subnavLink"){
      subnav[i].onmouseover = function(){activate(prev(this.parentNode))};
      subnav[i].onmouseout = function(){deactivate()};
    }
  }
  
  var nav = document.getElementById("navBars");
}

function show_international_notice(){
  var win = window.open ("","intl_notice","status=1,width=450,height=200"); 
  win.document.write('<html><body style="background:#eee;"><p style="font-family:helvetica,sans-serif;padding:10px 20px;">This product can only be purchased by customers in the United States and its territories.<br/><br/> Items available to be purchased internationally are all products other than EMI/CMG published material.</p></body></html>');
}
