/*
	Javascript to open in the layout.xhtml
	author: ppu
	date:		09.07.09
*/

		function loadOnReload (popUp,companyFilter)
	  {
		  changeHSIDeliveryInformation(companyFilter);
		  changeProdListPopUpStatus(popUp);
		}

	  function changeHSIDeliveryInformation(companyFilter)
	  {
		  if ( (document.forms['checkOutForm'] != null) && 
		  			(document.forms['checkOutForm'].elements['checkOutForm:postcode'] != null) && 
		  			(companyFilter != null) && (companyFilter != '') )
			{
				if ( (companyFilter == 'HBI') && 
						( (document.forms['checkOutForm'].elements['checkOutForm:postcode'].value=='9020') || (document.forms['checkOutForm'].elements['checkOutForm:postcode'].value=='9220') ) )
				{
					if (document.getElementById('checkOutForm:shipping') != null) {
							document.getElementById('checkOutForm:shipping').style.visibility = 'visible';
					}
					if (document.getElementById('checkOutForm:shipping2') != null) {
							document.getElementById('checkOutForm:shipping2').style.visibility = 'hidden';
					}
				}
				else if ( (companyFilter == 'HBA') && 
						( (document.forms['checkOutForm'].elements['checkOutForm:postcode'].value=='9020') || (document.forms['checkOutForm'].elements['checkOutForm:postcode'].value=='9220') ) ) 
				{
					if (document.getElementById('checkOutForm:shipping') != null) {
						document.getElementById('checkOutForm:shipping').style.visibility = 'hidden';
					}
					if (document.getElementById('checkOutForm:shipping2') != null) {
						document.getElementById('checkOutForm:shipping2').style.visibility = 'visible';
					}						
				}
				else
				{
					if (document.getElementById('checkOutForm:shipping') != null) {
						document.getElementById('checkOutForm:shipping').style.visibility = 'hidden';
					}
					if (document.getElementById('checkOutForm:shipping2') != null) {
						document.getElementById('checkOutForm:shipping2').style.visibility = 'hidden';
					}
				}
			}
			else
			{
				if (document.getElementById('checkOutForm:shipping') != null) {
					document.getElementById('checkOutForm:shipping').style.visibility = 'hidden';
				}
				if (document.getElementById('checkOutForm:shipping2') != null) {
					document.getElementById('checkOutForm:shipping2').style.visibility = 'hidden';
				}
			}
		}

		function changeProdListPopUpStatus(popUp)
	  {
		  if (document.forms['productListing'] != null)
			{
				var elem = document.forms['productListing'].elements['productListing:popUpActivationStore'];
				var elemRadio1 = document.getElementById('popUpActivation1');
				if ( (elem != null) && (elemRadio1 != null) && ( popUp=='true')	) {
					elemRadio1.checked='true';
				}
				else {
					var elemRadio2 = document.getElementById('popUpActivation2');
					if (elemRadio2 != null) {
						elemRadio2.checked='true';
					}
				}
			}
		}

		function hideDivById(divId) 
		{
			document.getElementById(divId).style.visibility = "hidden";
		}		
		function showDivById(divId) 
		{
			document.getElementById(divId).style.visibility = "visible";
		} 
