// Contains JavaScript used in the Retail Store Locator / Google Maps Integration
function usePNGWorkaround() {			
	// Finds out if browser version is IE 5.5 / IE 6.x
	// These versions have issues with displaying PNG images with transparency.
	
	// convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
	
	if( (is_ie5_5 && document.body.filters)  || ( is_ie6 && document.body.filters) ) {
		return true;
	} else {
		return false;
	}
}

function getImageURL(indexString,isCertified) {
	// Returns imageURL for marker based on index
	//alert("getImageURL - TODO: implement 'certified' markers");
	var imgsrc = "/consumerfiles/assets/img/pin_empty.gif";
	var index = parseInt(indexString);
	var filenames = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6"];
	var markerPath = (isCertified && (isCertified==true || isCertified=="true")) ? "markers-c/" : "markers/";
	if (index >= 1 && index <= filenames.length) {
		imgsrc = "/consumerfiles/assets/img/" + markerPath + filenames[index - 1] + ".png";
	}
	return imgsrc;
}

function restrictZoomLevels(googleMap, minLevel, maxLevel) {
	// Restricts zooming of a Google Map to levels minLevel -> maxLevel

  	// Get the list of map types
	var mt = googleMap.getMapTypes();
	// Override the getMinimumResolution() and getMaximumResolution() methods for all map types of this map.
	// This will restrict the range of zoom levels.
	for (var i=0; i<mt.length; i++) {
		mt[i].getMinimumResolution = function() {return minLevel;}
		mt[i].getMaximumResolution = function() {return maxLevel;}
  	}
}

function getDestinationAddress() {
	// Returns the destination address for a particular dealer
	return this.address1 + ', ' + this.city + ', ' + this.country;
}


function trim(strValue) {
	return strValue.replace(/^\s+|\s+$/g,"");
}

function isNullOrEmpty(inputString) {
	// Checks if inputString is null or empty string
	return (inputString == null || trim(inputString) == '');
}


/*function getMaxContent() {
	// Returns address details, product groups, exclusive, included and excluded products for this dealer.
	var htmlContent = '';

	htmlContent += '<p class="mapInfoWindowHeader">' + sitetextMap["AddressDetails"] + '</p>';
	htmlContent += this.getAddressHTMLContent(false) + '<br/>';

	if (this.groups.length > 0) {
		htmlContent += '<p class="mapInfoWindowHeader">' + sitetextMap["SpecializedFollowingProds"] + '</p>';
		for (var i=0; i<this.groups.length; i++)
		{
			htmlContent += this.groups[i] + '<br/>';
		}
		htmlContent += '<br/>';
	}

	if (this.exclusiveProducts.length > 0) {
		htmlContent += '<p class="mapInfoWindowHeader">' + sitetextMap["AuthorizedFor"] + '</p>';
		for (var i=0; i<this.exclusiveProducts.length; i++)
		{
			htmlContent += this.exclusiveProducts[i] + '<br/>';
		}
		htmlContent += '<br/>';
	}
	
	if (this.includedProducts.length > 0) {
		htmlContent += '<p class="mapInfoWindowHeader">' + sitetextMap["AlsoAvailableAtThisStore"] + '</p>';
		for (var i=0; i<this.includedProducts.length; i++)
		{
			htmlContent += this.includedProducts[i] + '<br/>';
		}
		htmlContent += '<br/>';
	}

	if (this.excludedProducts.length > 0) {
		htmlContent += '<p class="mapInfoWindowHeader">' + sitetextMap["NotAvailableAtThisStore"] + '</p>';
		for (var i=0; i<this.excludedProducts.length; i++)
		{
			htmlContent += this.excludedProducts[i] + '<br/>';
		}
	}
	return htmlContent;
}*/

function showMarker() {
  //var maxContent = this.getMaxContent();
	//var contentNode = document.createElement('div');
	//contentNode.innerHTML = maxContent;
	//this.marker.openInfoWindowHtml(this.getAddressHTMLContent(true), {maxContent: contentNode, maxTitle:'<p class="mapInfoWindowHeader">' + sitetextMap["StoreDetails"] + '</p>'});
	// Highlight location in list
	highlightLocation(this);
}

