var pc = navigator.userAgent.toLowerCase();
var is_ie4_win = (pc.indexOf("win")!=-1) && (pc.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >= 4);
var is_gecko = pc.indexOf("gecko/") != -1 && parseFloat(pc.substring(pc.indexOf("gecko/") + 6, pc.indexOf("gecko/") + 14)) > 20030108;

function getElement( pForm, pName ) {

    var wElements = pForm.elements;
    for ( var i = 0; i < wElements.length; i++ ) {
        if ( wElements[ i ].name == pName ) {
            return  wElements[ i ];
        }
    }
    return null;
}


function findObject( pElementId ) {
    if ( document.getElementById ) {
        return document.getElementById( pElementId );
    } else if ( document.all ) {
        return document.all[ pElementId ];
    } else {
        return { style: {} };
    }
}
		
function resetRadioFormField( pForm, pFieldName, pRadioFieldValue ){
	
	var wx = pForm.elements.length;
	for ( x = 0; x < wx; x++ ) {
		if ( pForm.elements[x].name == pFieldName ) {
			if ( pForm.elements[x].type == "radio" && pForm.elements[x].value == pRadioFieldValue ) {

				pForm.elements[x].checked = true;
			}
		}	
	}

}

var newWindow
function viewPrinterFriendlyVersion( pController, pForm ) {

	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

  if ( !newWindow || newWindow.closed ) {
    newWindow = window.open('about:blank','printerFriendlyPage','toolbar=yes,resizable=no,scrollbars=yes,height=500,width=685')
  } else {
    newWindow.focus()
  }  
	form.action=pController;
	form.target=newWindow.name;
	form.submit();

}

/* This is a really useful function you can call when you want to get the params part of a url generated 
 * from all the inputs of a form. 
 * This is used for example in the new Diamond Search in JSA. The search Prep screen 
 * calls the server with an AJAX call (POST method) to get a count of the diamonds matching the criteria but it 
 * needs to put all the inputs of the form in the url.
 * Note that you can pass a String Array in the excluded parameter to exclude certain values from being put in the param String returned. 
 * Again this is used in the new Diamond Search to exclude inputs that have 'Min' and 'Max' values (Default text to help user out).
 */
function paramsQuery( form ,excluded, excludeBlankValues ){

   if( typeof excludeBlankValues == "undefined" ) {
       excludeBlankValues = true;
   } 
   var elems = form.elements;
   var params = new Array();
   for ( i = 0; i < elems.length; i++ ) {
   		if ( elems[i].type == 'textarea' ) {
			if ( elems[i].value.length > 0 || !excludeBlankValues ){
				params.push([elems[i].name,elems[i].value]);
			}
   		} else if ( elems[i].type == 'text' || elems[i].type == 'hidden' ) {
   			var isAParam = true;
   			if( excluded != null ) {
   				for ( j = 0; j < excluded.length; j++ ) {
   					if ( elems[i].value == excluded[j] ) {
   						isAParam = false;
   					}
   				}
   			}
   			if ( isAParam && ( elems[i].value.length > 0 || !excludeBlankValues ) ) {
   				params.push([elems[i].name,elems[i].value]);
   			}
   		} else if ( elems[i].type == 'radio' || elems[i].type == 'checkbox' ) {
   			if ( elems[i].checked ) {
		   		params.push([elems[i].name,elems[i].value]);
		   	}
   		} else if ( elems[i].type == 'select-one'  ){
   			if ( elems[i].value.length > 0 || !excludeBlankValues ) {
				params.push([elems[i].name,elems[i].value]);
			}
   		} else if ( elems[i].type == 'select-multiple' ) {
			var opts = elems[i].options;
			for ( j = 0; j < opts.length; j++ ) {
				if ( opts[j].selected ) {
					if ( opts[j].value.length > 0 || !excludeBlankValues ) {
						params.push([elems[i].name,opts[j].value]);
					}
				}
			}
   		}
   }
   var value = '';
   for ( i = 0; i < params.length; i++ ) {
   		if ( i > 0 ) {
   			value += '&';
   		}
   		// When and if one day we support UTF-8, we should call encodeURIComponent function instead of escape...
   		value += escape(params[i][0])+'='+escape(params[i][1]);
   }
   return value;
}

