
function init()
{
	//	If Product Page then default tabs to use the right window.CreateBookmarkLink()
	if( window.location.toString().split('/').length > 3 )
	{
		if( window.location.toString().split('/')[3] == 'product' )
		{
			if( document.location.toString().split("#").length > 1 )
				currentTab = document.location.toString().split("#")[1].toLowerCase();
			else
				currentTab = '';
			norTabs.init( 'overview', currentTab, '/sites/www/images/cs-tabs-', '.png', '-', 'tab_' );
		}
	}
}

function addSeparator(text, li) {
   // This is now being done in Scriptaculous controls.js
   //text.value += ', ';
}

function norOpenWindow( t )
{
	window.open( t.href, '_BLANK', 's' );
	return false;
}

function checkDomain( t )
{
	var regExInvalidChars = /[^a-zA-Z0-9-\s.]+/;
	if (regExInvalidChars.test(t.value))
	{
		alert('Invalid character in domain.\n\nOnly letters, numbers or hyphens are allowed.');
		return false;
	}
}


function checkDomainsSubmit( t )
{
	if( checkDomain( t.site ) == false )
		return false;
	if( checkDomain( t.domain ) == false )
		return false;
	if( t.site.value == "" )
	{
		alert( "You must specify a site" );
		return false;
	}
}


function CreateBookmarkLink() {

	title = document.title; 
	url = window.location.toString();
	if (window.sidebar) { // Mozilla Firefox Bookmark
	window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
	window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
	return true; }
}


function makeDeliciousLink()
{
	window.open( "http://del.icio.us/post?url="+escape(window.location.toString())+"&title="+escape(document.title), '_blank', '' );
}


function doPopup( url, target, width, height, x, y, features )
{
	features = ( features ? features : '' );
	if( target )
		features += ', toolbar=no';
	if( width && target )
		features += ', width=' + width;
	if( height && target )
		features += ', height=' + height;
	if( x && target )
		features += ', left=' + x;
	if( y && target )
		features += ', top=' + y;
	window.open( url, ( target ? '_blank' : '_self' ) , features );
}

var norTabs = {
	init: function( defaultTab, currentTab, prefix, postfix, seperator, idPrefix )
	{
		if( currentTab != '' )
			defaultTab = currentTab;
		
		this.prefix = prefix;
		this.postfix = postfix;
		this.seperator = seperator;
		this.idPrefix = idPrefix;
		this.current = defaultTab;
		this.tabs = document.getElementsByClassName( 'hovertabs' );
		
		this.resetTabs();
		this.clickTab( defaultTab );
	},
	
	resetTabs: function()
	{
		for( i = 0; i < this.tabs.length; i++ )
		{
			$(this.tabs[i].id).up('li').removeClassName('active_tab');
			id = this.tabs[i].id.replace( this.idPrefix, "" );
//			this.tabs[i].src = this.makeUrl( id, 'blur' );
			document.getElementById( id + "_tab" ).style.display = 'none';
		}
	},
	
	makeUrl: function( id, action )
	{
		return this.prefix + id + this.seperator + action + this.postfix;
	},
	
	doImage: function( id, action )
	{
		if( img = document.getElementById( this.idPrefix + id ) )
			img.src = this.makeUrl( id, action );
	},
	
	focusTab: function( id )
	{
		if( id != this.current )
			this.doImage( id, 'over' );
	}, 
	
	blurTab: function( id )
	{
		if( id != this.current )
			this.doImage( id, 'blur' );
	},
	
	clickTab: function( id )
	{
		this.resetTabs();
		this.current = id;
		if( img = document.getElementById( this.idPrefix + id ) ) {
			img.src = this.makeUrl( id, 'over' );
			$(img).up('li').addClassName('active_tab');
		}
		document.getElementById( id + "_tab" ).style.display = 'block';
	}
}

function selectSort( obj, sortBy )
{
	sortBy = ( sortBy ? sortBy : '' );
    url = window.location.toString();
	
	// Add our sort info to the URL
    if (url.match(/sort=/))
    {
        url = url.replace(/sort=[a-z]+/, "sort=" + obj.value);
    } else if( url.match(/\?/) ) {
        url += "&sort=" + obj.value;
    } else {
        url += "?sort=" + obj.value;
	}

	// If we are on a particular page, reset that
    if (url.match(/pn=[0-9]+&/))
    {
        url = url.replace(/pn=[0-9]+&/, "");
    }

	// If a form was passed, then submit it.
	// Otherwise, go to the URL directly.
	if( sortBy && document.getElementById( sortBy ) )
	{
		document.getElementById( sortBy ).submit();
	} else {
		window.location.replace(url);
	}
}

function selectNumPP( obj )
{
    url = window.location.toString();
    if (url.match(/numPP=/))
    {
        url = url.replace(/numPP=[al0-9]+/, "numPP=" + obj.value);
    } else if( url.match(/\?/) ) {
        url += "&numPP=" + obj.value;
    } else {
        url += "?numPP=" + obj.value;
	}

    if (url.match(/pn=[0-9]+&/))
    {
        url = url.replace(/pn=[0-9]+&/, "");
    }
    window.location.replace(url);
}

