
//window.onerror=silentErrorHandler;
//function silentErrorHandler() {return true;}

var show_ax_img = false;
var myGlobalHandlers = {
	onCreate: function(){
		if (show_ax_img){
			Element.show('systemWorking1')
		};
	},
	onComplete: function() {
		if(Ajax.activeRequestCount == 0){
			if (show_ax_img){
			Element.hide('systemWorking1');
			show_ax_img = false;
			};
		}
	}
};
 
//Ajax.Responders.register(myGlobalHandlers);

function hide_open(){
weg2('opent_l','fade');
show2('opent_s','blind');
	if (cookiesAllowed()){
		setCookie('show_opentime',false,1)
	}	
}

function show_open(){
/*
x='<?php echo open_time_plain()?>';
txt='<br><b style="font-size:1.6em;color:#6387b6">&nbsp; &nbsp; Unsere &Ouml;ffnungszeiten:</b><br><br style="line-height:40px"> <div style="font-size:1.1em;text-align:center;font-weight:bold;line-height:22px">'+x+'</div>';
mldg='OK';
h=260;
w=530;
//grayOut(true);
alert_win2(txt,mldg,h,w);
//grayOut(false);
*/
weg2('opent_s','fade');
show2('opent_l','blind');
	if (cookiesAllowed()){
		setCookie('show_opentime',false,-1)
	}
}


function del_plz_cook(){
	setCookie('plz','',-3);
	window.location.reload();
}



function do_qu(url,pars,ziel){
show_ax_img=true;
var ur = url;
var pa = pars;
var ta = ziel;
var myAjax = new Ajax.Updater(ta, ur, {method: 'get', parameters: pa});
}



function ax_subm_form(form_id,url){
var pars=$(form_id).serialize() 
var myAjax = new Ajax.Request(
	url, 
	{
		method: 'post', 
		parameters: pars, 
		onComplete: conf_data_saved,
		onFailure: fail_data_saved
	});
}

function conf_data_saved(originalRequest){
$('message_div').update('Die Daten wurden gespeichert.').show();
setTimeout("weg2('message_div','puff')",0)
}

function fail_data_saved(originalRequest){
$('message_div').update('Problem!<br>Die Daten wurden NICHT gespeichert.').show();
}



function request_ajax_source(para){

var url = 'ajax_source.php';
var pars = 'id='+para;
var myAjax = new Ajax.Request(
	url, 
	{
		method: 'get', 
		parameters: pars, 
		onComplete: showResponse_coo
	});
} 





String.prototype.htmlEntities = function () {   

//usage:
//var tmp = '<html><head></head>';
//var safe= tmp.htmlEntities(); // Returns ““&lt;html&gt;&lt;head&gt;&lt;/head&gt;””

return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
};

function set_coo(bool,what,expire){
//true = hide
if(bool) {bool=0}else{bool=1}
setCookie(what,bool,expire);
}


function cookiesAllowed() {
   setCookie('checkCookie', 'test', 1);
   if (getCookie('checkCookie')) {
      deleteCookie('checkCookie');
      return true;
   }
   return false;
}

function setCookie(name,value,expires, options) {
   if (options===undefined) { options = {}; }
   if ( expires ) {
      var expires_date = new Date();
      expires_date.setDate(expires_date.getDate() + expires)
   }
   document.cookie = name+'='+escape( value ) +
      ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + 
      ( ( options.path ) ? ';path=' + options.path : '' ) +
      ( ( options.domain ) ? ';domain=' + options.domain : '' ) +
      ( ( options.secure ) ? ';secure' : '' );
}

function getCookie( name ) {
   var start = document.cookie.indexOf( name + "=" );
   var len = start + name.length + 1;
   if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
      return null;
   }
   if ( start == -1 ) return null;
   var end = document.cookie.indexOf( ';', len );
   if ( end == -1 ) end = document.cookie.length;
   return unescape( document.cookie.substring( len, end ) );
}

function deleteCookie( name, path, domain ) {
   if ( getCookie( name ) ) document.cookie = name + '=' +
      ( ( path ) ? ';path=' + path : '') +
      ( ( domain ) ? ';domain=' + domain : '' ) +
      ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}


// trim
String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
   return this.replace(/^\s+/g,"");
}
String.prototype.rtrim = function() {
   return this.replace(/\s+$/g,"");
}

