// Script by DeLucaMarketing
// V1.6 - 2003-12-04

window.defaultStatus = "Acvisa - die richtige Adresse für Contractors und Feststellen";
var scriptID = "script.js";				// to identify whether this script is loaded
var popupWin = false;						// popup window flag - true means there is an open popup window
var admin="marco@delucamarketing.ch";	// standard webmaster e-mail
var browserAlert = false;					// outdated browser
var debug = false;							// in debug mode a lot of alerts pop up

// Error handling
function stopError()	{return true;}		
// if (!debug) window.onerror=stopError;

// Determine browser language
var languageinfo = navigator.language ? navigator.language : navigator.userLanguage;
if (debug) alert (languageinfo);
if      (languageinfo.indexOf('de') != -1){languageinfo = 'de';}
else if (languageinfo.indexOf('en') != -1){languageinfo = 'en';}
else if (languageinfo.indexOf('fr') != -1){languageinfo = 'fr';}
else if (languageinfo.indexOf('it') != -1){languageinfo = 'it';}
else                                      {languageinfo = '';}

// Determine Browser
if (parseInt(navigator.appVersion) < 4)								// outdated browser?
	browserAlert = true;

if (-1 != location.href.indexOf("home.htm"))							// entry page?
{
	if (browserAlert)															// check browser
		openWindow("browseralert.htm", "Alert", 350, 250, "")

	if (location.search == "?fullw")
	{
		window.moveTo(0,0);													// move browser window to top left
		var b = browserID();
		if (b == 1 || b ==4)													// resize browser to full size (IE and NS6)
			self.resizeTo(screen.availWidth, screen.availHeight);
		else if (b == 2)														// Netscape 4 requires more effort (as usual)
		{
			var nh = window.outerHeight - window.innerHeight;
			var nw = window.outerWidth - window.innerWidth
			self.resizeTo(screen.availWidth-nw, screen.availHeight-nh);
		}
	}
}

function winstatus(text)
{
	window.status = text;
}

browser = browserID();
function browserID()
{
	var browser=0;
	if(-1 != navigator.userAgent.indexOf("Opera"))
		browser = 3;
	else if(-1 != navigator.userAgent.indexOf("MSIE"))
		browser = 1;
	else if( -1 != navigator.userAgent.indexOf("Gecko") && -1 != navigator.userAgent.indexOf("Netscape")) // Netscape6+
		browser = 4;
	else if( -1 != navigator.userAgent.indexOf("Gecko") && -1 == navigator.userAgent.indexOf("Netscape")) // Mozilla
		browser = 5;
	else if(-1 != navigator.userAgent.indexOf("Mozilla"))
		browser = 2;
	return browser;
}
		
function openWindow(url, name, w, h, flags)
{
	//	flags = 'directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes';
	w = (w > screen.availWidth)  ? screen.availWidth  - 40 : w;
	h = (h > screen.availHeight) ? screen.availHeight - 120 : h;
	var winX = (screen.availWidth - w)*.5;
	var winY = (screen.availHeight - h)*.5;
	// if (popupWin && !popupWin.closed) popupWin.close();
	popupWin = window.open(url, name, 'width=' + w + ',height=' + h + ', left=' + winX + ',top=' + winY + ',screenX=' + winX + ',screenY=' + winY + ',' + flags);
	popupWin.focus();
}

function fullsizeWindow()
{
	self.resizeTo(screen.availWidth, screen.availHeight);
}

function removeelements()
{
	document.bgColor="white";
	document.body.background='';
	document.bgColor = "white";
	document.fgColor = "black";
	document.linkColor = "black";
	document.vlinkColor = "black";
	document.alinkColor = "black";
	
   var remove_el = document.all.noprint;
   if (remove_el != '' && remove_el.length == null)
      remove_el.style.display = 'none'
   else
   {
      for (i=0; i<remove_el.length; i++)
         remove_el[i].style.display='none'
   }
}

function chk_Email(email)
{
	if (email.length>0)
	{
		i   = email.indexOf("@");
		j   = email.indexOf(".",i);
		k   = email.indexOf(",");
		kk  = email.indexOf(" ");
		jj  = email.lastIndexOf(".")+1;
		len = email.length;

		if ((i>0) && (j>(i+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=4))
			return true;
	}
	return false;
}

// -----------------------------------------------------------------------------
// Converts encoded characters to unescaped hex chars for output in e.g. alert()
// -----------------------------------------------------------------------------
function Conv2Unesc(str) // 1.0
{
	str = str.replace(/&Auml;/, unescape('%C4'));	// Ae
	str = str.replace(/&Ouml;/, unescape('%D6'));	// Oe
	str = str.replace(/&Uuml;/, unescape('%DC'));	// Ue
	str = str.replace(/&auml;/, unescape('%E4'));	// ae
	str = str.replace(/&ouml;/, unescape('%F6'));	// oe
	str = str.replace(/&uuml;/, unescape('%FC'));	// ue

	str = str.replace(/&szlig;/, unescape('%DF'));	// Esszet

	str = str.replace(/&copy;/, unescape('%A9'));
	str = str.replace(/&laquo;/, unescape('%ab'));
	str = str.replace(/&raquo;/, unescape('%bb'));

	str = str.replace(/&ccedil;/, unescape('%E7'));
	str = str.replace(/&eacute;/, unescape('%e9'));
	str = str.replace(/&egrave;/, unescape('%e8'));
	str = str.replace(/&agrave;/, unescape('%e0'));
	str = str.replace(/&ecirc;/, unescape('%ea'));
	str = str.replace(/&ucirc;/, unescape('%fb'));
	str = str.replace(/&acirc;/, unescape('%e2'));

	return str;
}