function viewImages( pController, pForm ) {

	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

  if ( !newWindow || newWindow.closed ) {
    newWindow = window.open('about:blank','imagesPage','toolbar=yes,resizable=yes,scrollbars=yes,height=500,width=760')
  } else {
    newWindow.focus()
  }  
	form.action=pController;
	form.target=newWindow.name;
	form.submit();
}

function viewImagesParam( pController, pForm, pMultiple ) {


	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

	if( pMultiple == 'YES' ){
	
	
	
		day = new Date();
		id = day.getTime();
		
		eval("var page" + id + " = window.open('about:blank', '" + id + "', 'toolbar=yes,resizable=yes,scrollbars=yes,height=500,width=760');");
	
		eval("page" + id + ".focus()" );	
	
		form.action=pController;
		form.target=eval("page" + id + ".name;" );
		form.submit();		
	
	
	} else {



		  if ( !newWindow || newWindow.closed ) {
		    newWindow = window.open('about:blank','imagesPage','toolbar=yes,resizable=yes,scrollbars=yes,height=500,width=760')
		  } else {
		    newWindow.focus()
		  }  
		form.action=pController;
		form.target=newWindow.name;
		form.submit();
	
	}
}

function openCnSearchTab(controller) {
	
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == "CertNetForm") {
			form = forms[i];	
		}
	}
	
	if ( form != null ) {
		document.CertNetForm.action=controller;
		document.CertNetForm.target=window.name;
		document.CertNetForm.submit();
	} else {
	 location.href=controller;
	}
}

function openJnSearchTab(controller) {
	
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == "JewelryNetForm") {
			form = forms[i];	
		}
	}
	
	if ( form != null ) {
		document.JewelryNetForm.action=controller;
		document.JewelryNetForm.target=window.name;
		document.JewelryNetForm.submit();
	} else {
	 location.href=controller;
	}
}

function submitAction(pForm,controller,action1,action2) {

	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

	if ( controller != null ) {
		form.action=controller;
	}
	form.target=window.name;
	form.submit();

	if ( action1 != null ) {
		div1=document.getElementById(action1).style
		if (div1.display=="none") {
			div1.display=""
		} else {
			div1.display="none"
		}
	}
	if ( action2 != null ) {
		div2=document.getElementById(action2).style
		if (div2.display=="none") {
			div2.display=""
		} else {
			div2.display="none"
		}
	}
}




function submitActionFromDropDownList(pForm,pListId) {

	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}
	if ( pListId != null && document.getElementById(pListId).value != '' ) {
        form.action = "/cgi/en/" + document.getElementById(pListId).value;
		form.target=window.name;
		form.submit();
	}
}




function submitActionLink( pURL, pDiv1, pDiv2 ) {

  location.href = pURL;

	if ( pDiv1 != null ) {
		var div1 = document.getElementById( pDiv1 ).style;
		if ( div1.display == "none" ) {
			div1.display = "";
		} else {
			div1.display = "none";
		}
	}

	if ( pDiv2 != null ) {
		var div2 = document.getElementById( pDiv2 ).style;
		if ( div2.display == "none" ) {
			div2.display = "";
		} else {
			div2.display = "none";
		}
	}
}


function submitAction(pForm,controller) {
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

	if ( controller != null ) {
		form.action=controller;
	}
	
	form.target=window.name;
	form.submit();
}

function submitActionLink( pURL ) {

  location.href = pURL;

}



function synchronizeCheckbox(pElementToSynchro,pSourceElement) {
	if(document.getElementById(pSourceElement).checked) {
		document.getElementById(pElementToSynchro).checked=true;
	} else {
		document.getElementById(pElementToSynchro).checked=false;
	}
}

function clearComponent(pComp) {
	document.getElementById(pComp).value='';
}

function synchronizeDropDownList(pForm,pListId,pTargetListId) {

	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

	var wx = form.elements.length;
	for ( x = 0; x < wx; x++ ) {
		if ( form.elements[x].id == pListId ) {
			document.getElementById(pTargetListId).value=form.elements[x].value;
		}	
	}
}

function viewPrinterFriendlyVersionNoSubmit( pController ) {
    newWindow = window.open(pController,'printerFriendlyPage','toolbar=yes,resizable=no,scrollbars=yes,height=500,width=685')
    newWindow.focus()
  
}

