var navImages = new Array();
	var imNames = new Array( 'shop' , 'collections' , 'press' , 'symbolism'  , 'charity'  , 'about'  , 'contact' , 'search' , 'view_basket'  );
	var subNames = new Array( 'snShop' , 'snCollections' ,  'snPress'  , 'nothing'  , 'nothing'  , 'snAbout' , 'snContact' , 'nothing' ,'nothing' ,'nothing' , 'nothing' );

	var navLoaded = 0;
	function loadImages( ActiveNavId ){
		
		
		 for ( var i=0,j=0 ; j < imNames.length ; i+=2,j++  ) {
						navImages[  i  ] = new Image();
						navImages[  i  ].src = "images/topNav/tn_" + imNames[  j  ]   +  "_NT.gif" ;
						navImages[  i+1  ] = new Image();
						navImages[  i+1  ].src = "images/topNav/tn_"  + imNames[  j  ] +  "_RO.gif" ;
		}
		navLoaded = 1;
		activate_section_nav( ActiveNavId );
	}// end func
	
var t_clock  ;
var selectdIM = "_empty";	
var selectdSUB = "";
var selectdAR;
var currentPage = "";
var resetTimer_currentPage;

// Language options
var isJapan = 0;
var isPort = 0;
var isItalian = 0;
var isFrench = 0;



var navJsStatements = new Array();

navJsStatements.shop = new Array( 'shop' , 1 , 'snShop' );
navJsStatements.collections = new Array( 'collections' , 3 , 'snCollections' );
navJsStatements.press = new Array( 'press' , 5 , 'snPress' );
navJsStatements.symbolism = new Array( 'symbolism' , 7 , 'nothing' );
navJsStatements.charity = new Array( 'charity' , 9 , 'snLinks' );

navJsStatements.about = new Array( 'about' , 11 , 'snAbout' );
navJsStatements.contact = new Array( 'contact' , 13 , 'snContact' );
navJsStatements.search = new Array( 'search' , 15 , 'nothing' );
navJsStatements.viewCart = new Array( 'viewCart' , 17 , 'nothing' );



function activate_section_nav( id ){
	if ( id ) { 
	//alert ( id );
		var sArray =  navJsStatements[ id ]
											//alert ( sArray );
		onMenu( sArray[ 0 ]  , sArray[ 1 ] , sArray[ 2 ] );
		currentPage = sArray[ 0 ];
	}
}
	
	
var waitTimer;
	
	function onMenu( HTMLid  , arID , subNavId ){
	
		if (navLoaded ){    //alert ( "in onMenu " + HTMLid + "arID= " + arID );
			clearTimeout ( t_clock );
			
			if (( selectdIM != "_empty" ) && (  selectdIM != HTMLid )) {
				hideSub( selectdSUB );
				offMenu( selectdIM , (selectdAR-1) )
			}
			
			document.images[  HTMLid  ].src = navImages[  arID ].src;
			showSub ( subNavId );
				
			selectdIM = HTMLid ;
			selectdAR = arID ;
			selectdSUB = subNavId;
		}
		//waitTimer = setTimeout ( "onMenu(" +  HTMLid  + " , " +  arID + " , " + subNavId + " )" , 1000 );
	} // end onMenu
	
	
	var momoToggle = 0;
	function monogram_info( id ){
		
		if ( momoToggle ) {
			document.getElementById( "monoBlock" ).style.visibility = "hidden";
			document.getElementById( "momo_pDesc" ).style.visibility = "visible";
			momoToggle = 0;
		
		}else{
			document.getElementById( "momo_pDesc" ).style.visibility = "hidden";
			document.getElementById( "monoBlock" ).style.visibility = "visible";
			momoToggle = 1;
		
		}
		
	}
	
	
	function showSub ( id ){
			document.getElementById( id ).style.visibility = 'visible';
	}
	
	function hideSub( id ){
			document.getElementById( id ).style.visibility = 'hidden';
	}
	
	function offMenu( id , arID ) {
		if (navLoaded ){
			document.images[  id  ].src = navImages[  arID ].src;
		}
	}

	function timer(){
		t_clock = setTimeout ( 'clear_all()' , 1200 );
	}

	function clear_all(){
	  	for ( var y=0; y < imNames.length ; y++ ){
		//alert ( "currentPage = " + currentPage ) ;
		if ( imNames[ y ] == currentPage ) continue ;

	  			document.images[  imNames[ y ]  ].src = navImages[ y*2 ].src;
				document.getElementById( subNames[ y ] ).style.visibility = 'hidden';
	  	}
		clearTimeout ( t_clock );
		
		resetTimer_currentPage = setTimeout (  "activate_section_nav('" + currentPage +"' )"  , 50 );

	}
	
	function clear_timer(){
		clearTimeout ( t_clock );
	}
	
