// JavaScript Document
var PageInfo = function(){};
PageInfo.getPageSizeWithScroll = function(){
	if( typeof window.innerHeight == 'number' && typeof window.scrollMaxY == 'number' ){ // Firefox 
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}else if( document.body.scrollHeight > document.body.offsetHeight ){ // all but Explorer Mac
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}else{ // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		pageWidth = document.body.offsetWidth + document.body.offsetLeft;
		pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}
	pageWidth = Math.max(pageWidth,document.documentElement.clientWidth);
	pageWidth = Math.max(pageWidth,document.body.clientWidth);
	pageHeight = Math.max(pageHeight,document.documentElement.clientHeight);
	pageHeight = Math.max(pageHeight,document.body.clientHeight);
	return new Array(pageWidth,pageHeight);
};
PageInfo.getViewPortSize = function(){
	var xViewPort = self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
	var yViewPort = self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
	arrayViewPortSize = new Array(xViewPort,yViewPort);
	return arrayViewPortSize;
};
PageInfo.getPageCornerCoord = function(){
	var pageSizeWithScroll = PageInfo.getPageSizeWithScroll();
	var xCornerCoord = pageSizeWithScroll[0] - pageSizeWithScroll[0] + document.body.scrollLeft + document.documentElement.scrollLeft;
	var yCornerCoord = pageSizeWithScroll[1] - pageSizeWithScroll[1] + document.body.scrollTop + document.documentElement.scrollTop;
	arrayPageCornerCoord = new Array(xCornerCoord,yCornerCoord);
	return arrayPageCornerCoord;
};

/* This function will submit a form via a link */
/* PARAM1: The id of the form */
/* PARAM2: The controller to be called when submitting the form */
function submitAction(pForm,controller) {
  var forms = document.forms;
  var form = null;
  for (var i = 0; i < forms.length; i++) {
    if (forms[i].id == pForm) {
      form = forms[i];
    }
  }
  if ( controller != null ) {
    form.action=controller;
  }
  form.target=window.name;
  form.submit();
}

/* This function sets the 'action' attribute of a form and then submits it.
 * This method should be used in place of submitAction() because it does not
 * rely on the form having a 'name' attribute, which is a depricated attribute in
 * XHTML Strict. - jfranks */
/* pFormId: ID of the form */
/* pAction: Action to set the form to */
function submitActionById(pFormId, pAction) {
	
	wForm = document.getElementById(pFormId);
	
	wForm.action = pAction;
	wForm.submit();
	
}

/* This function will toggle any element to display or not */
/* PARAM1: The id of the element that you want to show or hide */
/* PARAM2: The attribute value of the display style */
function toggleElement( pId, pAttribute ) {
	var wElement = document.getElementById(pId);
	if ( wElement != null ) {
		if ( wElement.style.display=='none' ) {
			wElement.style.display=pAttribute;
		} else {
			wElement.style.display='none';
		}
	}
}

/* This function will show any element*/
/* PARAM1: The id of the element that you want to show or hide */
/* PARAM2: The attribute value of the display style */
function showElement( pId, pAttribute ) {
	var wElement = document.getElementById(pId);
	if ( wElement != null ) {
		wElement.style.display=pAttribute;
	}
}

/* This function will hide any element*/
/* PARAM1: The id of the element that you want to show or hide */
function hideElement( pId ) {
	var wElement = document.getElementById(pId);
	if ( wElement != null ) {
		wElement.style.display='none';
	}
}