function Right(str, n){
    if (n <= 0){
       return "";
    }else{ 
	if (n > String(str).length)
       {return str;
    }else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
	   }
    }
}

// sort array
Array.prototype.sortNum = function() {
   return this.sort( function (a,b) { return a-b; } );
}

// format numers
function formatNumber(num,prefix){
   prefix = prefix || '';
   num += '';
   var splitStr = num.split('.');
   var splitLeft = splitStr[0];
   var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : '';
   var regx = /(\d+)(\d{3})/;
   while (regx.test(splitLeft)) {
      splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
   }
   return prefix + splitLeft + splitRight;
}

function unformatNumber(num) {
   return num.replace(/([^0-9\.\-])/g,'')*1;
}

// end 



function confirm_goto(url){
txt='<img src="images/icons1/ic_n_50/Icon-note.png" width="64" height="64" style="float:left;margin-right:9px"/>';
txt += 'Wirklich l'+unescape("%F6")+'schen? ';				
		var OK='Ja, l&ouml;schen';	
		Dialog.confirm("<div style='padding:20px 10px 10px 10px ;font-size:1.3em;text-align:left'>"+txt+"</div>", 
		   {className: "dialog", width:410, okLabel: OK, 
		   buttonClass: "button_alert",
		   id: "myDialogId", destroyOnClose:true,
		   cancel:function(win) {return false;},
		   ok:function(win) {goto(url);  return true;}
		  });
}

function goto(url){window.location.href = url;}

function confirm_win(txt,OK,ex){
Dialog.confirm("<div style='padding:20px 10px 10px 10px ;font-size:1.3em;text-align:left'>"+txt+"</div>", 
               {className: "dialog", width:400, okLabel: OK, 
               buttonClass: "button_alert",
               id: "myDialogId",
               cancel:function(win) {debug("cancel");},
               ok:function(win) {exec(ex); return true;}
              });
// function exec(ex) gelöscht
}



// message
function alert_win2(txt,mldg,h,w){
img='<img src="images/icons1/ic_n_50/Icon-note.png" width="64" height="64" style="float:left;margin: 0px 14px 10px 0px"/>';
txt=img+txt;
alert_win(txt,mldg,h,w)
}

//AL
function alert_win_AL(txt,mldg,h,w){
img='<img src="images/icons1/ic_n_50/120px-Icon-warning.png" width="60" height="60" style="float:left;margin: 0px 14px 10px 0px"/>';
txt=img+txt;
alert_win(txt,mldg,h,w)
}

//OK
function alert_win_OK(txt,mldg,h,w){
img='<img src="images/icons1/icons_neu/Yes.png" width="48" height="48" style="float:left;margin: 0px 14px 10px 0px"/>';
txt=img+txt;
alert_win(txt,mldg,h,w)
}


function alert_win(txt,mldg,h,w){
if (h==undefined) h=130;
if (w==undefined) w=400;
if (mldg==undefined) mldg='OK';
Dialog.alert("<div style='padding:20px 10px 10px 10px;font-size:1.3em;text-align:left'>"+txt+"</div>", 
{className: "dialog", buttonClass: "button_alert", width:w, height:h, okLabel: mldg, ok:function(win) {return true;}});
}





var timeout;
function openInfoDialog(txt,ht,tout) {

  Dialog.info("<div style='padding:20px 10px 10px 10px ;font-size:1.5em;text-align:center;color:#009;'>"+txt+"<br><br><div align=\"center\"><img src=\"images/icons/anim/loading.gif\" width=\"32\" height=\"32\"></div></div>",
               {className: "dialog", width:400, height:ht, showProgress: true});
  timeout=tout;
  setTimeout(infoTimeout, 1000)
}

function infoTimeout() {
  timeout--;
  if (timeout >0) {
   // Dialog.setInfoMessage("Test of info panel, it will close <br />in " + timeout + "s ...")
    setTimeout(infoTimeout, 1000)
 }
 else
  Dialog.closeInfo()
}