// END NAV FUNCTIONS

/* ************** SET UPS ***************************
****************************************************  */

	function getClientWidth(){
		var cw =(IE)?document.body.clientWidth :window.innerWidth ;
	
			if( NS )  { 
				if ( window.innerHeight < document.height )cw -= 13;
				//alert ( 'window.innerHeight=' + window.innerHeight + 'document.height =' + document.height)
			}
		return cw ;
	}
	
	function getClientHeight(){  // not used as yet
		var ch =(IE)?document.body.clientHeight :window.innerHeight ;
			if( NS )  { 
			
			}
		return ch;
	}
	
	function getScreenHeight(){
		//alert ( screen.height );
	}
	
	function DynamicPosDiv( id , objectWidth , offsetAmount ){
		this.object = id ;
		this.div_obj = document.getElementById( this.object ).style;
		//this.lpos = cw/2 - offset
		this.offset = parseInt( objectWidth / 2 )+ offsetAmount ;
	}

DynamicPosDiv.prototype.set = function(){
 			this.cw = getClientWidth();
 			this.lpos = this.cw/2 - this.offset;
			this.initPos = 1;
			if(this.cw > 764 ){
			if ( this.lpos < this.initPos ) this.lpos = this.initPos; 
	 			if (IE )this.div_obj.pixelLeft = this.lpos ;
	 			if( NS )this.div_obj.left = this.lpos ;
				this.div_obj.visibility="visible";
			
			}else{
				if (IE )this.div_obj.pixelLeft = this.initPos ;
	 			if( NS )this.div_obj.left = this.initPos ;
				this.div_obj.visibility="visible";
			}
		//for ( i=0; i<unhideArray.length ; i++ ){//var snv = new dop( unhideArray[ i ]  );//snv.el.visibility="visible";}
 }

 var isLoaded = 0;
 var obj_topNavContainer;
 
function setUpDivs( ActiveNavId ) {
		setVal = 400 ; 
		id = 'topNavContainer' ;
		isLoaded=1;
 		obj_topNavContainer = new DynamicPosDiv ( 'topNavContainer' , 862 , -1 );  //762
		obj_topNavContainer.set();
		// activate_section_nav( ActiveNavId ); call moved to load nav images()
}
	
function setDivPos(){
	if ( isMac || ns4 )this.location.href = this.location.href;
	if(isLoaded){
	 	obj_topNavContainer.set();
	}
}
var checkOutUrl = '';  //  set via Cbusiness Props in SF6 leftNav cntrl 
function getCheckOutUrl( ){	
		if ( checkOutUrl ) {
			return checkOutUrl ;  // will have been set on ssl page load with session_id
		}else{
			return "shoppingcart.aspx" ;
		}
} 

function veiwBasket(){
	this.window.location = getCheckOutUrl( );//alert ( "in :" +  getCheckOutUrl( ) );
}

function pageInit( id ){
	setUpDivs(  ); //id
	loadImages( id );
	//alert ( getCheckOutUrl( ) );
}
//alert ( screen.availableHeight ) if avail h < 601 : move top of page ( margin ) and top of topNav up 14px.....


var selectd_leftNav = '' ; // request.QueryString ( subCat )
	
function setLeftNavItem (){
		if (selectd_leftNav){
			if ( document.getElementById( selectd_leftNav )!=null ){
			document.getElementById( selectd_leftNav ).style.color = "#ffffff"  ;//'leftNavLinkSelctd';
			document.getElementById( selectd_leftNav ).style.fontWeight = "bold"  ;
			
			}
		}
}

function openSecCodeWindow(){
	var scWin = window.open ( 'sec_code.html','scWin','titlebar=0,status=0,location=0,toolbar=0,menubar=0,scrollbars=no,resizable=no,width=440,height=400' )
	scWin.focus();
}


function openJewelWin( html ){
	html += ".html"
	var jWin = window.open ( html,'jWin','titlebar=0,status=0,location=0,toolbar=0,menubar=0,scrollbars=no,resizable=no,width=440,height=260' )
	jWin.focus();
}
// openJewelWin( spessartite )  openJewelWin( diopside )
// onload="pageInit()" onResize="setDivPos()"

