
function browserInfo() {
	var agent = navigator.userAgent.toLowerCase();
	this.moz  = ( ( agent.indexOf( 'mozilla' ) != -1 ) && ( ( agent.indexOf( 'spoofer' ) == -1 ) && ( agent.indexOf( 'compatible' ) == -1 ) ) );
	this.ie   = ( agent.indexOf( 'msie' ) != -1 );
}
var bi = new browserInfo();


function openWindow( p_strURL, p_strName, p_numWidth, p_numHeight, p_numTop, p_numLeft, p_blnScroll, p_blnResize )
{
	var hndWindow = null;	// Window handle
	
	if ( p_strName == null ){
		p_strName = "myWindow";
	}
	if ( p_numWidth == null ) {
		p_numWidth = 320;
	}
	if ( p_numHeight == null ) {
		p_numHeight = 200;
	}
	if ( p_numTop == null ) {
		p_numTop = 0;
	}
	if ( p_numLeft == null ) {
		p_numLeft = 0;
	}
	if ( p_blnScroll == null ) {
		p_blnScroll = "no";
	}
	if ( p_blnResize == null ) {
		p_blnResize = "no";
	}
	
	if ( ( p_numTop == -1 ) && ( p_numLeft == -1 ) ) {
		// => Center window on screen
		
		if ( navigator.appVersion.substring( 0, 1 ) > '3' ) {
			p_numTop     = ( screen.availHeight - p_numHeight ) / 2;
			p_numLeft    = ( screen.availWidth  - p_numWidth )  / 2;
		} else {
			p_numWidth  += 20;
			p_numHeight += 40;
			p_numTop     = ( 600 - p_numHeight ) / 2 - 20;
			p_numLeft    = ( 800 - p_numWidth )  / 2;
		}
	}
	
	strOptions =	'resizable=' + p_blnResize + ',menubar=no,scrollbars=' + p_blnScroll +
					',status=no,directories=no,width=' + p_numWidth + ',height=' + p_numHeight + 
					',top=' + p_numTop + ',left=' + p_numLeft;
	
	hndWindow = window.open( p_strURL, p_strName, strOptions );
	if ( hndWindow != null ) {
		hndWindow.focus();
	}
	
	return hndWindow;
}


var arrayExtendedSearchToggleRows = new Array( "QWLSearchMaskRow3", "QWLSearchMaskRow4", "QWLSearchMaskRow5" );