var popWin = null;
function openPopWindow( pWinURL, pWinName, pWinFeatures ){
    closePopWin();
    popWin = window.open( "", pWinName, pWinFeatures  );
    popWin.opener = window;
    popWin.opener.name = "opener";    
    popWin.location.href=pWinURL;
}

function popupWindow( pURL, pWindowName, pWindowFeatures ){
openPopWindow( pURL, pWindowName, pWindowFeatures );
}


function openPopWindowParam( pWinURL, pWinName, pWinFeatures, pMulti, pExternalUrl ){

	if ( pExternalUrl == 'YES' ) 
	{
	    if ( navigator.appName == "Microsoft Internet Explorer" ) {
	        // Internet Explorer
	        window.open(pWinURL, target='_blank' );
	    } else {
	        window.open(pWinURL, "no name", "target=_blank,status=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes,scrollbars=yes" );
	    }
		return;
	}

	var id = 'miscWindow';

	if( pMulti == 'YES' ){
	
		day = new Date();
		id = day.getTime();
		
		eval("var page" + id + " = window.open(pWinURL, '" + id + "', pWinFeatures);");
	
	
	} else {
	
		if ( navigator.appName == "Microsoft Internet Explorer" )
		{
			closePopWin();
		    popWin = window.open( pWinURL, pWinName, pWinFeatures  );
		}
		else
		{
		    closePopWin();
		    popWin = window.open( "", pWinName, pWinFeatures  );
		    popWin.opener = window;
		    popWin.opener.name = "opener";    
	    	popWin.location.href=pWinURL;
		}
		
	}




}

function closePopWin(){
  if ( navigator.appName != "Microsoft Internet Explorer" || parseInt( navigator.appVersion ) >= 4 ) {
    if( popWin != null ) {
      if( !popWin.closed ) {
        popWin.close();
      }
    }
  }
}

function submitActionNewWindow( pForm, pController, pWindowName ) {
var newWin
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {

		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}
	
  if ( !newWin || newWin.closed ) {
    newWin = window.open('',pWindowName,'menubar=yes,toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=875,left=0,top=0');
  } 
  
	newWin.focus();
	
	form.action=pController;
	form.target=newWin.name;
	form.submit();

}

function submitActionPrintNewWindow( pForm, pController, pWindowName ) {
var newWin
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {

		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}
	
  if ( !newWin || newWin.closed ) {
    newWin = window.open('',pWindowName,'menubar=yes,toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=875,left=0,top=0');
  } 
  
	newWin.focus();
	
	form.action=pController;
	form.target=newWin.name;
	form.submit();

}

function submitActionNewWindowParam( pForm, pController, pWindowName, pMultiple ) {
	var newWin;
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {

		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}
	
	if( pMultiple == 'YES' ){
	
	
	
		day = new Date();
		id = day.getTime();
		
		eval("var page" + id + " = window.open('about:blank', '" + id + "', 'toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=900,left=0,top=0');");
	
		eval("page" + id + ".focus()" );	
	
		form.action=pController;
		form.target=eval("page" + id + ".name;" );
		form.submit();		
	
	
	
	} else {
	
	
		if ( !newWin || newWin.closed ) {
			newWin = window.open('',pWindowName,'toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=900,left=0,top=0');
		} 

		newWin.focus();

		form.action=pController;
		form.target=newWin.name;
		form.submit();
		
	}

}


function popNewMessageWindow( pController ) {
	openPopWindow( pController, 'writeWindow','toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=800,left=0,top=0');
}

function popNewMessageWindowParam( pController, pUnique ) {

	//alert( "test" );

	var id = 'writeWindow';

	if( pUnique == 'YES' ){
		day = new Date();
		id = day.getTime();
		
		eval("var page" + id + " = window.open(pController, '" + id + "', 'menubar=yes,toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=870,left=0,top=0');");
	
	
	} else {
		openPopWindow( pController, id,'menubar=yes,toolbar=no,status=yes,resizable=yes,scrollbars=yes,height=600,width=870,left=0,top=0');
		
	}
	
}