/* This function will show the help info depending on the selected region */
/* PARAM1: The number of the region selected */
function showHelpInfo( pHelpNo ) {
	var wPhoneInfo = document.getElementById('helpInfo');
	var wEmailInfo = document.getElementById('helpInfoEmail');
	var wSelectedRegion = document.getElementById('helpSelectedRegion');
	var wHelpInfoInnerHTML;
	var wHelpSelectedRegionInnerHTML;
	var wHelpInfoEmailInnerHTML;
	
	document.getElementById('viewRegions').style.display='none';
	
	if ( pHelpNo == 'USA' ) {
		wHelpInfoInnerHTML = '<span class="phoneHelp">&nbsp;&nbsp;1.800.221.4435<br/>+1.970.262.7200</span>';
		wHelpInfoEmailInnerHTML = '<span class="emailHelp"><a href="mailto:usa@polygon.net" class="ie6Fix">usa@polygon.net</a><br />&nbsp;</span>';
		wHelpSelectedRegionInnerHTML = 'USA';
	} else if ( pHelpNo == 'Canada' ) {
		wHelpInfoInnerHTML = '<span class="phoneHelp">&nbsp;&nbsp;1.800.221.4435<br/>+1.450.463.8926</span>';
		wHelpInfoEmailInnerHTML = '<span class="emailHelp"><a href="mailto:canada@polygon.net" class="ie6Fix">canada@polygon.net</a><br />&nbsp;</span>';
		wHelpSelectedRegionInnerHTML = 'Canada';
	} else if ( pHelpNo == 'UK' ) {
		wHelpInfoInnerHTML = '<span class="phoneHelp">00.800.7765.9466<br />&nbsp;</span>';
		wHelpInfoEmailInnerHTML = '<span class="emailHelp"><a href="mailto:international@polygon.net" class="ie6Fix">international@polygon.net</a><br />&nbsp;</span>';
		wHelpSelectedRegionInnerHTML = 'UK';
	} else if ( pHelpNo == 'International' ) {
		wHelpInfoInnerHTML = '<span class="phoneHelp">+1.970.262.7200<br />&nbsp;</span>';
		wHelpInfoEmailInnerHTML = '<span class="emailHelp"><a href="mailto:international@polygon.net" class="ie6Fix">international@polygon.net</a><br />&nbsp;</span>';
		wHelpSelectedRegionInnerHTML = 'International';
	}
	wSelectedRegion.innerHTML = wHelpSelectedRegionInnerHTML;
	wPhoneInfo.innerHTML = wHelpInfoInnerHTML;
	wEmailInfo.innerHTML = wHelpInfoEmailInnerHTML;
}

function uncheckAllCheckBox( pCheckBoxAllId ) {
	document.getElementById(pCheckBoxAllId).checked = false;
}

function selectAllCheckBox( pFormId, pElementId, pCheckBoxAllId ) {
	if ( document.getElementById(pFormId) != null ) {
		var wForm = document.getElementById(pFormId);
		for ( var x=0; x < wForm.length; x++ ) {
			if ( (wForm[x].type == 'checkbox') && (wForm[x].id.indexOf(pElementId) == 0) && (wForm[x].id != pCheckBoxAllId) ) {
				wForm[x].checked=false;
			}
		}
	}
}

/* This function will show the help info depending on the selected region */
/* PARAM1: The number of the region selected */
function showContactInfo( pContactInfoName ) {
	document.getElementById('contactInfoViewRegions').style.display='none';

	var wContactInfoPhoneInnerHTML;
	var wContactInfoFaxInnerHTML;
	var wContactInfoRegionInnerHTML;
	
	if ( pContactInfoName == 'USA' ) {
		wContactInfoPhoneInnerHTML = '<span>1.800.221.4435<br />+1.970.262.7200</span>';
		wContactInfoFaxInnerHTML = '<span>Fax:<br/>+1.970.262.7201</span>';
		wContactInfoRegionInnerHTML = 'USA';
	} else if ( pContactInfoName == 'Canada' ) {
		wContactInfoPhoneInnerHTML = '<span>1.800.221.4435<br/>+1.450.463.8926</span>';
		wContactInfoFaxInnerHTML = '<span>Fax:<br/>+1.970.262.7201</span>';
		wContactInfoRegionInnerHTML = 'Canada';
	} else if ( pContactInfoName == 'UK' ) {
		wContactInfoPhoneInnerHTML = '<span>00.800.7765.9466<br />&nbsp;</span>';
		wContactInfoFaxInnerHTML = '<span>Fax:<br/>+1.970.262.7201</span>';
		wContactInfoRegionInnerHTML = 'UK';
	} else if ( pContactInfoName == 'International' ) {
		wContactInfoPhoneInnerHTML = '<span>+1.970.262.7200<br />&nbsp;</span>';
		wContactInfoFaxInnerHTML = '<span>Fax:<br/>+1.970.262.7201</span>';
		wContactInfoRegionInnerHTML = 'International';
	}
	var wPhoneInfo = document.getElementById('contactInfoPhone');
	wPhoneInfo.innerHTML = wContactInfoPhoneInnerHTML;
	var wFaxInfo = document.getElementById('contactInfoFax');
	wFaxInfo.innerHTML = wContactInfoFaxInnerHTML;
	var wSelectedRegion = document.getElementById('contactInfoSelectedRegion');
	wSelectedRegion.innerHTML = wContactInfoRegionInnerHTML;
}