function setExtendedSearch( p_strMode, p_arrayExtendedSearchToggleRows )
{
	if ( p_strMode == 'on' ) {
		// => extended search mask should be displayed
		blnDeleteSearchParams = false;
		var strLinkText = "Einfache Suche";
		var strLinkURL  = "javascript:setExtendedSearch('off',arrayExtendedSearchToggleRows);";
	} else if ( p_strMode == 'off' ) {
		// => extended search mask should be hidden
		blnDeleteSearchParams = true;
		var strLinkText = "Erweiterte Suche";
		var strLinkURL  = "javascript:setExtendedSearch('on',arrayExtendedSearchToggleRows);";
	}
	
	
	// Check, if extended search parameters have been changed by user (not yet fully implemented!)
	if (	document.frmSearchMask.s2.value         != SEARCH_PARAM_DEFAULT_VALUE__SEARCH1 ||
			document.frmSearchMask.prc_limit.value  != SEARCH_PARAM_DEFAULT_VALUE__PRICE_LIMIT ||
			document.frmSearchMask.prc.value        != SEARCH_PARAM_DEFAULT_VALUE__PRICE ||
			document.frmSearchMask.class_type.value != SEARCH_PARAM_DEFAULT_VALUE__CLASS_TYPE ||
			document.frmSearchMask.disp_ads.value   != SEARCH_PARAM_DEFAULT_VALUE__DISP_ADS ||
//			document.frmSearchMask.sort.value       != SEARCH_PARAM_DEFAULT_VALUE__SORTING ||
			document.frmSearchMask.result.value     != SEARCH_PARAM_DEFAULT_VALUE__RESULT ) {
		var blnPromptUser = true;
	} else {
		var blnPromptUser = false;
	}
	
	if ( blnDeleteSearchParams && blnPromptUser ) {
		blnConfirm = confirm( LANG_CONFIRM__CLOSE_EXTENDED_SEARCH );
		if ( ! blnConfirm ) {
			return;
		} else{
			document.frmSearchMask.s2.value         = SEARCH_PARAM_DEFAULT_VALUE__SEARCH1;
			document.frmSearchMask.prc_limit.value  = SEARCH_PARAM_DEFAULT_VALUE__PRICE_LIMIT;
			document.frmSearchMask.prc.value        = SEARCH_PARAM_DEFAULT_VALUE__PRICE;
			document.frmSearchMask.class_type.value = SEARCH_PARAM_DEFAULT_VALUE__CLASS_TYPE;
			document.frmSearchMask.disp_ads.value   = SEARCH_PARAM_DEFAULT_VALUE__DISP_ADS;
//			document.frmSearchMask.sort.value       = SEARCH_PARAM_DEFAULT_VALUE__SORTING;
			document.frmSearchMask.result.value     = SEARCH_PARAM_DEFAULT_VALUE__RESULT;
		}
	}
	
	
	// Display or hide extended search mask rows
	for ( var i = 0; i < p_arrayExtendedSearchToggleRows.length; i++ ) {
		obj = document.getElementById( p_arrayExtendedSearchToggleRows[i] );
		
		if ( bi.ie ) {
			if ( p_strMode == 'on' ) {
				// => display extended search mask
				obj.style.display = 'inline';
				document.frmSearchMask.ext_mask.value = "TRUE";
			} else if ( p_strMode == 'off' ) {
				// => hide extended search mask
				obj.style.display = 'none';
				document.frmSearchMask.ext_mask.value = "FALSE";
			}
		} else {
			if ( p_strMode == 'on' ) {
				// => display extended search mask
				obj.style.display = 'table-row';
				document.frmSearchMask.ext_mask.value = "TRUE";
			} else if ( p_strMode == 'off' ) {
				// => hide extended search mask
				obj.style.display = 'none';
				document.frmSearchMask.ext_mask.value = "FALSE";
			}
		}
	}
	
	
	// Replace link text and URL
	if ( document.getElementById ) {
		document.getElementById("QWLextSearchLink").firstChild.nodeValue = strLinkText;
		document.getElementById("QWLextSearchLink").href = strLinkURL;
	} else if ( document.all ) {
		document.all["QWLextSearchLink"].innerText = strLinkText;
		document.all["QWLextSearchLink"].href = strLinkURL;
	}
	
}


function displayImage( strImage ) {
	if ( document.getElementById ) {
		document.getElementById("QWLadImage").src = eval( strImage + ".src" );
	} else {
		document.adImage.src = eval( strImage + ".src" );
	}
}


function searchCat( strCatID )
{
	document.frmSearchMask.cid.value = strCatID;
	document.frmSearchMask.mask.value = "";
	
	document.frmSearchMask.submit();
}


function searchPage( strPageNumber )
{
	document.frmSearchMask.p.value = strPageNumber;
	document.frmSearchMask.mask.value = "";
	
	document.frmSearchMask.submit();
}


function categoryToggle( strID )
{
	objElement = document.getElementById( strID );
	objSign    = document.getElementById( strID + "_sign" );
	
	if ( objElement ) {
		if ( objElement.style.display == "block" ) {
			objElement.style.display = "none";
			if ( objSign ) { objSign.innerHTML = "(+)"; }
		} else {
			objElement.style.display = "block";
			if ( objSign ) { objSign.innerHTML = "(-)"; }
		}
	}
}