function posEmailIE(){
			if ( IE ){
			//document.getElementById( 'ecapContainer' ).style.pixelTop = -37;
			}
}
function posEmailIE_02(){
			if ( IE ){
			document.getElementById( 'ecapContainer' ).style.pixelTop = -20;
			}
}

function getMeroCookie(c_name){
	if ( document.cookie.length>0 ){
  			c_start=document.cookie.indexOf( c_name + "=" );
  			if ( c_start!=-1 ){ 
    			c_start=c_start + c_name.length+1; 
    			c_end=document.cookie.indexOf( ";", c_start);
    			if ( c_end==-1 ) c_end=document.cookie.length;
    			return unescape( document.cookie.substring( c_start,c_end ) );
    		} 
  	}
	
	return "";
}

function setMeroCookie( c_name , StrValue ){
	var cVal = getMeroCookie ( c_name ) ;
	//alert ( "c_name = " + c_name + "  StrValue= " + StrValue );
	StrValue = StrValue + ',' + cVal  ;
	document.cookie = c_name+ "=" + escape( StrValue );
}

function setMeroCookie02( c_name , PID , CatID , PageID, PosID ){
	var cVal = getMeroCookie ( c_name ) ;
	//alert ( "c_name = " + c_name + "  StrValue= " + StrValue );
	StrValue = PID + ',' +  CatID + ',' + PageID + ',' + PosID 
	StrValue = StrValue + ',' + cVal  ;
	document.cookie = c_name+ "=" + escape( StrValue );
	//alert (   StrValue  );
	//alert ( " cname = " +  c_name + " PID = " + PID  + " CatID = " + CatID + " PageID = " + PageID + " PosID = " +  PosID );
}

function deleteMeroCookie (){
		c_name = "mero_usrViewCookie";
		document.cookie = c_name+ "=" +  "";
}	
		
		
function openPressDetail( id ){
	//alert ( id );
	getPid = id ; 
	html = 'popDetail.aspx?p_id=' + getPid;
	var meroPress = window.open ( html,'contentWin','titlebar=0,status=0,location=0,toolbar=0,menubar=0,scrollbars=no,resizable=yes,width=327,height=450' )
	meroPress.focus();	
}


var fade_timer;
var fade_timer2;
var fade_timer_count = 0;
var fade_timer_count2 = 0;
var lowKey = ( 3 );

var fadeArray = new Array ( "opacity0" ,"opacity8" ,"opacity15" , "opacity25" , "opacity35"  , "opacity45" , "opacity55" ,"opacity65" , "opacity75" , "opacity80" ,  "opacity85",  "opacity90"  ,"opacity95", "opacity100");

function changeFade( obj_id ){
//alert ( fadeArray[ fade_timer_count ] );
	//document.getElementById('nycImage').setAttribute("class", fadeArray[ fade_timer_count ] );
	clearTimeout(fade_timer);
	document.getElementById( obj_id ).className = fadeArray[ fade_timer_count ];
	//alert ( document.getElementById('nycImage').className );
	timer_changeFade( obj_id );
	
	
}

function timer_changeFade( obj_id ){
//alert ( obj_id );
	if ( fade_timer_count < (fadeArray.length-1)){
	 	fade_timer = setTimeout(  "changeFade( '" +obj_id +"' )" , 120 );
		fade_timer_count ++
	}else {
		clearTimeout(fade_timer);
		fade_timer_count = 0;
	}
}

function changeFade2( obj_id ){ // logo  .. with more time i would make this a class - at the mo its a sketch
//alert ( fadeArray[ fade_timer_count ] );
	//document.getElementById('nycImage').setAttribute("class", fadeArray[ fade_timer_count ] );
	clearTimeout(fade_timer2);
	document.getElementById( obj_id ).className = fadeArray[ fade_timer_count2 ];
	document.getElementById( 'tn_lines' ).className = fadeArray[ fade_timer_count2 ];
	document.getElementById( 'bannerTable' ).className = fadeArray[ fade_timer_count2 ];
	
	
	//alert ( document.getElementById('nycImage').className );
	timer_changeFade2( obj_id );
	
	
}

function timer_changeFade2( obj_id ){ // TopNav table *************** turning to length - more for low key 
//alert ( lowKey );
	if ( fade_timer_count2 < ( fadeArray.length - lowKey )){
	 	fade_timer2 = setTimeout(  "changeFade2( '" +obj_id +"' )" , 50 );
		fade_timer_count2 ++
	}else {
		clearTimeout(fade_timer2);
		fade_timer_count2 = 0;
	}
}