function stoned( pSelected, pSelectedSearchId, pSelectedMenuId) {
	var stone = new Array("diamond","jewelry","coloredStone","watch");
	for(var i=0;i<=stone.length-1;i++){
		if(document.getElementById(stone[i] + 'Search')) {
			document.getElementById(stone[i] + 'Search').className = stone[i] + 'Search';
		}
	}	
	document.getElementById(pSelectedSearchId + 'Search').className += ' current';

	var menuIds = new Array(
    "POG_MENU_PRODUCTS_QUICKSEARCH_DIAMOND",
    "POG_MENU_PRODUCTS_QUICKSEARCH_COLOREDSTONE",
    "POG_MENU_PRODUCTS_QUICKSEARCH_JEWELRY",
    "POG_MENU_PRODUCTS_QUICKSEARCH_WATCH");
	for(var i=0;i<=menuIds.length-1;i++){
		if(document.getElementById(menuIds[i])) {
			document.getElementById(menuIds[i]).className = '';
		}
	}
	document.getElementById(pSelectedMenuId).className = 'current';
    
    // URL
	// /pog-products-quick.search.content-en.jsa?SearchType=Diamond&ContentType=Details
	var contentLoader = new ContentLoader('/pog-quick.search-quick.search.content-en.jsa?SearchType=' + pSelected + '&ContentType=' + 'ContentBox', 'ContentBox');
	contentLoader.start();
	var formLoader = new ContentLoader('/pog-quick.search-quick.search.content-en.jsa?SearchType=' + pSelected + '&ContentType=' + 'FormBox', 'FormBox');
	formLoader.start();
	var formFooterLoader = new ContentLoader('/pog-quick.search-quick.search.content-en.jsa?SearchType=' + pSelected + '&ContentType=' + 'FormFooterBox', 'FormFooterBox');
	formFooterLoader.start();
	var detailsLoader = new ContentLoader('/pog-quick.search-quick.search.content-en.jsa?SearchType=' + pSelected + '&ContentType=' + 'DetailsBox', 'DetailsBox');
	detailsLoader.start();
	/*
	var options = new Object();
	options.callback4=function()
	{
	    //Trim before setting in title
	    document.title=headerLoader.text.replace(/^\s+|\s+$/g, '');
	}
	var headerLoader = new ContentLoader('/pog-quick.search-quick.search.content-en.jsa?SearchType=' + pSelected + '&ContentType=' + 'Header','Header',options);
	headerLoader.start();
	*/
}


function imgPreview(pThumbId, pPreview, pMainImage, pType) {
    var wThumb = document.getElementById(pThumbId);
    var wPreviewImage = document.getElementById('previewPic');
    var wPreviewA = document.getElementById('previewA');
    var wPreviewImageHeight = wPreviewImage.height;
	var wPreviewImageWidth = wPreviewImage.width;
	  
    var thumbs = new Array("thumb1","thumb2","thumb3" );

	for(var i=0;i<=thumbs.length-1;i++){
	    var wCurThumb = document.getElementById(thumbs[i]);
	    if(	wCurThumb != null) {
            wCurThumb.className = '';
	    }
	}
	
    if(	wThumb != null) {
        wThumb.className = 'current';
    }
    wPreviewImage.src = pPreview;
    
    if ( pType == 'IMAGE' || pType == 'IMAGE_CONVERSION' ) {
        var wMainImage = document.getElementById('mainImage');
        
        wMainImage.innerHTML = "<table><tr><td><div id='mainPic'><img src='" + pMainImage + "' alt='' /></div></td></tr></table><img id='close' alt='Close' src='/cgi/en/img/close.png'/>";
        
        wPreviewA.href = "javascript:divPopUp('mainImage');";
        wPreviewA.target = '_self';
    } else {
        wPreviewA.href = pMainImage;
        wPreviewA.target = '_blank';
    }
}