function popNewPrintWindowParam( pController, pUnique ) {

	var id = 'writeWindow';
	if( pUnique == 'YES' ){
		day = new Date();
		id = day.getTime();
		eval("var page" + id + " = window.open(pController, '" + id + "', 'menubar=yes,toolbar=no,status=no,resizable=yes,scrollbars=yes,height=600,width=695,left=0,top=0');");
	} else {
		openPopWindow( pController, id,'menubar=yes,toolbar=no,status=no,resizable=yes,scrollbars=yes,height=600,width=705,left=0,top=0');
	}
	
}

function viewPrinterFriendlyVersionParam( pController, pForm, pUnique ) {
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

	var day = new Date();
	var windowId = "printerFriendlyPage" + day.getTime();

	if( pUnique == 'YES' ){
		eval("var page" + windowId + " = window.open('about:blank', '" + windowId + "', 'toolbar=yes,resizable=yes,scrollbars=yes,height=500,width=685');");
		eval("page" + windowId + ".focus()" );	
	
		form.action=pController;
		form.target=eval("page" + id + ".name;" );
		form.submit();	
	} else {
		if ( !newWindow || newWindow.closed ) {
			newWindow = window.open('about:blank',windowId,'toolbar=yes,resizable=yes,scrollbars=yes,height=500,width=685')
		} else {
			newWindow.focus()
		}  
		form.action=pController;
		form.target=newWindow.name;
		form.submit();
	}
}


function viewPrinterFriendlyVersionNoSubmitParam( pController, pUnique ) {
	var id = 'printerFriendlyPage';
	
	if( pUnique == 'YES' ){
		day = new Date();
		id = day.getTime();
	}
	
	var newWindow = window.open(pController, id,'menubar=yes,resizable=no,scrollbars=yes,height=500,width=685')
	newWindow.focus()
}

function buySellPopupWindowSubmitAction( pForm, pController, pWindowName ) {
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

	var radioButtonValue = returnValueForSelectedRadioButton( form, 'BuySell.SingleAction');
	
	if ( radioButtonValue == 'Post' )  {
		form.action = pController;
		form.submit();
	} else if ( radioButtonValue == 'Match' )  {
		form.action = pController;
		form.target = window.opener.name;
		form.submit();
		window.opener.focus();
		window.close();
	} else if ( radioButtonValue == 'PostAndMatch' )  {
		form.action = pController;
		form.target = window.opener.name;
		form.submit();
		window.opener.focus();		
		window.close();
	}
	
}

function returnValueForSelectedRadioButton( pForm, pRadioName ) {
 	var wx = pForm.elements.length;
	for ( var x = 0 ; x < wx ; x++ ) {
  		if ( pForm.elements[x].name == pRadioName ) {
  			if ( pForm.elements[x].checked == true ) {
   				return pForm.elements[x].value;
   			}
	    }
	}
	return null;

}

function selectUnSelectCheckBoxes( pForm, pMasterBoxName, pBoxNames ) {
	
	// -- This method will select or unselect all checkboxes sharing the
	// -- the name [pBoxName], It will trim out the index on the input field
	// -- if there is one. Ex: If your input fields are called PogDoc.Doc[0]@docId
	// -- the pBoxName passed should be PogDoc.Doc@docId. The test will trim out
	// -- the [0] to reduce PogDoc.Doc[0]@docId to PogDoc.Doc@docId.

	// -- Find the proper form that we are working with
	var forms = document.forms;
	var form = null;
	for (var i = 0; i < forms.length; i++) {
		if (forms[i].name == pForm) {
			form = forms[i];	
		}
	}

	// -- Detemine the value that is set in the 'master' checkbox
	var checkValue = false;
	var masterBox = getElement( form, pMasterBoxName )
	if ( masterBox.checked == true ) {
		checkValue = true;
	}

	// -- Find all checkboxes in the family and set them to the same value as the 'master' checkbox
    var wElements = form.elements;
    for ( var i = 0; i < wElements.length; i++ ) {
        if ( wElements[ i ].type == 'checkbox' ) {
			var cbName = wElements[ i ].name;
			var beginCbName = cbName.substring( 0, cbName.indexOf( '[' ) );
			var endCbName = cbName.substring( cbName.indexOf( ']' ) + 1 );
            if ( beginCbName + endCbName == pBoxNames ) {
				wElements[ i ].checked = checkValue;
            } 
        }
    }
	
}

