/* verify a link with a javascript dialog */
function verifyClick( message ) {
	if( typeof( message ) == 'string' ) {
		return confirm( message );
	} 

	return confirm( "Are you sure you want to delete this item?" );
}

/* create a popup with the provided link, window, width and height */
function sizedPopup( linkname, windowname, ww, wh ) {
	var href;

	if( !window.focus ) return true;

	if( typeof( linkname ) == 'string' ) { href = linkname; }
	else { href = linkname.href; }

	window.open( href, windowname, 'width='+ ww +', height= '+ wh +' ,scrollbars=no, resizable=no');

	return false;
}

/* image rollover code */
function changeImage( imageName, newImage ) {
	if( document.images ) {
		document[ imageName ].src = newImage;
	}
}

/* use css/dhtml to display or hide page elements */
var currentTabId = 'imageTab';
function showTab( tabId, top, left ) {
        if( document.getElementById( tabId ) ) {
		hideTab( currentTabId );
                document.getElementById( tabId ).style.display = 'block';
				document.getElementById( tabId ).style.top=top;
				document.getElementById( tabId ).style.left=left;
                currentTabId = tabId;
        }
        return false;
}
function hideTab( tabId ) {
        if( document.getElementById( tabId ) ) {
                document.getElementById( tabId ).style.display = 'none';
        }
        return false;
}
function showTab2( tabId, top, left ) {
        if( document.getElementById( tabId ) ) {
			if(tabId=='specificationsTab'){
				hideTab( 'imageTab' );
                document.getElementById( 'specificationsTab' ).style.display = 'block';
				document.getElementById( 'specificationsTab' ).style.top=top;
				document.getElementById( 'specificationsTab' ).style.left=left;
                //currentTabId = tabId;
			}
			else{
				hideTab( 'specificationsTab' );
                document.getElementById( 'imageTab' ).style.display = 'block';
				document.getElementById( 'imageTab' ).style.top=top;
				document.getElementById( 'imageTab' ).style.left=left;
			}
        }
        return false;
}


function updateSelectList( key, selected, selectObj, selectArray ) {
	//alert( '('+key+')('+selected+')('+selectObj+')('+selectArray+')' );
	// remove all children
	while ( selectObj.hasChildNodes() ) { selectObj.removeChild ( selectObj.firstChild ); }

	// create new children
	
	var catArray = selectArray[key];	

	for( optionVal in catArray ) {
		if(optionVal.length==2){
			newOption = document.createElement( 'OPTION' );
			newOption.setAttribute( 'value', optionVal );
			newOption.appendChild( document.createTextNode( catArray[ optionVal ] ) );
			if( catArray[ optionVal ] == selected ) { newOption.defaultSelected = true; }
			else { newOption.defaultSelected = false; }
			selectObj.appendChild( newOption );
		}
	}
}

function gotourl(url){
	window.location.href=url;
}