function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

function viewQuote(id)
{
	return false;
}

function deleteQuote(id)
{
	row = document.getElementById(id);
	row.parentNode.deleteRow(row.sectionRowIndex);

    // Send the user's info to the database
    ajax = new Ajax.Request('/ajax.php', {
        method: 'get',
        parameters: {
            requestType: 'myAccountQuoteDelete',
            quoteid: id
        },
        onFailure: function(){ alert('The system could not change the category...') }
    });

	return false;
}

function printPage()
{
	window.print();
}


function resizeFloaters( d )
{
	if( d.length > 0 )
	{
		m = 0;
		// Find the tallest box and set all boxes to have the same height
		for( i = 0; i < d.length; i++ )
			m = ( m > d[i].clientHeight ? m : d[i].clientHeight )
		for( i = 0; i < d.length; i++ )
			d[i].style.height = m;  
	}
}

function resizeMe()
{
	resizeFloaters( document.getElementsByClassName( 'productFloat' ) );
	resizeFloaters( document.getElementsByClassName( 'categoryFloat' ) );
	resizeFloaters( document.getElementsByClassName( 'searchResultFloat' ) );
	resizeFloaters( document.getElementsByClassName( 'imageFloat' ) );
}

//Make the layout of the media boxes uniform, works from top-down, inside-out
//   accepts an unlimited number of class names and processes them in order (period prefix denoes class name)
//   can accept any element/identifier that Prototype's $$ method can enumerate
function makeUniform()
{
	var areas = makeUniform.arguments;
	
	for (var area=0; area < areas.length; area++) {
		var dim = 0;
		var d = $$(areas[area]);
		
		if (d.length > 0) {
			// Find the tallest area for the class
			for( i = 0; i < d.length; i++ ) {
				if ($(d[i]) == null) continue;
				dim = (dim > d[i].getHeight()) ? dim : d[i].getHeight();
			}
			
			// Set all areas with same class to have the same height
			for( i = 0; i < d.length; i++ ) {
				if ($(d[i]) == null) continue;
				d[i].setStyle('height :'+dim+'px;');
			}
		}
	}
}

function clearSearch()
{
	var sFields = document.getElementsByClassName( 'search_form_field' );
	for( i = 0; i < sFields.length; i++ )
	{
	}
}

function viewImprintColors( v )
{
	document.getElementsByClassName( 'imprintColors' )[0].style.display = ( v == true ? 'block' : 'none' );
}

function flashSave( id )
{
	d = document.getElementById( id );
	d.innerHTML = 'Saved';
	showSave( id );
	setTimeout( "hideSave('"+id+"')", 500 ); 
	setTimeout( "showSave('"+id+"')", 1000 );
	setTimeout( "hideSave('"+id+"')", 1500 ); 
	setTimeout( "showSave('"+id+"')", 2000 );
	setTimeout( "hideSave('"+id+"')", 2500 ); 
	setTimeout( "showSave('"+id+"')", 3000 );
	setTimeout( "hideSave('"+id+"')", 3500 ); 
	setTimeout( "showSave('"+id+"')", 4000 );
	setTimeout( "hideSave('"+id+"')", 4500 ); 
}
function showSave(id){ document.getElementById( id ).style.display = 'block'; }
function hideSave(id){ document.getElementById( id ).style.display = 'none'; }


function NRWD_ArtTransferOpenWindow(mylink){
    window.open(mylink, '_blank', config='status=no,menubar=no,location=no,toolbar=no,resizable=yes,scrollbars=yes,left=10,top=10,screenX=0,screenY=0,width=600,height=600'); 
}
<!--function art transfer open custom window end -->
<!--function order status open custom window start -->
function NRWD_OrderStatusOpenWindow(mylink){
        window.open(mylink, '_blank', config='status=no,menubar=no,location=no,toolbar=no,resizable=yes,scrollbars=yes,left=10,top=10,screenX=0,screenY=0,width=600,height=300'); 
}
<!--function order status open custom window end -->

/*	
 * Will Fastie 
 * http://www.ptcto.com/cto/essays/nobots.htm#nobotscode
 */
function nb(ename, edomain, edisplay, esubj, showOnly) {
  // Written by Will Fastie, 06 Feb 2006
  var subj = "?subject=", atsign = "@";
  var addr = ename + atsign + edomain;
  var display = addr;
  if( showOnly ) {
  	document.write( addr );
  	return;
  }
  if (((arguments.length == 4) || (arguments.length == 3)) && (edisplay != "")) {
    display = edisplay;
  }
  if ((arguments.length == 4) && (esubj != "")) {
  	addr = addr + subj + esubj;
  }
  document.write( "<a " +  " href=\"mailto:" + addr + "\">" + display + "</a>");
}

function cssHide( id )
{
	c = document.getElementsByClassName( id );
	for( i = 0; i < c.length; i++ )
		c[i].style.display = 'none';
}

function cssShow( id )
{
	c = document.getElementsByClassName( id );
	for( i = 0; i < c.length; i++ )
		c[i].style.display = 'block';
}

function refresh(){window.location.href=window.location.href;}


