// Shop online buttons

var defaultMenuWidth="180px" //set default menu width.
var linkset=new Array()

//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

linkset[0]='<a href="http://www.samsoniteblacklabel.com/" class="butBlackLabel"></a>'
linkset[0]+='<a href="http://shop.samsonite.com/" class="butOriginals"></a>'
linkset[0]+='<a href="http://samsonite-store.jp/" class="butJapan"></a>'
linkset[0]+='<a href="http://cn.samsoniteblacklabel.com/" class="butChina"></a>'
linkset[0]+='<a href="http://kr.samsoniteblacklabel.com/" class="butKorean"></a>'

////No need to edit beyond here

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

if (ie5||ns6)
document.onclick=hidemenu

// end of Shop online buttons

// statements in need of TMPL_VAR's
// writes the page/item id into a js variable
var page_id='<TMPL_VAR NAME="item:itemid"><TMPL_IF NAME="request:extension:branch_id">b<TMPL_VAR NAME="request:extension:branch_id"></TMPL_IF><TMPL_IF NAME="request:extension:image_id">i<TMPL_VAR NAME="request:extension:image_id"></TMPL_IF><TMPL_IF NAME="request:extension:page">p<TMPL_VAR NAME="request:extension:page"></TMPL_IF>';
// specify the client path - do not write the last forward slash
var str_path="/samsonite";
// csv list of ids
var str_page='<TMPL_MSDO NAME="getcookie" PARAMS="inv_print_basket">';

// used in Image Gallery
function checkEmail(_frm,_el){
 var _o=document.forms[_frm].elements[_el];
 var _rv=false;
 var _regex=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/;
 if(_o.value && (_o.value.length > 0) && _regex.test(_o.value)){
  _rv=true;
 }else{
  alert('Please enter a valid email address.');
  _o.focus();
 }
 return(_rv);
}

// used in Image Gallery
function check(){
 if(!document.ilpopup.ff_privacy.checked){
   alert('Please accept the copyright notice');
   return false;
   }
  else{
  return true;
  }
}

// scripts which provide rounded courners in the filter press release box

function addEvent(obj,type,fn){
	if(obj.addEventListener){
		obj.addEventListener(type,fn,false);
	}else if(obj.attachEvent){
		obj["e"+type+fn] = fn;
		obj[type+fn] = function(){
			obj["e"+type+fn](window.event);
		}
		obj.attachEvent("on"+type,obj[type+fn]);
	}
}

function removeNode( trg ){
	if( trg.removeNode ){
		trg.removeNode( true );
	}else{
		trg.parentNode.removeChild( trg );
	}
}		

function o( id ){
	return document.getElementById( id );
}

function co( tag, id, cls, content ){
	var el = document.createElement( tag );
	if( id ){ el.setAttribute( 'id', id ); }
	if( cls ){ el.className = cls; } 
	if( content ){ el.innerHTML = content; } // createTextNode
	return el;
}

function setCboOption( obj, value ){
	obj.setAttribute( 'mo_value', value );
	obj.onmouseover = function(){
		this.className = 'over';
	};
	obj.onmouseout = function(){
		this.className = '';
	};
	obj.onclick = function(){
		o( 'cboHidden' ).setAttribute( 'value', this.getAttribute( 'mo_value' ) );
		o( 'cboMO' ).innerHTML = this.innerHTML;
		this.parentNode.className = '';
	};
}

function setCboMask(){
	var holder = o( 'cboMask' );
	if( holder ){
		var selected_key = '';
		var selected_value = '';
		
		var key_name = ( o( 'cboOtherHolder' ) ) ? 'form_field_il_search_branch' : 'category';
		
		var url = document.location.toString();
		if( url.indexOf( '?' ) && url.indexOf( key_name ) && ( url.indexOf( key_name ) > url.indexOf( '?' ) ) ){
			var query_string = url.split( '?' )[1];
			var key_values = query_string.split( '&' );
			for( var i = 0 ; i < key_values.length ; i++ ){
				var key_value = key_values[ i ];
				if( key_value.indexOf( key_name ) == 0 ){
					selected_key = key_value.split( '=' )[1];
					break;
				}
			}	
		}
		
		var cbo = o( 'cboCategory' );
		cbo.style.display = 'none';
		holder.style.display = 'block';
		
		var cbo_hidden = co( 'input','cboHidden' );
		cbo_hidden.setAttribute( 'type', 'hidden' );
		cbo_hidden.setAttribute( 'name', key_name );
		
		var options = cbo.getElementsByTagName( 'option' );
		var mask_holder = co( 'div', 'cboHolder' );		
		
		var mask = co( 'dl' );
		
		for( var i = 0 ; i < options.length ; i++ ){
			
			var mask_tag = ( i == 0 ) ?  'dt' : 'dd';
			var mask_option = co( mask_tag );
			var mask_value = options[ i ].getAttribute( 'value' );
			
			if( mask_tag == 'dt' ){
				mask_option.setAttribute( 'id', 'cboMO' );
				mask_option.onclick = function(){
					if( this.parentNode.className == 'open' ){
						this.parentNode.className = '';
					}else{
						this.parentNode.className = 'open';
					};
				};
				mask_option.appendChild( document.createTextNode( options[ i ].text ) );
				mask.appendChild( mask_option );
				
				mask_option = co( 'dd' );
				setCboOption( mask_option, mask_value );
			}else{
				if( selected_key && ( selected_key == mask_value ) ){
					selected_value = options[ i ].text; 
				}
				setCboOption( mask_option, mask_value );
			}
			mask_option.appendChild( document.createTextNode( options[ i ].text ) );
			mask.appendChild( mask_option );
		}
		mask_holder.appendChild( mask );
		removeNode( cbo );
		mask_holder.appendChild( cbo_hidden );
		
		holder.appendChild( mask_holder );
		
		if( selected_key && selected_value ){
			o( 'cboMO' ).innerHTML = selected_value;
		}
	}
}

addEvent( window, "load", setCboMask );