function open_contact_owner(page){
/*
alert(page);

alert("Protokoll: " + location.protocol);
alert("Host: " + location.host);
alert("Hostname: " + location.hostname);
alert("Href: " + location.href);
alert("Pathname :" + location.pathname);
alert("Port: " + location.port);
alert("Search: " + location.search);
*/
page+=location.search;
var win346 = new Window(
{
className: "mac_os_x",  
width:720, height:470, zIndex: 100, 
resizable: true, 
title: "Kontakt, Feedback, Support - gern beantworten wir Ihre Fragen...", 
showEffect:Effect.Appear, hideEffect: Effect.Fade, 
destroyOnClose:true,
draggable:false, 
wiredDrag: false});
$url='form_ajax_contact_owner.php?p='+page;
win346.setAjaxContent($url,{method:'get'},{showCentered:true},{showModal:true});
}

function open_vorteile_reg(){

var win346 = new Window(
{
className: "mac_os_x",  
width:720, height:550, zIndex: 100, 
resizable: true, 
title: "Registrieren Sie sich...", 
showEffect:Effect.Appear, hideEffect: Effect.Fade, 
destroyOnClose:true,
draggable:false, 
wiredDrag: false});
$url='form_vorteile_reg.php';
win346.setAjaxContent($url,{method:'get'},{showCentered:true},{showModal:true});
}

function open_coupon_info(){
var win346 = new Window(
{
className: "mac_os_x",  
width:720, height:550, zIndex: 100, 
resizable: true, 
title: "Tragen Sie Ihren Coupon-Code ein...", 
showEffect:Effect.Appear, hideEffect: Effect.Fade, 
destroyOnClose:true,
draggable:false, 
wiredDrag: false});
$url='form_coupons.php';
win346.setAjaxContent($url,{method:'get'},{showCentered:true},{showModal:true});
}






// in upload docs und in member_change
function conf_upload_doc_nozip(file)
{
if (file==='') {
	alert_win2('Bitte eine Datei ausw&auml;hlen mit Durchsuchen...','OK',120,400);
	return false;
}else{
	$dot_pos =file.lastIndexOf('.');
	$file_type=file.substr($dot_pos,4);
	$file_type=$file_type.toLowerCase();
		if ($file_type=='.pdf' || $file_type=='.doc' ){
			return true;
		}else{
			alert_win2('Der Upload von '+$file_type+' ist hier nicht erlaubt! <br /><br />Bitte beachten Sie die Hinweise.','OK',120,400);
			return false;
		}
}
}



function show_soc_bm(){
var url ='include_frags/soc_bokkmarks.htm';
window.if_soc_bm.location = url; 
show2('soc_bm','blind');
$('open_soc_bm').hide();
$('close_soc_bm').show();
$('trig_show').hide();
$('trig_hide').show();
}
function hide_soc_bm(){
weg2('soc_bm','blind');
$('open_soc_bm').show();
$('close_soc_bm').hide();
$('trig_hide').hide();
$('trig_show').show();
}


function get_current_page_name(){
var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
return sPage;
}

function getHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  return myHeight;
}

function getWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  return myWidth;
}

// Call: strReplaceAll2 = strText.replaceAll( "th", "[X]" ) 
String.prototype.replaceAll = function( 
strTarget, // The substring you want to replace
strSubString // The string you want to replace in.
){
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
while (intIndexOfMatch != -1){
strText = strText.replace( strTarget, strSubString )
intIndexOfMatch = strText.indexOf( strTarget );
} 
return( strText );
}



function weg2(id,met) {
 if (met=='switch') {
	//Sound.play('sound/puff.mp3');
	new Effect.SwitchOff(id);
	
 } else if (met=='drop') {
   new Effect.DropOut(id);
   
 } else if (met=='blind') {
   new Effect.BlindUp(id);

 } else if (met=='squish') {
	new Effect.squish(id); 
	
 } else if (met=='fold') {

	new Effect.Fold(id);
  
 } else if (met=='shrink') {
	new Effect.Shrink(id); 
	
 } else if (met=='slide') {
	new Effect.SlideUp(id);  
	
 } else if (met=='puff') {
	new Effect.Puff(id,{duration:4.5});
 
 } else if (met=='fade') {
	new Effect.Fade(id,{duration:1.2, from:0.9});

 }

}




function show2(id,met) {

 if (met=='blind') {
	new Effect.BlindDown(id);
 } else if (met=='grow') {
	new Effect.Grow(id); 
 } else if (met=='slide') {
	new Effect.SlideDown(id);  
 } else if (met=='appear') {
	new Effect.Appear(id,{duration:1.2, from:0.9});
 }

}