function showRows( pPrefix ) {
	if ( is_gecko ) {
		toggleRows( pPrefix, "table-row-group" );
	} else {
		toggleRows( pPrefix, "block" );
	}
}

function hideRows( pPrefix ) {
	toggleRows( pPrefix, "none" );
}

function toggleRows( pPrefix, pDisplay ) {
	var wRows = document.getElementsByTagName( "tbody" );	
	for ( var i = 0; i < wRows.length; i++ ) {
		var wRow = wRows.item( i );
		var wId = wRow.id;
		var wIndex = -1;
		if ( wId != null ) {
			wIndex = wId.indexOf( pPrefix );
		}
		if ( wIndex == 0 ) {			
			wRow.style.display = pDisplay;
		}
	}
}

function toggleRow( pId ) {
	var wRows = document.getElementsByTagName( "tbody" );	
	for ( var i = 0; i < wRows.length; i++ ) {
		var wRow = wRows.item( i );
		var wId = wRow.id;
		if ( wId != null && wId == pId ) {
			if ( wRow.style.display == "none" ) {
				if ( is_gecko ) {
					wRow.style.display = "table-row-group";
				} else {
					wRow.style.display = "block";
				}
			} else {
				wRow.style.display = "none";
			}
		}
	}
}

function highlightRow( pPrefix1, pPrefix2, pId1, pId2, pOnColor, pOffColor ) {
	var wRows = document.getElementsByTagName( "tbody" );	
	for ( var i = 0; i < wRows.length; i++ ) {
		var wRow = wRows.item( i );
		var wId = wRow.id;
		if ( wId != null && wId.length > 0 ) {
			var wIndex = -1;
			wIndex = wId.indexOf( pPrefix1 );
			if ( wIndex != 0 ) {
				wIndex = wId.indexOf( pPrefix2 );
			}		
			if ( wId == pId1 || wId == pId2 ) {
				wRow.style.backgroundColor = pOnColor;
			} else if ( wIndex == 0 ) {
				wRow.style.backgroundColor = pOffColor;
			}
		}
	}
}

function highlightFirstRow( pPrefix1, pPrefix2, pOnColor, pOffColor, pAnchorName, pFirstDocId ) {
	var wAnchors = document.getElementsByTagName( "a" );
	var wAnchor = null;
	for ( var i = 0; i < wAnchors.length; i++ ) {
		var wAnchorTmp = wAnchors.item( i );
		var wName = wAnchorTmp.name;
		if ( wName != null && wName == pAnchorName ) {
			wAnchor = wAnchorTmp;
			break;			
		}		
	}
	
	if ( wAnchor == null ) {
		return;
	}
	
	var wTd = wAnchor.parentNode;
	if ( wTd == null || wTd.nodeName.toLowerCase() != 'td' ) {
		return;
	}
	
	var wTr = wTd.parentNode;
	if ( wTr == null || wTr.nodeName.toLowerCase() != 'tr' ) {
		return;
	}
	
	var wTbody = wTr.parentNode;
	if ( wTbody == null || wTbody.nodeName.toLowerCase() != 'tbody' ) {
		return;
	}
	
	var wId = wTbody.id;
	if ( wId == null || wId.length == 0 ) {
		return;
	}
	
	var wIndex = wId.indexOf( pPrefix2 );
	var wDocId = "";
	if ( wIndex == 0 ) {
		wDocId = wId.substring( pPrefix2.length );
	}
	
	highlightRow( pPrefix1, pPrefix2, pPrefix1 + wDocId, pPrefix2 + wDocId, pOnColor, pOffColor );
	
	if ( wDocId == pFirstDocId ) {
		location.href = "#top";
	} else {
		location.href = "#" + pAnchorName;
	}
}

function toggleAll( pPrefix, pId ) {
	var wRows = document.getElementsByTagName( "tbody" );	
	for ( var i = 0; i < wRows.length; i++ ) {
		var wRow = wRows.item( i );
		var wId = wRow.id;
		if ( wId != null && wId == pId ) {
			if ( wRow.style.display == "none" ) {
				showRows( pPrefix );
			} else {
				hideRows( pPrefix );
			}
		}
	}
}

