function saveThisPage() {
		url = this.location.href;
		document.execCommand("saveAs", true,"sekretaria");
		this.location.href = url;
	}


function mi_popUp(URL, WIDTH, HEIGHT) {
	Wnd=window.open(URL,"a","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + WIDTH + ",height=" + HEIGHT + ",alwaysRaised=1,dependent=1,directories=no,personalbar=0");

	if (Wnd.opener==null)
	Wnd.opener = window;
	Wnd.opener.name = "mainaponame";
	Wnd.focus();
}

function print_popUp(URL, WIDTH, HEIGHT) {
	Wnd=window.open(URL,"a","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + WIDTH + ",height=" + HEIGHT + ",alwaysRaised=1,dependent=1,directories=no,personalbar=0");

	if (Wnd.opener==null)
	Wnd.opener = window;
	Wnd.opener.name = "mainaponame";
	Wnd.focus();
	Wnd.onload = setTimeout(Wnd.print(), 500);
}

/* Preload und Austausch der Produkt-Bilder */
prdImages = Array();
currentProdImg = 1;

function preloadPrdImg(url) {
	var img = new Image();
	img.src = url;
	prdImages[prdImages.length] = img;
}

function showPrdImg(index) {
	var img = document.getElementById("prdbig");
	img.width = prdImages[index].width;
	img.height = prdImages[index].height;
	img.src = prdImages[index].src;
	currentProdImg = index + 1;
}

function openPopup(url, width, height) {
	var options = 'location=no,menubar=no';
	if (parseInt(width) && parseInt(height)) {
		options += ',width=' + width + ',height=' + height;
	}
	var p = '?';
	if (url.split('?').length != 1) {
		p = '&';
	}
	url += p + 'imgcol=' + currentProdImg;
	return window.open(url, "prdpopup", options);
}

function setSize() {
	var img = document.getElementById('prdimg');
	width = img.width + 10;
	height = img.height + 60;
	if (window.outerWidth) {
		window.outerWidth = width;
		window.outerHeight = height;
	}
	else
		if (window.resizeTo) {
			window.resizeTo(width,height);
		}
}

function openPrdCompare(pcode, width, height) {
	var options = 'location=no,menubar=no';
	if (parseInt(width) && parseInt(height)) {
		options += ',width=' + width + ',height=' + height;
	}
	var url = 'ecms.php?page=prd_compare&pv[p]=' + pcode;
	return window.open(url, 'prdCompare', options);
}

function show_notice_and_disable(formname) {
	popup = document.getElementById("payment_save_notice");

	if (formname== 'OrderPayment') {
		if (popup.style.visibility != 'visible') {
			popup.style.visibility = "visible";
			popup.style.display = "block";

			document.getElementById("doSave").disabled = true;

			document.OrderPayment.submit();

		} else {
			popup.style.visibility = "hidden";
			popup.style.display = "none";

			document.getElementById("doSave").disabled = false;
		}
	}
	if (formname== 'OrderDone') {
		if (popup.style.visibility != 'visible') {
			popup.style.visibility = "visible";
			popup.style.display = "block";

			document.getElementById("doSave").disabled = true;

			document.OrderDone.submit();

		} else {
			popup.style.visibility = "hidden";
			popup.style.display = "none";

			document.getElementById("doSave").disabled = false;
		}
	}
}

// File-Upload Progressbar
// Get the Current Upload-Status (AJAX) and set the Progressbar to match
function getProgress(idx, sid, redirect){
	var myRequest = new Ajax.Request('ecms.php?page=ecms_pageCfgUploadProgress&id=' + idx, {
	onSuccess: function(transport) {
		var splitted = transport.responseText.split("/");
		prozent = splitted[0] / splitted[1] * 100;
		document.getElementById('cfg_progress_done').style.width = (prozent ) + "%";
		document.getElementById('cfg_progress_missing').style.width = (100 - prozent ) + "%";
		if (splitted[1] > 1048576) {
			document.getElementById('cfg_progress_current').innerHTML = Math.round((splitted[0]/1048576)*100)/100+' von '+Math.round((splitted[1]/1048576)*100)/100+' MB ('+Math.round(prozent)+' %)';
		} else {
			document.getElementById('cfg_progress_current').innerHTML = Math.round((splitted[0]/1024)*100)/100+' von '+Math.round((splitted[1]/1024)*100)/100+' kB ('+Math.round(prozent)+' %)';
		}
		// call again until upload is finished
		if (prozent != 100) {
			setTimeout("getProgress('" + idx + "', '" + sid + "', '" + redirect + "')", 500);
		} else {
			document.location.href = redirect;
		}
	}
	});
}

// Start the refreshing of the progressbar
function startProgress(filename, idx, sid, redirect) {
	// do we have a file?
	if (filename) {
	    // show the progressbar
	    document.getElementById("cfg_progressbar").style.display="block";
	    document.getElementById("cfg_progress").style.display="block";
		// get the upload-status
	    setTimeout("getProgress('" + idx + "', '" + sid + "', '" + redirect + "')", 500);
	}
}

// speichern
function saveThisPage() {
	url = this.location.href;
	document.execCommand("saveAs", true,"business-english");
	this.location.href = url;
}

// popup
function sek_popUp(URL, WIDTH, HEIGHT) {
	Wnd=window.open(URL,"a","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + WIDTH + ",height=" + HEIGHT + ",alwaysRaised=1,dependent=1,directories=no,personalbar=0");

	if (Wnd.opener==null)
	Wnd.opener = window;
	Wnd.opener.name = "mainaponame";
	Wnd.focus();
}

// hide container
function hide_container(id) {
	container = document.getElementById(id);
	container.style.display = "none";
	container.style.visibility = "hidden";
}

// bilder speichern verboten
function click (e) {
  if (!e)
    e = window.event;
   	tar=(!e.target?e.srcElement:e.target);

  	if ((e.type && e.type == "contextmenu") || (e.button && e.button == 2) || (e.which && e.which == 3)) {
		if (tar.className == "nodownload" || tar.tagName == "IMG") {
    		if (e.type && e.type != "contextmenu") {
    			if (window.opera) {
	      			window.alert("Die Bilder sind leider nicht zum Download verfügbar..");
	    		} else {
	    			alert("Die Bilder sind leider nicht zum Download verfügbar.");
	    		}
    		}
			return false;
		}

  	}
}
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown = click;
document.oncontextmenu = click;

/* R E A D S P E A K E R - S T A R T */


/* The selected text function */

var selectedString="";

function getSelectedHTML() {
  selectedString="";
  var rng=undefined;
  if (window.getSelection) {
    selobj = window.getSelection();
    if (!selobj.isCollapsed) {
      if (selobj.getRangeAt) {
        rng=selobj.getRangeAt(0);
      }
      else {
        rng = document.createRange();
        rng.setStart(selobj.anchorNode,selobj.anchorOffset);
        rng.setEnd(selobj.focusNode,selobj.focusOffset);
      }
      if (rng) {
        DOM = rng.cloneContents();
        object = document.createElement('div');
        object.appendChild(DOM.cloneNode(true));
        selectedString=object.innerHTML;
      }
      else {
        selectedString=selobj;
      }
    }
  }
  else if (document.selection) {
    selobj = document.selection;
    rng = selobj.createRange();
    if (rng && rng.htmlText) {
      selectedString = rng.htmlText;
    }
    else if (rng && rng.text) {
      selectedString = rng.text;
    }
  }
  else if (document.getSelection) {
    selectedString=document.getSelection();
  }
  	selectedString = cleanSelectedString(selectedString);
}

function copyselected()
{
  setTimeout("getSelectedHTML()",50);
  return true;
}

document.onmouseup = copyselected;
document.onkeyup = copyselected;

/* The expanding function */

function readspeaker(rs_call,rs_div)
{
  if (selectedString.length>0) {
    rs_call=rs_call.replace("/cgi-bin/rsent?","/enterprise/rsent_wrapper.php?");
  }
  savelink=rs_call+"&save=1";
  start_rs_table="<table style='border:1px solid #aeaeae; font-size: 10px;'><tr><td>";
  rs_embed="<object type='application/x-shockwave-flash' data='http://media.readspeaker.com/flash/readspeaker20.swf?mp3="+escape(rs_call)+"&autoplay=1&rskin=bump' height='20' width='250'><param name='movie' value='http://media.readspeaker.com/flash/readspeaker20.swf?mp3="+escape(rs_call)+"&autoplay=1&rskin=bump' /><param name='quality' value='high' /><param name='SCALE' value='exactfit' /><param name='wmode' value='transparent' /><embed wmode='transparent' src='http://media.readspeaker.com/flash/readspeaker20.swf?mp3="+escape(rs_call)+"&autoplay=1&rskin=bump' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwaveflash' scale='exactfit' height='20' width='250' /></embed></object>";
  rs_downloadlink="<br />Speech-enabled by <a href='http://www.readspeaker.com'>ReadSpeaker</a><br /><a href='"+savelink+"'>Download audio</a>";
  close_rs="<br /><a href='#' onclick='close_rs_div(\""+rs_div+"\"); return false;'>Close player</a>";
  end_rs_table="</td></tr></table>";

  var x=document.getElementById(rs_div);

  x.innerHTML=start_rs_table+rs_embed+rs_downloadlink+close_rs+end_rs_table;
}

function close_rs_div(rs_div)
{
  var x=document.getElementById(rs_div);
  x.innerHTML="";
}

/* Selected text cleaning function */

function cleanSelectedString(theString)
{
	var comments = theString.match(/<!--/gi);
	var temp = "";
	if(comments != undefined)
	{
		for(i=0;i<comments.length;i++)
		{
			var temp = theString.substring(theString.search(/<!--/gi),theString.search(/-->/gi)+3);
			theString = theString.replace(temp,"");
		}
	}
	var regexp = /(<\/?[A-Z]+[0-9]?)\s?[^>]*>/gi
	theString = theString.replace(regexp, "$1>");
	var regexp2 = /<\/?[A-Z]+[0-9]?\s?>/gi
	theString = theString.replace(regexp2, function(m) { return returnTags(m);});
	var regexp_spaces = /\s+?\s*/gi
	theString = theString.replace(regexp_spaces, " ");
	var regexp_br = /(<br>)+?\s?(<br>\s*)*/gi
	theString = theString.replace(regexp_br, "<br>");
	return theString;
}

function returnTags(thematch)
{
	var regtag = /<\/?(h[1-6]|a|area|ul|ol|dl|dd|dt|li|table|td|tr|th|p|hr|br)>/i
	if(regtag.test(thematch))
	{
		return thematch;
	}
	else
	{
		return "";
	}
}

/* R E A D S P E A K E R  - E N D */