function do_transl1(lang_code){
source_text = $('lang_src').innerHTML;
//source_text = source_text.stripTags();
target='lang_target';
	google.language.translate(source_text, "de", lang_code, function(result) { 
		if (!result.error) { 
		var container = $(target); 
		container.innerHTML = result.translation; 
		//$('help_descr_'+lang_code).value=result.translation;
		show2('lang_target','blind')		
	}});
}


function fullw(){
window.moveTo(0,0); 
window.resizeTo(screen.availWidth,screen.availHeight+3); 
} 

function gettranslation(lang) {

var v_link = window.location;
var width= window.screen.width-200;
var height= window.screen.height-100;
var top=190;
var left=90;

if (lang=='e') {
var trans_link = "http://translate.google.com/translate?hl=en&ie=UTF-8&oe=UTF-8&langpair=de%7Cen&u=";
trans_link = trans_link + v_link;
trans_link = trans_link + '&prev=/language_tools';
}else{
var trans_link = "http://translate.google.com/translate?hl=en&ie=UTF-8&oe=UTF-8&langpair=de%7Cfr&u=";
trans_link = trans_link + v_link;
trans_link = trans_link + '&prev=/language_tools';
}
popUpWin = open(trans_link, 'popUpWin', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function gettranslation2(lang) {
if (lang=='') {return false}

var v_link = window.location;
var width= window.screen.width-200;
var height= window.screen.height-100;
var top=190;
var left=90;

var trans_link = "http://translate.google.com/translate?hl=en&ie=UTF-8&oe=UTF-8&sl=de&tl=";
    trans_link = trans_link + lang;
	trans_link = trans_link + '&u=' + v_link;

popUpWin = open(trans_link, 'popUpWin', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
/*




deustch nach

arabisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=ar&hl=de&ie=UTF-8

bulgarisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=bg&hl=de&ie=UTF-8

chinesisch (traditionell)
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=zh-TW&hl=de&ie=UTF-8

chinesisch (vereinfacht)
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=zh-CN&hl=de&ie=UTF-8

dänisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=da&hl=de&ie=UTF-8

finnisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=fi&hl=de&ie=UTF-8

griechisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=el&hl=de&ie=UTF-8

hebräisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=iw&hl=de&ie=UTF-8

hindi
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=hi&hl=de&ie=UTF-8

indonesisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=id&hl=de&ie=UTF-8

italienisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=it&hl=de&ie=UTF-8

japanisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=ja&hl=de&ie=UTF-8

katalanisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=ca&hl=de&ie=UTF-8

koreanisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=ko&hl=de&ie=UTF-8

kroatisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=hr&hl=de&ie=UTF-8

lettisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=lv&hl=de&ie=UTF-8

litauisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=lt&hl=de&ie=UTF-8

niederländisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=nl&hl=de&ie=UTF-8

norwegisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=no&hl=de&ie=UTF-8

polnisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=pl&hl=de&ie=UTF-8

portugiesisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=pt&hl=de&ie=UTF-8

rumänisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=ro&hl=de&ie=UTF-8

russisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=ru&hl=de&ie=UTF-8

schwedisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=sv&hl=de&ie=UTF-8

serbisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=sr&hl=de&ie=UTF-8

slowakisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=sk&hl=de&ie=UTF-8

slovenisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=sl&hl=de&ie=UTF-8

spanisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=es&hl=de&ie=UTF-8

tagalog
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=tl&hl=de&ie=UTF-8

tschechisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=cs&hl=de&ie=UTF-8

ukrainisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=uk&hl=de&ie=UTF-8

vietnamesisch
http://translate.google.de/translate?u=http%3A%2F%2Fwww.musikhaus-grimm.ch%2Fcatalog_neu%2Findex.php&sl=de&tl=vi&hl=de&ie=UTF-8

*/

function grayOut(vis, options) {
//http://www.hunlock.com/blogs/Snippets:_Howto_Grey-Out_The_Screen
//To set all three: {'opacity':'70', 'bgcolor':'#0000FF', 'zindex':'25' }. 
  // 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 || 2050;
  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%';
    }   
    //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';
  }
}