function PLocation(name,address1,address2,postcode,city,country,state,phone,fax,email,visualUrl,url,groups,groupsImages,includedProducts,excludedProducts,exclusiveProducts,point,locationIndex,locationRow,locationLabel,logoURL,isCertified) {
	// Constructor for a retailer
	// Most properties are easily explained by looking at the name.
	// Properties that need extra description:
	// * groups: group names for the groups which are connected to the dealer
	// * groupsImages: image assets for the groups
	// * exclusiveProducts: ctn's and names of the exclusive products offered by this dealer.
	// * includedProducts: ctn's and names of the included products offered by this dealer.
	// * excludedProducts: ctn's and names of the excluded products offered by this dealer.
	// * point: Google geocode (GLatLng object) for the position of the dealer on the map
	// * icon: icon used for the marker of the dealer
	// * marker: marker used to show the dealer on the map
	// * infoTabs: tabs used for building up the info window over the marker
	// * locationRow: row in the dealer results table that contains information on the dealer
	// * locationLabel: label for an element in the dealer search results table that shows the dealer name
	// * logoURL: htdocs relative URL of the logo for this dealer, if available (else null)
	// * isCertified: boolean flag, marks the shop as a Philips certified dealer 
	//
	// Methods:
	// * getDestinationAddress - returns a string with the dealer destination address used in the routeplanner
	// * getAddressHTMLContent - returns a string with the HTML content of minimized version of the info window
	// * getMaxContent - returns a string with the HTML content of the maximized version of the infowindow
	// * showMarker - activates the marker on the map
	this.name = name;
	this.address1 = address1;
	this.address2 = address2;
	this.postcode = postcode;
	this.city = city;
	this.country = country;
	this.state = state;
	this.phone = phone;
	this.fax = fax;
	this.email = email;
	this.visualUrl = visualUrl;
	this.url = url;
	this.groups = groups;
	this.groupsImages = groupsImages;
	this.includedProducts = includedProducts;
	this.excludedProducts = excludedProducts;
	this.exclusiveProducts = exclusiveProducts;
	this.point = point;
	this.locationIndex = locationIndex;
	this.locationRow = locationRow;
	this.locationLabel = locationLabel;
	this.getDestinationAddress = getDestinationAddress;
	this.logoURL=logoURL;
	this.isCertified=isCertified;
	//this.getAddressHTMLContent = getAddressHTMLContent;
	this.showMarker = showMarker;
	this.icon = generateIcon(this.locationIndex, this.isCertified);
	// Create a marker for the specific geocode using the provided icon
	var marker = new GMarker(this.point,this.icon);
	var currentDealer = this;
	GEvent.addListener(marker, "click", function() {
		currentDealer.showMarker();
	});
	this.marker = marker;
	
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function generatePopupVisualURL(visualURL){
	visualURLPopup = "<a href='" + visualURL + "'" + " onclick=\"window.open('" + visualURL + "','philips', 'toobar=no,location=no,direction=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=320, height=390');\">" + visualURL + "</a>";
	return visualURLPopup;
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function generateIcon(index,isCertified) {
	//alert("generateIcon - index=" + index + ", isCertified="+isCertified);
	var icon = new GIcon(G_DEFAULT_ICON);
	icon.image = getImageURL(index,isCertified);
	icon.iconSize = new GSize(23, 39);
	icon.iconAnchor = new GPoint(6, 20);    
	icon.infoWindowAnchor = new GPoint(9, 1);
	return icon;
}

PLocation.prototype.generateIcon = function(index, isCertified){
	//alert("PLocation.generateIcon - index=" + index + ", isCertified=" + isCertified);
	return generateIcon(index, isCertified);
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function highlightLocation(newLocation) {
	// First unhighlight the currently selected dealer
	var tableCells;
	if (selectedLocation != null) {
		// Change text color of first table cell back to original
		tableCells = selectedLocation.locationRow.getElementsByTagName('td');
		for (var i=0; i<tableCells.length; i++)
		{
			tableCells[i].style.color='';
			tableCells[i].style.background='';
		}
		selectedLocation.locationLabel.style.color='#0E5FD8';
	}
	// Then highlight the newly selected dealer
	tableCells = newLocation.locationRow.getElementsByTagName('td');
	for (var i=0; i<tableCells.length; i++)
	{
		tableCells[i].style.color='#FFFFFF';
		tableCells[i].style.background='#669CFF';
	}
	newLocation.locationLabel.style.color='#FFFFFF';
	selectedLocation = newLocation;
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function processAddress(response) {
	var searchValue = response.name.toUpperCase();
	// Build up regular expression to check if country code is already at the end of the search string.
	var reCountryCode = new RegExp("\\s" + countryCode + "$","i");
	if (!response.Placemark) {
		//show advanced search panel when no locations are found
		showAdvancedSearch('advSearch'); 
		// No locations found, search again with the country code included in the search value.
		if (searchValue.search(reCountryCode) == -1 && searchValue.indexOf(countryName) == -1) {
			searchValue = searchValue + " " + countryCode;
			geoCoder.getLocations(searchValue, processAddress);
		} else {
    		// Even searching with country code does not return results, show error.
			showErrorFragment()				
		}
	} else {		
		// Locations were found. Find the first one within the country		
		for (var counter=0 ; counter < response.Placemark.length ; counter++) {
			// Check if Country is available in the address details. This is not always the case, especially not when searching for postal codes.
			if (response.Placemark[counter].AddressDetails.Country) {
				if(response.Placemark[counter].AddressDetails.Country.CountryNameCode == countryCode) {
					var geocode = new GLatLng(response.Placemark[counter].Point.coordinates[1], response.Placemark[counter].Point.coordinates[0]);
					document.retailLocation.geoLat.value = geocode.lat();
					document.retailLocation.geoLong.value = geocode.lng();
					document.retailLocation.submit();
					return;
				}
			}
		}
		if(searchValue.search(reCountryCode) == -1 && searchValue.indexOf(countryName) == -1) {
			// Add country code and try again.
			searchValue = searchValue + " " + countryCode;
			geoCoder.getLocations(searchValue, processAddress);
		} else {
    		// Failure show the fail logic
			showErrorFragment();
			return;
		}
	}
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function submitIfNotEmpty(){
	var latLong;
	var selectedGroupId = "";
	var searchAddress = document.getElementById('searchAddress');
	var searchValue = searchAddress.value;
	searchValue = searchValue + " " + countryCode;
	
	//check selected radio button (product group)
	for (var i=0; i<document.forms[1].groupId.length; i++)  {
		if (document.forms[1].groupId[i].checked)  {
			selectedGroupId = document.forms[1].groupId[i].value
		}	
	}	
		
	//check selected radio button (product group)
	if (selectedGroupId != "") { 
		//hide message 
		hideElement("errorNoGroupSelected");
		geoCoder.getLocations(searchValue, processAddress);
	} else {
		//show message that product group should be selected
		showElement("errorNoGroupSelected"); 
	}
}

//var isVisible = true;
function toggleAdvancedSearch(elementId) {
	var elt = document.getElementById(elementId);
	
	//check if element is visible or not to toggle
	if (elt.style.display == "inline") {
		isVisible = true;
	} else {
		isVisible = false;
	}
	
	var arrowElt = document.getElementById('arrow');
	if (! isVisible) {
		arrowElt.src = "/consumerfiles/assets/img/grey_arrow_down.gif";
		elt.style.display = 'inline';
		hideElement("searchResults");
		hideElement("errorFragment");
		hideElement("errorNoGroupSelected");
		isVisible = true;
	} else {
		arrowElt.src = "/consumerfiles/assets/img/grey_arrow_right.gif";
		elt.style.display = 'none';
		isVisible = false;
		if (activeFragment == 'errorFragment')
		{
			showElement('errorFragment');
		}
		if (activeFragment == 'searchResults')
		{
			showElement('searchResults');
		}
	}
}


/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function showAdvancedSearch(){
	showElement('advSearch');
	var arrowElt = document.getElementById('arrow');
	arrowElt.src = "/consumerfiles/assets/img/grey_arrow_down.gif";
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function hideAdvancedSearch(){
	hideElement('advSearch');
	var arrowElt = document.getElementById('arrow');
	arrowElt.src = "/consumerfiles/assets/img/grey_arrow_right.gif";
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function showErrorFragment(){
	showElement("errorFragment");
	hideElement("searchResults");
	// and also open the advanced search options panel
	showAdvancedSearch();
	activeFragment='errorFragment';
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function showElement(elementId){
	var elt = document.getElementById(elementId);
	if (elt !=null) {elt.style.display = 'inline';}
}		

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function hideElement(elementId){
	var elt = document.getElementById(elementId);
	if (elt !=null) {elt.style.display = 'none';}
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function openGoogleMaps(destinationAddress, countryCode) {
	var addressFrom = document.directions.start.value;
	var URL = 'http://maps.google.com/maps?saddr=' + addressFrom + ',' + countryCode + '&daddr=' + destinationAddress + '&hl=' + language;
	window.open(URL);
}

/**
	* ----------------------------------------------------------------------------- generatePopupVisualURL(visualURL)
	*/
function checkEnter(e){ 
    var characterCode
    if(e && e.which){ 
        e = e
        characterCode = e.which 
    } else {
        e = event
        characterCode = e.keyCode
    }
    if(characterCode == 13){ 
        submitIfNotEmpty();
		return false;
    }
}


var focuscount = 0;
function clearfield(obj) {
	formfield = obj;
	if(focuscount > 0) {
		formfield.select();
	} else {
		focuscount += 1;
		formfield.value = "";
	}
}



// contents of the custom info window
	PLocation.prototype.htmlHr = function(){
     var mhtml = '';
     //mhtml += '<div id="line" style="height:1px; background-color:#D3D5DA;border:0;padding:0;"></div>';
     //mhtml += '<div id="line" style="height:1px; background-color:#ffffff;border:0;padding:0;"></div>';
     mhtml += '<div id="line" class="SeparatorLine_retail_store_locator_color"></div>';
     mhtml += '<div id="line" class="SeparatorLine_retail_store_locator_white"></div>';
     return mhtml;
   }

   // search form
  PLocation.prototype.htmlSearch = function(){
     var mhtml = '';
     mhtml += this.htmlHr();
     mhtml += '<div style="height:4px; background-color:#f2f2f6; border:0; padding:0;"></div>';
     mhtml += '<div id="search" style="height:40px; background-color:#f2f2f6; border:0; padding:0px;">';
     mhtml += '<form method="post" id="directions" name="directions" onSubmit="return false">';
     // FIXME sitetextmap seems not to be working
     mhtml += '<input type="text" id="start" name="start"  value="' + sitetextMap["StartAddress"] + '" onfocus="clearfield(this)" style="position:relative; float:left; margin-left:10px; width:197px; height:17px; border-top:1px solid #9297A3;border-left:1px solid #9297A3;border-bottom:1px solid #D3D5DA;border-right:1px solid #D3D5DA;font-size:1em;padding-left:4px;"/>';
     mhtml += '<table class="p-button-action" style="float:left; margin-left:16px;" border="0" cellspacing="0"><tr><td onclick="openGoogleMaps(\'' + this.getDestinationAddress() + '\', \'' + this.country + '\');"><div style="padding-left:4px;">' + sitetextMap["GetDirections"] + '</div></td></tr></table>';
     mhtml += '</form>';
     mhtml += '</div>';
     return mhtml;
   }

   // store info
  PLocation.prototype.htmlStoreInfo = function(){
     var mhtml = '';
     mhtml += '<div style="height:16px; border:0; padding:0;"></div>';
     mhtml += '<table id="map-storeinfo" border="0" cellspacing="0" cellpadding="4" width="428" align="center">';
       mhtml += '<tr>';
         // FIXME replace the generic logo here with the dealer's logo from the new dealersheet
         
         if (this.isCertified=="true"){
	         dealerLogo = '<img src="/consumerfiles/assets/img/p-infowindow/dealer_certified.gif" hspace="4"  />'
	         if (!isNullOrEmpty(this.logoURL)){
	         		dealerLogo = '<img src="' + this.logoURL + '" hspace="4" width="90" />'
	         }
	         	mhtml += '<td id="map-storeinfo-logo" valign="top" rowspan="2" width="104" align="center">' + dealerLogo + '</td>';
	        } else {
	        	mhtml += '<td id="map-storeinfo-logo" valign="top" rowspan="2" width="8" align="center">&nbsp;</td>'
	        }
         
         mhtml += '<td colspan="2" style="font:normal 11px verdana;"><b>';
         	if (!isNullOrEmpty(this.name)) mhtml += this.name;
         mhtml += '</b></td>';
       mhtml += '</tr>';
       mhtml += '<tr>';
         mhtml += '<td valign="top" style="font:normal 11px verdana;padding-bottom:10px">';
           if (!isNullOrEmpty(this.address1)) mhtml += '' + this.address1 + ', ';
           if (!isNullOrEmpty(this.address2)) mhtml += '' + this.address2 + '<br/>';
           if (!isNullOrEmpty(this.city)) mhtml += '' + this.city + ', ';
           if (!isNullOrEmpty(this.state)) mhtml += '' + this.state + '<br/>';
           if (!isNullOrEmpty(this.postcode)) mhtml += '' + this.postcode + '<br/>';
           if (!isNullOrEmpty(this.email)) mhtml += '' + this.email  + '<br/>';
						if (!isNullOrEmpty(this.visualUrl)) {
							if (!isNullOrEmpty(this.url)) { mhtml += '<a href="' + this.url + '" target="_blank">'; }
							mhtml += this.visualUrl;
							if (!isNullOrEmpty(this.url)) { mhtml += '</a>'; }
							mhtml += '<br/>';
						}
						if (!isNullOrEmpty(this.phone)) mhtml += '' + this.phone + '<br/>';
         mhtml += '</td>';
       mhtml += '</tr>';
     mhtml += '</table>';
     return mhtml;
   }

   // categories info
  PLocation.prototype.htmlGroupsInfo = function(){
     var mhtml = '';
     //if (this.groups.length > 0 || this.exclusiveProducts.length > 0 || this.includedProducts.length > 0 || this.excludedProducts.length > 0){
     if (this.groups.length > 0){
	     mhtml += this.htmlHr();
	     mhtml += '<div style="height:8px; border:0; padding:0;"></div>';
	     mhtml += '<table id="map-groupsinfo" style="margin-left:4px">';
	     
		if (this.groups.length > 0) {	     
			mhtml += printGroupsBegin(sitetextMap["SpecializedFollowingProds"]);
			for (i=0; i<this.groups.length && i<7; i++){
				mhtml += '<img src="' + this.groupsImages[i] + '" width="52" height="52" style="padding-right:4px;" />';
			}
			mhtml += printGroupsEnd();
		}

		/*
		if (this.exclusiveProducts.length > 0) {
			mhtml += printGroupsBegin(sitetextMap["AuthorizedFor"]);
			for (i=0; i<this.exclusiveProducts.length && i<7; i++){
				mhtml += '<img src="/consumerfiles/assets/img/catalog/' + this.exclusiveProducts[i] + '_52x52.gif" width="52" height="52" hspace="3" />';// TODO naming conventions for product/group images?
			}
			mhtml += printGroupsEnd();
		}
		
		if (this.includedProducts.length > 0) {
			mhtml += printGroupsBegin(sitetextMap["AlsoAvailableAtThisStore"]);
			for (i=0; i<this.includedProducts.length && i<7; i++){
				mhtml += '<img src="/consumerfiles/assets/img/catalog/' + this.includedProducts[i] + '_52x52.gif" width="52" height="52" hspace="3" />';// TODO naming conventions for product/group images?
			}
			mhtml += printGroupsEnd();
		}
		
		if (this.excludedProducts.length > 0) {
			mhtml += printGroupsBegin(sitetextMap["NotAvailableAtThisStore"]);
			for (i=0; i<this.excludedProducts.length && i<7; i++){
				mhtml += '<img src="/consumerfiles/assets/img/catalog/' + this.excludedProducts[i] + '_52x52.gif" width="52" height="52" hspace="3" />';// TODO naming conventions for product/group images?
			}
			mhtml += printGroupsEnd();
		}
		*/
	         
	     mhtml += '</table>';
	     mhtml += '<div style="height:8px; border:0; padding:0;"></div>';
	   }
     return mhtml;
   }

  PLocation.prototype.htmlMoreInfoOpen = function(){
     var mhtml = '';
     mhtml += '<div style="padding:8px; font:10px verdana;">';
     //if (this.groups.length > 0 || this.exclusiveProducts.length > 0 || this.includedProducts.length > 0 || this.excludedProducts.length > 0){
     if (this.groups.length > 0){
	     mhtml += '<a style="color:#005AFF;font-weight:bold;text-decoration:none;" href="javascript:googleMap.minimizeExtInfoWindow();"><img src="/consumerfiles/assets/img/p-infowindow/arw_more_open.gif" width="9" height="9" border="0" hspace="4" />';
	     mhtml += '' + sitetextMap["StoreDetails"] + '</a>';
	   }
	   mhtml += '</div>';
     mhtml += '<div style="height:8px; border:0; padding:0;"></div>';
     return mhtml;
   }


  PLocation.prototype.htmlMoreInfoClosed = function(){
     var mhtml = '';
     mhtml += '<div style="padding:8px; font:10px verdana;">';
	   //if (this.groups.length > 0 || this.exclusiveProducts.length > 0 || this.includedProducts.length > 0 || this.excludedProducts.length > 0){
     if (this.groups.length > 0){
	     mhtml += '<a style="color:#005AFF;font-weight:bold;text-decoration:none;" href="javascript:googleMap.maximizeExtInfoWindow();"><img src="/consumerfiles/assets/img/p-infowindow/arw_more_closed.gif" width="9" height="9" border="0" hspace="4" />';
	     mhtml += '' + sitetextMap["StoreDetails"] + '</a>';
	   }
	   mhtml += '</div>';
     mhtml += '<div style="height:2px; border:0; padding:0;"></div>';
     return mhtml;
   }


	PLocation.prototype.getMaxContent = function(){
     var mhtml = 
     	this.htmlStoreInfo() + 
     	//this.htmlMoreInfoOpen() + 
     	this.htmlGroupsInfo() + 
     	this.htmlSearch()
     return mhtml;
   }
   
   PLocation.prototype.getMinContent = function () {
     var mhtml =  
     	this.htmlStoreInfo() + 
     	//this.htmlMoreInfoClosed() + 
     	this.htmlSearch();
     return mhtml;
   } 

   
   function printGroupsBegin(title){
			var mhtml = '';
			mhtml += '<tr>';
			mhtml += '<td style="height:20px; vertical-align:top; font:normal 11px verdana;">';
			mhtml += '<strong style="margin-left:4px;">' + title + '</strong><br/>';
			mhtml += '</td>';
			mhtml += '</tr>';
			mhtml += '<tr>';
			mhtml += '<td style="font:normal 11px verdana;">';
			return mhtml;
		}
		
		function printGroupsEnd(){
			var mhtml = '';
			mhtml += '</td>';
			mhtml += '</tr>';
			return mhtml;
		}

/*****************************************************
 	Selects the option in the advanced search panel.
******************************************************/		
function selectRadioButton(id) {
	var elem = document.getElementById(id);
	elem.checked = true;
}		 

/*****************************************************
 	Shows/hide advanced panel (initial on page)
******************************************************/		
function showAdvancedPanel(visible) {
	isVisible = visible;
	
	if (visible) {		
		showAdvancedSearch('advSearch');
	} else {		
		hideAdvancedSearch('advSearch');				
	}
}		 



