function openWin(URL,width,height,scroll,resize, status, menubar, toolbar, location, directories, winName) {
	noUrl = false
	if (URL == "" || URL == null) { URL="about:blank"; noUrl=true }
	if (width == "" || width == null ) { width = 640 }
	if (height == "" || height == null ) { height = 480 }
	if (width == "*" ) {
		width = (screen.availWidth * (100/99)) ;
		if (width > 800) width="800"; //since the site isn't wider than 800px, there's no point in opening in fullscreen mode, it just looks silly!
	}
	if (height == "*" ) {
	height =  (screen.availHeight * (100/95));
		if (height > 580) height="580";//since the site isn't taller than 800px, there's no point in opening in fullscreen mode, it just looks silly!
	}
	if (scroll == "" || scroll == null ) { scroll = 1 }
	if (resize == "" || resize == null ) { resize = 1 }
	if (status == "" || status == null ) { status = 1 }
	if (menubar == "" || menubar == null) {menubar=0}
	if (toolbar == "" || toolbar == null) {toolbar=0}
	if (location == "" || location == null) {location=0}
	if (directories == "" || directories == null) {directories=0}
	if (winName == "" || winName == null) {winName="NEW"}

	PARMS = 'toolbar='+toolbar +',location='+location +',directories='+directories +',status='+status +',menubar='+menubar +',scrollbars=' + scroll + ',resizable=' + resize + ',width=' + width + ',height=' + height
  var newWin = window.open(URL,winName,PARMS);
	/* newWin.screenX = 0;
  newWin.screenY = 0; */
	if (noUrl) {
		newWin.document.writeln("<BR><BR><FONT color='red'>It seems like you forgot to put in a value for URL when you called for <I>openWin()</I></FONT>")
		newWin.document.close()
	}
	return;
}

/* Switch map */
function swapMap(mapId) {
	document.getElementById('map').src = '_images/map_' + mapId  + '.gif';
}

/* Clear form fields */
function clearField(id, state) {
	if (state == 'clear')
		document.getElementById(id).value = '';
	else {
		if (document.getElementById(id).value == '')
			document.getElementById(id).value = 1;
	}
}

function showLayer(infoLayerId, state, strength) {
	grayOut(state, {'opacity':strength});
	if (state == true) {
		document.getElementById(infoLayerId).style.zIndex = 100000;
		document.getElementById(infoLayerId).style.visibility = 'visible';

	}
	else {
		document.getElementById(infoLayerId).style.zIndex = -100000;
		document.getElementById(infoLayerId).style.visibility = 'hidden';
	}
}

function checkSearchField(field, form) {
	if ($(field).value == '' || (($(field).id == 'email_nl' || $(field).id == 'femail') && ($(field).value.length < 6 || ($(field).value.indexOf("@") < 1)  || ($(field).value.indexOf(".") < 1))))
		Effect.Pulsate($(field),{duration:1, pulses: 2});
	else
		$(form).submit();
}

function setPaymentMethod(paymentMethod) {
	document.getElementById('payment_method').value = paymentMethod;
}

function mergeMail(name, prov, top, subject){
	document.location.href="mailto:" + name +"@"+ prov +"."+ top +"?subject=" + subject;
}

function moreInfo(infoLayerId, state) {
	grayOut(state);
	if (state == true) {
		document.getElementById('infoLayer_' + infoLayerId).style.zIndex = 100000;
		document.getElementById('infoLayer_' + infoLayerId).style.visibility = 'visible';

	}
	else {
		document.getElementById('infoLayer_' + infoLayerId).style.zIndex = -100000;
		document.getElementById('infoLayer_' + infoLayerId).style.visibility = 'hidden';
	}
}


function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {};
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }
	//alert(pageHeight);
	var pageHeight='100%';
	var pageWidth='100%'
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;
    dark.style.MozOpacity=opaque;
    dark.style.filter='alpha(opacity='+opacity+')';
    dark.style.zIndex=zindex;
    dark.style.backgroundColor=bgcolor;
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';
  } else {
     dark.style.display='none';
  }
}