function divPopUp(pElementId){
	showOrHideAllSelects("hidden");
    var state 	= document.getElementById('greyBox').style.display;
    if(document.getElementById)	{
      if (state == 'none') {
        state = 'block';
      }	else	{
         state = 'none';
      }

        var pHeight = 800;
    	var pWidth = 800;
        var wGreyBoxPadding = 50;
        
		var top = (PageInfo.getPageCornerCoord()[1] + ((PageInfo.getViewPortSize()[1] - pHeight)/2));
    	top = Math.max(top,PageInfo.getPageCornerCoord()[1]);
		document.getElementById(pElementId).style.left = (PageInfo.getPageCornerCoord()[0] + ((PageInfo.getViewPortSize()[0] - pWidth)/2))+'px';
		document.getElementById(pElementId).style.top = top+'px';
		document.getElementById(pElementId).style.display = state;
		document.getElementById('greyBox').style.height = Math.max(PageInfo.getPageSizeWithScroll()[1],(PageInfo.getPageCornerCoord()[1]+pHeight+wGreyBoxPadding)) + 'px';
		document.getElementById('greyBox').style.display = state;
    }
}

function openWindow( pURL, pWidth, pHeight, pScrollbars ) {
    if (typeof pScrollbars == "undefined") {
        pScrollbars = "no";
    }
    popWin = window.open( "", "Agreement", "width=" + pWidth + ",height=" +  pHeight + ",dependent=yes,scrollbars=" + pScrollbars + ",resizable=1" );
    popWin.location.replace( pURL );
    popWin.moveTo(0,0);
    popWin.focus();
}

function externalLinks() {

	if (!document.getElementsByTagName) return;

		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		var relvalue = anchor.getAttribute("rel");

		if (anchor.getAttribute("href")) {
			var external = /external/;
			var relvalue = anchor.getAttribute("rel");
			if (external.test(relvalue)) { anchor.target = "_blank"; }
		}
	}
}

function submitOnEnter(pField, pEvent)
{
    var keycode = 0;
    if (window.event) {
        keycode = window.event.keyCode;
    } else if (pEvent) {
        keycode = pEvent.which;
    }

    if (keycode == 13) {
       pField.form.submit();
    }
}

function disableSelection(element) {
    element.onselectstart = function() {
        return false;
    };
    element.unselectable = "on";
    element.style.MozUserSelect = "none";
    element.style.cursor = "default";
}

function notifyListeners() {
	if(typeof addLoadListener.listeners != 'undefined'){
		for (var i = 0; i < addLoadListener.listeners.length; i++) {
			addLoadListener.listeners[i]();
		}
	}
}
function addLoadListener(fn) {
	if(typeof addLoadListener.listeners == 'undefined'){
		addLoadListener.listeners=[];
	}
	if(addLoadListener.listeners.length == 0) {
		if (typeof window.addEventListener != 'undefined') {
			window.addEventListener('load', notifyListeners, false);
		} else if (typeof document.addEventListener != 'undefined') {
			document.addEventListener('load', notifyListeners, false);
		} else if (typeof window.attachEvent != 'undefined') {
			window.attachEvent('onload', notifyListeners);
		} else {
			var oldfn = window.onload;
			if (typeof window.onload != 'function') {
				window.onload = notifyListeners;
			} else {
				window.onload = function() { oldfn(); notifyListeners(); };
			}
		}
	}
	addLoadListener.listeners[addLoadListener.listeners.length]=fn;
}		

function updateErrorColors() {
	var labels = document.getElementsByTagName( 'label' );
	for ( var i = 0; i < labels.length; i++ ) {
		labels[i].className = labels[i].className.replace( 'error','' );
	}

	var inputs = document.getElementsByTagName( 'input' );
	for ( var i = 0; i < inputs.length; i++ ) {
		if( ( inputs[i].type == 'hidden' ) && ( inputs[i].name.indexOf( 'error_msg' ) == 0 ) ) {
				var forName = inputs[i].value.replace( 'Code','' );
				var forName2 = inputs[i].value.replace( 'Code','' ).replace( 'Max','' ).replace( 'Min','' );
			for ( var j = 0; j < labels.length; j++ ) {
					var labelFor = labels[j].htmlFor.replace( 'Code','' );
					var labelFor2 = labels[j].htmlFor.replace( 'Code','' ).replace( 'Max','' ).replace( 'Min','' );
				if( labelFor == forName || labelFor == forName2 || forName == labelFor2 ) {
					if( labels[j].className != null ) {
						if(labels[j].className.indexOf('error') < 0) {
							labels[j].className = labels[j].className + ' error';
						}
					} else {
						labels[j].className = 'error';
					}
				}
			}
		}
	}
}