function scrollToAnchor( pName ) {
	var wAnchors = document.getElementsByTagName( "a" );
	for ( var i = 0; i < wAnchors.length; i++ ) {
		var wAnchor = wAnchors.item( i );
		var wName = wAnchor.name;
		if ( wName != null && wName == pName ) {
			wAnchor.scrollIntoView( true );
		}
	}
}

function selectAllChoices( pName ) {
	var wSelectElements = document.getElementsByTagName( "select" );
	for ( var i = 0; i < wSelectElements.length; i++ ) {
		var wSelectObj = wSelectElements.item( i );
		var wSelectObjName = wSelectObj.name;
		if ( wSelectObjName != null && wSelectObjName == pName ) {
			for ( var j = 0; j < wSelectObj.length; j++ ) {
				wSelectObj.options[j].selected = true;
			}
		}
	}
}

function uncheck( pName ) {
	var wCheckBoxElements = document.getElementsByTagName( "input" );
	for ( var i = 0; i < wCheckBoxElements.length; i++ ) {
		var wCheckBoxObj = wCheckBoxElements.item( i );
		if ( wCheckBoxObj.type == "checkbox" && wCheckBoxObj.name == pName ) {
			wCheckBoxObj.checked = false;
		}
	}
}


// Used to display Ajax banners on dashboard page (featured members)
// -- START -- //
function xmlhttpPost(strURL, pDivId ) {
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
				self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
				self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {
				if (self.xmlHttpReq.readyState == 4) {
						document.getElementById(pDivId).innerHTML = self.xmlHttpReq.responseText;
				}
		}
		self.xmlHttpReq.send("");
}


function displayInnerBanners( pBannerId, pDivId ){
		var wHiddenId = document.getElementById( pBannerId ).value
		xmlhttpPost( wHiddenId, pDivId );
}

function getGenericHiddenBannerId() {
	return "hiddenBannerId";
}
function openPopUpWindowForFancyClrDescCertNet()
{
    var wUrl = 'http:\/\/' + document.domain + '\/cgi\/en\/PogCertNet\/PogCertNetSearchResultsFancyClrDesc.html';
	window.open(wUrl,'','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=650,left = 100,top = 100');
}

function validateBrowseEntry( pMessage ) {
  alert(pMessage);
}

// -- END -- //

function previewImagePDF( pImageId, pLink, pThumbId, pThumbName, pThumbIdMax ) {

	var wImage = document.getElementById( pImageId );
	
	if ( wImage ) {
		var wThumb = document.getElementById( pThumbId );
		wImage.src=pLink;
		if ( wThumb ) {
			for ( x = 1; x < pThumbIdMax+1; x++ ) {
				var wThumbX = document.getElementById( pThumbName + x );
				if ( wThumbX ) {
					wThumbX.style.backgroundImage="none";
				}
			}
			wThumb.style.backgroundImage="url(/cgi/en/img/Pog_arrow_selection.gif)";
			wThumb.style.backgroundPosition="top center";
			wThumb.style.backgroundRepeat="no-repeat";
		}
	}
	
}