function generateHiddenParams(hiddenId , paramMap){
	var hiddenDiv = document.getElementById(hiddenId);
	var newHiddenDiv = "";
	for ( i in paramMap ) {
		var paramName = paramMap[i][0];
		var paramValue = paramMap[i][1];
		if(paramName){
			var element = document.getElementById(paramName);
			var names = document.getElementsByName(paramName);
			if(!element && (names.length==0)){
				newHiddenDiv += '<input type="hidden" name="'+paramName+'" id="'+paramName+'" value="'+paramValue+'"/>';
			}
		}
	}
	hiddenDiv.innerHTML=newHiddenDiv;
}

function printPage () {
    var printOptions = document.getElementById("printOptions");
    if ( printOptions == null ) {
        window.print();
    } else {
        if (printOptions.style.display=="none") {
            if ( document.getElementById("savedSearchId") ) {
                document.getElementById("savedSearchId").style.visibility="hidden";
            }
            if ( document.getElementById("bannerVert") ) {
                document.getElementById("bannerVert").style.visibility="hidden";
            }
            printOptions.style.display="block";
        } else {
            printOptions.style.display="none";
            if ( document.getElementById("savedSearchId") ) {
                document.getElementById("savedSearchId").style.visibility="";
            }
            if ( document.getElementById("bannerVert") ) {
                document.getElementById("bannerVert").style.visibility="";
            }
        }
    }
}

function showOrHideAllSelects() {
	var wSelects = document.getElementsByTagName("select");
	for (var i=0;i<wSelects.length;i++) {
		if(wSelects[i].style.visibility == 'hidden' ) {
			wSelects[i].style.visibility='';
		}else{
			wSelects[i].style.visibility='hidden';
		}
	}
	showOrHideAllFlashObjects();
}

function showOrHideAllFlashObjects() {
	var wFlash = document.getElementsByTagName("object");
	for (var i=0;i<wFlash.length;i++) {
		if(wFlash[i].style.visibility == 'hidden' ) {
			wFlash[i].style.visibility='';
		}else{
			wFlash[i].style.visibility='hidden';
		}
	}
}

function showHideDetails( pId ) {
	wElem = document.getElementById( "detail" + pId );
	wElemPlusMinus = document.getElementById( 'plus' + pId );
	wTrExpand = document.getElementById( 'tr' + pId );
	
	if ( wElem != null && wElemPlusMinus != null && wTrExpand != null ) {
		if ( wElem.style.display == 'none' ) {
			wElem.style.display = '';
			wElemPlusMinus.innerHTML = '<img src="/cgi/en/img/resultsMinus.gif" alt="-" />';
			wTrExpand.className += " expand";
		} else {
			wElem.style.display = 'none';
			wElemPlusMinus.innerHTML = '<img src="/cgi/en/img/resultsPlus.gif" alt="+" />';
			wTrExpand.className = wTrExpand.className.replace(/expand/,"");
		}
	}
}

function expandMemberInfo( pClientNo, pRowId, pSellerInfo, pPrintSellerInfo ) {
	var wId = 'memberInfo' + pRowId;
	var wElem = findObject( wId );
	if ( wElem.innerHTML.toLowerCase().indexOf( '<a' ) < 0 ) {
		var wUrlId = 'url' + pRowId;
		var wUrlElem = findObject(wUrlId);
		var wParam = 'clientNo=' + pClientNo + '&sellerInfo=' + pSellerInfo + '&url=' + escape( wUrlElem.value );
		
		if ( typeof pPrintSellerInfo == 'string' ) {
			wParam += '&printSellerInfo=' + pPrintSellerInfo;
		}
		
		var contentLoader = new ContentLoader( '/pog-member.info-expanded.member.info-en.jsa', null, wParam );
		contentLoader.callback4 = function() {
			var wId = 'memberInfo' + pRowId;
			var wElem = findObject( wId );
			wElem.innerHTML = wElem.innerHTML + contentLoader.text;
			showHideDetails( pRowId );
		};
		contentLoader.start();
	} else {
		showHideDetails( pRowId );
	}
}

function moveDivs(){
	moveElementInBody('greyBox');
	moveElementInBody('mainImage');
}

function moveElementInBody(id){
	var toMove = document.getElementById(id);
	toMove = toMove.parentNode.removeChild(toMove);
	document.body.appendChild(toMove);
}

function flip(e){
	document.getElementById('loadingImageDiv').style.display='none';
	document.getElementById('imageDiv').style.display='block';
}

function flipIe(e){
	var img = document.getElementById('image');
	if(img.readyState == "complete"){
		document.getElementById('loadingImageDiv').style.display='none';
		document.getElementById('imageDiv').style.display='block';
	}
}

function loadImage(url){
	document.getElementById('imageDiv').style.display='none';
	document.getElementById('loadingImageDiv').style.display='block';
	divPopUp('mainImage');

	var img = document.getElementById('image');
	img.onload=flip;
	img.onreadystatechange=flipIe;
	img.src = url;
}

function openCloseAllDetails(pOpen) {
	var wTrArray = document.getElementsByTagName( 'tr' );
	
	for ( var i = 0; i < wTrArray.length; i++ ) {
		if ( wTrArray[i].className.indexOf( 'openable' ) > -1 ) {
			var wId = wTrArray[i].id.substring( 2 );
			var wIsClosed = document.getElementById( "detail" + wId ).style.display == 'none';
			if(wIsClosed == pOpen){
				showHideDetails(wId);
			}
		}
	}
}

function saveSetting( pSettingCode, pSettingValue ) {
	if ( typeof pSettingCode == 'string'  ) {
		var wContentLoader = new ContentLoader( "/pog-diamond.search-save.setting-en.jsa?settingCode=" +
												pSettingCode + "&settingValue=" + pSettingValue);
		
		wContentLoader.start();
	} else {
		alert('saveSetting wrong !!!');
	}
}

function formatPreTagForHtml( pId ) {
    var wPre = document.getElementById(pId);
    if ( wPre != null ) {
        var wText = wPre.innerHTML;
        wPre.innerHTML = wText.replace(/\n/g,"&#160;<br />");
    }
}

function moreLess(name) {
	if(typeof name == 'undefined') {
		name='';
	}
	var more = document.getElementById(name+'MoreButton');
	var less = document.getElementById(name+'LessButton');
	var moreLess = document.getElementById(name+'MoreInnerHTML');
	var moreLessHidden = document.getElementById(name+'LessHidden');

    if ( moreLess != null && moreLessHidden != null ) {
    	var text = moreLess.innerHTML;
    	moreLess.innerHTML = moreLessHidden.innerHTML;
    	moreLessHidden.innerHTML = text;
    
    	if(more.style.display=='none') {
    		more.style.display='';
    		less.style.display='none';
    	} else {
    		more.style.display='none';
    		less.style.display='';
    	}
    }
}

function showMessageLight( pBoxId, pMessageId, pSwitch ) {
    if ( pSwitch == 'show' ) {
        var height;
        if ( window.innerHeight ) {
            height = window.innerHeight;
        } else if ( document.documentElement && document.documentElement.clientHeight ) {
            height = document.documentElement.clientHeight;
            width = document.documentElement.clientWidth;
            document.getElementById(pBoxId).style.width = '955px' ;
            document.getElementById(pMessageId).style.position = 'absolute' ;
            document.getElementById(pMessageId).style.top = 200+'px';
        } else if ( document.all ) {
            height = document.body.clientHeight;
            width = document.body.clientWidth;
            document.getElementById(pBoxId).style.width = '955px' ;
        }
        document.getElementById(pBoxId).style.height = '100%' ;
        document.getElementById(pBoxId).style.display='';
        document.getElementById(pMessageId).style.display='';
    } else {
        document.getElementById(pBoxId).style.display='none';
        document.getElementById(pMessageId).style.display='none';
    }
}
function switchSectionsSimple( sectionToHide, sectionToShow ) {
  var wSectionToHide = document.getElementById( sectionToHide );
  var wSectionToShow = document.getElementById( sectionToShow );
  wSectionToHide.style.display = "none";
  wSectionToShow.style.display = "";
}

function trim( pText) {
	return pText.replace(/^\s+|\s+$/g, '');
}

function addClass( node, className){
	if(!node.className){
		node.className = className;
	}
	if(node.className.indexOf(className)==-1){
		node.className = node.className + ' ' + className;
	}
}

function removeClass(node, className){
	if(node.className){
		if(node.className.indexOf(className)!=-1){
			node.className = trim(node.className.replace(className,''));
		}
	}
}