function previewImage( pImageId, pLink, pThumbId, pThumbName, pThumbIdMax, pImageToLoadId, pForm, pType ) {

	var wImage = document.getElementById( pImageId );
	
	if ( wImage ) {
		wImage.src=pLink;
	}

	var wThumb = document.getElementById( pThumbId );
	if ( wThumb ) {
		for ( x = 1; x < pThumbIdMax+1; x++ ) {
			var wThumbX = document.getElementById( pThumbName + x );
			if ( wThumbX ) {
				wThumbX.className="";
			}
		}
		wThumb.className="selectedThumb";
	}
	
	var wDisplayedImageImg = document.getElementById('displayedImageImg');
	if ( wDisplayedImageImg ) {
		if ( pType == 'PDF') {
			wDisplayedImageImg.innerHTML = '<a href="javascript:viewImages(\'/content-attachment.mgmt-view.versioned.attachment-en.jsa?VersionId=' + pImageToLoadId + '&amp;PhysicalType=MAIN\',\'' + pForm + '\')" title="Enlarge"><img id="previewImage" src="/content-attachment.mgmt-view.static.attachment-en.jsa?LogicalType=PDF&amp;PhysicalType=PREVIEW" alt="' + pThumbName +'" border="0"/></a>';
		}
		if ( pType == 'IMAGE_PENDING') {
			wDisplayedImageImg.innerHTML = '<a href="javascript:viewImages(\'/content-attachment.mgmt-view.versioned.attachment-en.jsa?VersionId=' + pImageToLoadId + '&amp;PhysicalType=MAIN\',\'' + pForm + '\')" title="Enlarge"><img id="previewImage" src="/content-attachment.mgmt-view.static.attachment-en.jsa?LogicalType=IMAGE_PENDING&amp;PhysicalType=PREVIEW" alt="' + pThumbName +'" border="0"/></a>';
		}
		if ( pType == 'IMG' ) {
			wDisplayedImageImg.innerHTML = '<a href="javascript:loadImage(\'/content-attachment.mgmt-view.versioned.attachment-en.jsa?VersionId=' + pImageToLoadId +'&amp;PhysicalType=MAIN\');" title="Enlarge"><img id="previewImage" src="/content-attachment.mgmt-view.versioned.attachment-en.jsa?VersionId=' + pImageToLoadId + '&amp;PhysicalType=PREVIEW" alt="' + pThumbName +'" border="0"/></a>';
		}
	}
	
	var wImageZoom = document.getElementById('displayedImageZoom');
	if ( wImageZoom ) {
		if ( pType == 'PDF') {
			wImageZoom.innerHTML = '<a class="enlarge" href="javascript:viewImages(\'/content-attachment.mgmt-view.versioned.attachment-en.jsa?VersionId=' + pImageToLoadId + '&amp;PhysicalType=MAIN\',\'' + pForm + '\')" title="Enlarge">&#160;</a>';
		}
		else if ( pType == 'IMAGE_PENDING') {
			wImageZoom.innerHTML = '<a class="enlarge" href="javascript:viewImages(\'/content-attachment.mgmt-view.versioned.attachment-en.jsa?VersionId=' + pImageToLoadId + '&amp;PhysicalType=MAIN\',\'' + pForm + '\')" title="Enlarge">&#160;</a>';
		}
		else if ( pType == 'IMG' ) {
			wImageZoom.innerHTML = '<a class="enlarge" href="javascript:loadImage(\'/content-attachment.mgmt-view.versioned.attachment-en.jsa?VersionId=' + pImageToLoadId +'&amp;PhysicalType=MAIN\');" title="Enlarge">&#160;</a>';
		}
	}
}

function clearObjectMinValue( pObj ) {
	if ( pObj.value == 'Min' ) {
		pObj.value = '';
	}
}

function clearObjectMaxValue( pObj ) {
	if ( pObj.value == 'Max' ) {
		pObj.value = '';
	}
}

function clearFieldMinValue( pObjId ) {
	var wObj = 	document.getElementById( pObjId );
	if ( wObj.value == 'Min' ) {
		wObj.value = '';
	}
}

function clearFieldMaxValue( pObjId ) {
	var wObj = 	document.getElementById( pObjId );
	if ( wObj.value == 'Max' ) {
		wObj.value = '';
	}
}

var submitPageOnEnterEnabled = true;
function submitPageOnEnter( e, pFrom, pAction ){
	var code;
	var srcElmId;
	if(window.event) { // IE
		code = window.event.keyCode;
		srcElmId =  window.event.srcElement.id ;
	} else if(e.which) { // Netscape/Firefox/Opera
		code = e.which;
		srcElmId = e.target.id;
	}
	if (code==13){
		if(srcElmId != 'findMemberTextBox' && 
		   srcElmId != 'UserStatusMessBut_mm' && 
		   srcElmId != 'dolSendMessageInput'){
			if(submitPageOnEnterEnabled){
				submitAction( pFrom, pAction );
		   	}
		}
	}
    
}
function submitPageOnEnterActive( pEnabled ){
	submitPageOnEnterEnabled = pEnabled;
}
function fxOnEnter( e, pFx ){
	var code;
	var srcElmId;
	if(window.event) { // IE
		code = window.event.keyCode;
		srcElmId =  window.event.srcElement.id ;
	} else if(e.which) { // Netscape/Firefox/Opera
		code = e.which;
		srcElmId = e.target.id;
	}
    if (code==13){
    	if(srcElmId != 'findMemberTextBox'){
    		if(submitPageOnEnterEnabled){
        		pFx();
       		}
    	}
    	
    }
}





