function BrowserType() {
	ajaxRequest=createXmlHttp();
	if (ajaxRequest) {
		type = (navigator.appName=="Microsoft Internet Explorer") ? "internet_explorer" : "other";
		ajaxRequest.open("get", "ajax.php?action=browser_type&type="+type, true);
		ajaxRequest.onreadystatechange=AjaxBrowserType;
		ajaxRequest.send(null);
	}
}

function AjaxBrowserType() {
	if (ajaxRequest.readyState==4 && ajaxRequest.responseText)
		internet_explorer=(ajaxRequest.responseText=="TRUE");
}

function TrimString(input_string) {
	while (input_string.indexOf("&nbsp;")!=-1) input_string=input_string.replace(/&nbsp;/, " ");
	while (input_string.indexOf(String.fromCharCode(160))!=-1) input_string=input_string.replace(String.fromCharCode(160), String.fromCharCode(32));
	while (input_string.indexOf("  ")!=-1) input_string=input_string.replace(/  /, " ");
	if (input_string.substring(0, 1)==" ") input_string=input_string.substring(1, input_string.length);
	if (input_string.substring(input_string.length-1, input_string.length)==" ") input_string=input_string.substring(0, input_string.length-1);
	return input_string;
}

function InputText(input_string, html_tags_allowed) {
	input_string=TrimString(input_string);
	if (!html_tags_allowed) {
		regular_expression=/<.*?>/;
		while (regular_expression.test(input_string)) input_string=input_string.replace(/<.*?>/, "");
	}

	while (input_string.indexOf("\\\\")!=-1) input_string=input_string.replace(/\\\\/, "\\");
	while (input_string.indexOf("\\\"")!=-1) input_string=input_string.replace(/\\\"/, "\"");
	while (input_string.indexOf("\\'")!=-1) input_string=input_string.replace(/\\'/, "'");
	while (input_string.indexOf("&lt;")!=-1) input_string=input_string.replace(/&lt;/, "<");
	while (input_string.indexOf("&gt;")!=-1) input_string=input_string.replace(/&gt;/, ">");
	while (input_string.indexOf("&laquo;")!=-1) input_string=input_string.replace(/&laquo;/, "«");
	while (input_string.indexOf("&raquo;")!=-1) input_string=input_string.replace(/&raquo;/, "»");

	while (input_string.indexOf("&otilde;")!=-1) input_string=input_string.replace(/&otilde;/, "õ");
	while (input_string.indexOf("&Otilde;")!=-1) input_string=input_string.replace(/&Otilde;/, "Õ");
	while (input_string.indexOf("&ucirc;")!=-1) input_string=input_string.replace(/&ucirc;/, "û");
	while (input_string.indexOf("&Ucirc;")!=-1) input_string=input_string.replace(/&Ucirc;/, "Û");
	while (input_string.indexOf("&#213;")!=-1) input_string=input_string.replace(/&#213;/, "õ");
	while (input_string.indexOf("&#245;")!=-1) input_string=input_string.replace(/&#245;/, "Õ");
	while (input_string.indexOf("&#251;")!=-1) input_string=input_string.replace(/&#251;/, "û");
	while (input_string.indexOf("&#219;")!=-1) input_string=input_string.replace(/&#219;/, "Û");
	while (input_string.indexOf("&#337;")!=-1) input_string=input_string.replace(/&#337;/, "õ");
	while (input_string.indexOf("&#336;")!=-1) input_string=input_string.replace(/&#336;/, "Õ");
	while (input_string.indexOf("&#369;")!=-1) input_string=input_string.replace(/&#369;/, "û");
	while (input_string.indexOf("&#368;")!=-1) input_string=input_string.replace(/&#368;/, "Û");

	while (input_string.indexOf("&#132;")!=-1) input_string=input_string.replace(/&#132;/, "\"");
	while (input_string.indexOf("&#147;")!=-1) input_string=input_string.replace(/&#147;/, "\"");
	while (input_string.indexOf("&#148;")!=-1) input_string=input_string.replace(/&#148;/, "\"");
	while (input_string.indexOf("&#145;")!=-1) input_string=input_string.replace(/&#145;/, "'");
	while (input_string.indexOf("&#146;")!=-1) input_string=input_string.replace(/&#146;/, "'");
	while (input_string.indexOf("&#150;")!=-1) input_string=input_string.replace(/&#150;/, "--");
	while (input_string.indexOf("&#151;")!=-1) input_string=input_string.replace(/&#151;/, "---");
	while (input_string.indexOf("&#133;")!=-1) input_string=input_string.replace(/&#133;/, "...");
	while (input_string.indexOf("&#215;")!=-1) input_string=input_string.replace(/&#215;/, "x");
	while (input_string.indexOf("&#171;")!=-1) input_string=input_string.replace(/&#171;/, "«");
	while (input_string.indexOf("&#187;")!=-1) input_string=input_string.replace(/&#187;/, "»");
	while (input_string.indexOf("&#8220;")!=-1) input_string=input_string.replace(/&#8220;/, "\"");
	while (input_string.indexOf("&#8221;")!=-1) input_string=input_string.replace(/&#8221;/, "\"");
	while (input_string.indexOf("&#8222;")!=-1) input_string=input_string.replace(/&#8222;/, "\"");
	while (input_string.indexOf("&#8216;")!=-1) input_string=input_string.replace(/&#8216;/, "'");
	while (input_string.indexOf("&#8217;")!=-1) input_string=input_string.replace(/&#8217;/, "'");
	while (input_string.indexOf("&#8211;")!=-1) input_string=input_string.replace(/&#8211;/, "--");
	while (input_string.indexOf("&#8212;")!=-1) input_string=input_string.replace(/&#8212;/, "---");
	while (input_string.indexOf("&#8230;")!=-1) input_string=input_string.replace(/&#8230;/, "...");

	while (input_string.indexOf(String.fromCharCode(337))!=-1) input_string=input_string.replace(String.fromCharCode(337), String.fromCharCode(245));
	while (input_string.indexOf(String.fromCharCode(336))!=-1) input_string=input_string.replace(String.fromCharCode(336), String.fromCharCode(213));
	while (input_string.indexOf(String.fromCharCode(369))!=-1) input_string=input_string.replace(String.fromCharCode(369), String.fromCharCode(251));
	while (input_string.indexOf(String.fromCharCode(368))!=-1) input_string=input_string.replace(String.fromCharCode(368), String.fromCharCode(219));
	while (input_string.indexOf(String.fromCharCode(132))!=-1) input_string=input_string.replace(String.fromCharCode(132), "\"");
	while (input_string.indexOf(String.fromCharCode(147))!=-1) input_string=input_string.replace(String.fromCharCode(147), "\"");
	while (input_string.indexOf(String.fromCharCode(148))!=-1) input_string=input_string.replace(String.fromCharCode(148), "\"");
	while (input_string.indexOf(String.fromCharCode(145))!=-1) input_string=input_string.replace(String.fromCharCode(145), "'");
	while (input_string.indexOf(String.fromCharCode(146))!=-1) input_string=input_string.replace(String.fromCharCode(146), "'");
	while (input_string.indexOf(String.fromCharCode(150))!=-1) input_string=input_string.replace(String.fromCharCode(150), "--");
	while (input_string.indexOf(String.fromCharCode(151))!=-1) input_string=input_string.replace(String.fromCharCode(151), "---");
	while (input_string.indexOf(String.fromCharCode(133))!=-1) input_string=input_string.replace(String.fromCharCode(133), "...");
	while (input_string.indexOf(String.fromCharCode(215))!=-1) input_string=input_string.replace(String.fromCharCode(215), "x");
	while (input_string.indexOf(String.fromCharCode(8220))!=-1) input_string=input_string.replace(String.fromCharCode(8220), "\"");
	while (input_string.indexOf(String.fromCharCode(8221))!=-1) input_string=input_string.replace(String.fromCharCode(8221), "\"");
	while (input_string.indexOf(String.fromCharCode(8222))!=-1) input_string=input_string.replace(String.fromCharCode(8222), "\"");
	while (input_string.indexOf(String.fromCharCode(8216))!=-1) input_string=input_string.replace(String.fromCharCode(8216), "'");
	while (input_string.indexOf(String.fromCharCode(8217))!=-1) input_string=input_string.replace(String.fromCharCode(8217), "'");
	while (input_string.indexOf(String.fromCharCode(8211))!=-1) input_string=input_string.replace(String.fromCharCode(8211), "--");
	while (input_string.indexOf(String.fromCharCode(8212))!=-1) input_string=input_string.replace(String.fromCharCode(8212), "---");
	while (input_string.indexOf(String.fromCharCode(8230))!=-1) input_string=input_string.replace(String.fromCharCode(8230), "...");

	while (input_string.indexOf("----")!=-1) input_string=input_string.replace(/----/, "---");
	input_string=input_string.replace(/^\-+$/, "-");

	return input_string;
}

function InputTextarea(input_string) {
	input_string=TrimString(input_string);
	while (input_string.indexOf(String.fromCharCode(13)+String.fromCharCode(10))!=-1) input_string=input_string.replace(String.fromCharCode(13)+String.fromCharCode(10), "|");
	while (input_string.indexOf(String.fromCharCode(13))!=-1) input_string=input_string.replace(String.fromCharCode(13), "|");
	while (input_string.indexOf(String.fromCharCode(10))!=-1) input_string=input_string.replace(String.fromCharCode(10), "|");
	while (input_string.indexOf("||")!=-1) input_string=input_string.replace("||", "|");
	if (input_string.substring(0, 1)=="|") input_string=input_string.substring(1, input_string.length);
	if (input_string.substring(input_string.length-1, input_string.length)=="|") input_string=input_string.substring(0, input_string.length-1);
	input_string=InputText(input_string);
	return input_string;
}

function InputFormattedTextarea(input_string) {
	input_string=TrimString(input_string);
	while (input_string.indexOf(String.fromCharCode(13)+String.fromCharCode(10))!=-1) input_string=input_string.replace(String.fromCharCode(13)+String.fromCharCode(10), "|");
	while (input_string.indexOf(String.fromCharCode(13))!=-1) input_string=input_string.replace(String.fromCharCode(13), "|");
	while (input_string.indexOf(String.fromCharCode(10))!=-1) input_string=input_string.replace(String.fromCharCode(10), "|");
	while (input_string.indexOf("|||")!=-1) input_string=input_string.replace("|||", "||");
	if (input_string.substring(0, 1)=="|") input_string=input_string.substring(1, input_string.length);
	if (input_string.substring(0, 1)=="|") input_string=input_string.substring(1, input_string.length);
	if (input_string.substring(input_string.length-1, input_string.length)=="|") input_string=input_string.substring(0, input_string.length-1);
	if (input_string.substring(input_string.length-1, input_string.length)=="|") input_string=input_string.substring(0, input_string.length-1);
	input_string=InputText(input_string, "html_tags_allowed");
	return input_string;
}

function StandardDate(year, month, day) {
	standard_date="";
	year = (year) ? Number(year) : 0;
	if (year<10) year="000"+year;
	else if (year<100) year="00"+year;
	else if (year<1000) year="0"+year;
	standard_date=year;
	month = (month) ? Number(month) : 0;
	if (month<10) month="0"+month;
	standard_date+="-"+month;
	day = (day) ? Number(day) : 0;
	if (day<10) day="0"+day;
	standard_date+="-"+day;
	return standard_date;
}

function StandardDatetime(year, month, day, hour, minute, second) {
	standard_datetime="";
	year = (year) ? Number(year) : 0;
	if (year<10) year="000"+year;
	else if (year<100) year="00"+year;
	else if (year<1000) year="0"+year;
	standard_datetime=year;
	month = (month) ? Number(month) : 0;
	if (month<10) month="0"+month;
	standard_datetime+="-"+month;
	day = (day) ? Number(day) : 0;
	if (day<10) day="0"+day;
	standard_datetime+="-"+day;

	hour = (hour) ? Number(hour) : 0;
	if (hour<10) hour="0"+hour;
	standard_datetime+=" "+hour;
	minute = (minute) ? Number(minute) : 0;
	if (minute<10) minute="0"+minute;
	standard_datetime+=":"+minute;
	second = (second) ? Number(second) : 0;
	if (second<10) second="0"+second;
	standard_datetime+=":"+second;
	standard_datetime=standard_datetime.replace(/24:\d\d:\d\d/, "00:00:00");
	standard_datetime=standard_datetime.replace(/:60:00/, ":00:00");
	return standard_datetime;
}

function Singular(input_string) {
	if (input_string.substring(input_string.length-4, input_string.length)=="shes" || input_string.substring(input_string.length-3, input_string.length)=="ses")
		input_string=input_string.substring(0, input_string.length-2);
	else if (input_string.substring(input_string.length-1, input_string.length)=="s")
		input_string=input_string.substring(0, input_string.length-1);
	return input_string;
}

function Plural(input_string) {
	input_string = (input_string.substring(input_string.length-2, input_string.length)=="sh" || input_string.substring(input_string.length-1, input_string.length)=="s") ? input_string+"es" : input_string+"s";
	return input_string;
}

function ValidUsername(input_string) {
	if (input_string=="") return true;
	input_string=InputText(input_string);
	while (input_string.indexOf(String.fromCharCode(245))!=-1) input_string=input_string.replace(String.fromCharCode(245), "ö");
	while (input_string.indexOf(String.fromCharCode(251))!=-1) input_string=input_string.replace(String.fromCharCode(251), "ü");
	while (input_string.indexOf(String.fromCharCode(213))!=-1) input_string=input_string.replace(String.fromCharCode(213), "Ö");
	while (input_string.indexOf(String.fromCharCode(219))!=-1) input_string=input_string.replace(String.fromCharCode(219), "Ü");
	regular_expression=/^[a-z0-9áéíóöúü -]{5,15}$/i;
	return (regular_expression.test(input_string));
}

function ValidPassword(input_string) {
	if (input_string=="") return true;
	temp=input_string;
	while (temp.indexOf("&#149;")!=-1) temp=temp.replace(/&#149;/, "");
	while (temp.indexOf(String.fromCharCode(149))!=-1) temp=temp.replace(String.fromCharCode(149), "");
	while (temp.indexOf(String.fromCharCode(8226))!=-1) temp=temp.replace(String.fromCharCode(8226), "");
	while (temp.indexOf("*")!=-1) temp=temp.replace(/\*/, "");
	if (temp=="") return true;
	input_string=InputText(input_string);
	while (input_string.indexOf(String.fromCharCode(245))!=-1) input_string=input_string.replace(String.fromCharCode(245), "ö");
	while (input_string.indexOf(String.fromCharCode(251))!=-1) input_string=input_string.replace(String.fromCharCode(251), "ü");
	while (input_string.indexOf(String.fromCharCode(213))!=-1) input_string=input_string.replace(String.fromCharCode(213), "Ö");
	while (input_string.indexOf(String.fromCharCode(219))!=-1) input_string=input_string.replace(String.fromCharCode(219), "Ü");
	regular_expression=/^[a-z0-9áéíóöúü-]{7,15}$/i;
	return (regular_expression.test(input_string));
}

function ValidEmail(input_string) {
	if (input_string=="") return true;

	if (input_string.indexOf("@")==-1) return false;
	if (input_string.indexOf("--")!=-1) return false;

	input_string=input_string.split("@");
	if (input_string[2]!=null) return false;

	regular_expression=/^[a-z0-9_\+\.\!\&\-]+$/i;
	if (!regular_expression.test(input_string[0])) return false;

	regular_expression=/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/;
	if (regular_expression.test(input_string[1])) return true;

	last_dot=input_string[1].lastIndexOf(".");
	domain=input_string[1].substring(0, last_dot);
	territory=input_string[1].substring(last_dot+1, input_string[1].length);

	domain=InputText(domain);
	while (domain.indexOf(String.fromCharCode(245))!=-1) domain=domain.replace(String.fromCharCode(245), "ö");
	while (domain.indexOf(String.fromCharCode(251))!=-1) domain=domain.replace(String.fromCharCode(251), "ü");
	while (domain.indexOf(String.fromCharCode(213))!=-1) domain=domain.replace(String.fromCharCode(213), "Ö");
	while (domain.indexOf(String.fromCharCode(219))!=-1) domain=domain.replace(String.fromCharCode(219), "Ü");
	regular_expression=/^[a-z0-9áéíóöúü][a-z0-9áéíóöúü_\.\-]*[a-z0-9áéíóöúü]$/i;
	if (!regular_expression.test(domain)) return false;

	regular_expression=/^[a-z]{2,4}$/i;
	if (!regular_expression.test(territory)) return false;

	return true;
}

function ValidZip(input_string) {
	if (input_string=="") return true;
	regular_expression=/^[a-z0-9-]{4,10}$/i;
	return (regular_expression.test(input_string));
}

function ValidNumber(input_string) {
	if (input_string=="") return true;
	while (input_string.indexOf(" ")!=-1) input_string=input_string.replace(/ /, "");
	while (input_string.indexOf(",")!=-1) input_string=input_string.replace(/\,/, "");
	while (input_string.indexOf(".")!=-1) input_string=input_string.replace(/\./, "");
	regular_expression=/^\d+$/;
	return (regular_expression.test(input_string));
}

function ValidDate(input_string) {
	year=Number(input_string.substring(0, 4));
	month=Number(input_string.substring(5, 7));
	day=Number(input_string.substring(8, 10));
	if (!year && !month && !day) {
		return true;
	} else if (!year || !month || !day) {
		return false;
	} else if (month>12 || day>31) {
		return false;
	} else {
		february_days = (year%4==0 && year%100!=0 || year%400==0) ? 29 : 28;
		if (month==2 && day>february_days)
			return false;
		else if ((month==4 || month==6 || month==9 || month==11) && day>30)
			return false;
	}
	return true;
}

function ValidDays(item) {
	ValidDaysRoot(item);
	ValidDaysRoot(item+"_from");
	ValidDaysRoot(item+"_to");
}

function ValidDaysRoot(item) {
	if (document.getElementById(item+"_month")) {
		g=document.getElementById(item+"_year");
		for (i=0; i<g.length; i++)
			if (g[i].selected)
				year=g.options[i].value;

		g=document.getElementById(item+"_month");
		for (i=0; i<g.length; i++)
			if (g[i].selected)
				month=g.options[i].value;
		date_delete=(g.options[0].value==0);

		g=document.getElementById(item+"_day");
		for (i=0; i<g.length; i++)
			if (g[i].selected)
				day=g.options[i].value;

		month_from = (date_limit && year==beginning_year) ? beginning_month : 1;
		month_to = (date_limit && year==now_year) ? now_month : 12;
		if (year==beginning_year && month<month_from) month=month_from;
		else if (year==now_year && month>month_to) month=month_to;

		if (month==2)
			days = (year && (year%4==0 && year%100!=0 || year%400==0)) ? 29 : 28;
		else if (month==4 || month==6 || month==9 || month==11)
			days=30;
		else
			days=31;

		day_from = (date_limit && year==beginning_year && month==beginning_month) ? beginning_day : 1;
		day_to = (date_limit && year==now_year && month==now_month) ? now_day : days;
		if (year==beginning_year && month==beginning_month && day<day_from) day=day_from;
		else if (year==now_year && month==now_month && day>day_to) day=day_to;

		if (day>days) day=days;

		if (!date_delete) {
			g=document.getElementById(item+"_month");
			g.length=month_to-month_from+1;
			for (i=0; i<=month_to-month_from; i++) {
				g.options[i].name=month_from+i;
				g.options[i].value=month_from+i;
				g.options[i].text=months[month_from+i];
				if (month_from+i==month) g[i].selected=true;
			}
			g=document.getElementById(item+"_day");
			g.length=day_to-day_from+1;
			for (i=0; i<=day_to-day_from; i++) {
				g.options[i].name=day_from+i;
				g.options[i].value=day_from+i;
				g.options[i].text=day_from+i;
				if (day_from+i==day) g[i].selected=true;
			}
		} else {
			g=document.getElementById(item+"_month");
			g.length=month_to-month_from+2;
			g.options[0].name=0;
			g.options[0].value=0;
			g.options[0].text=String.fromCharCode(8212);
			for (i=1; i<=month_to-month_from+1; i++) {
				g.options[i].name=month_from+i-1;
				g.options[i].value=month_from+i-1;
				g.options[i].text=months[month_from+i-1];
				if (month_from+i-1==month) g[i].selected=true;
			}
			g=document.getElementById(item+"_day");
			g.length=day_to-day_from+2;
			g.options[0].name=0;
			g.options[0].value=0;
			g.options[0].text=String.fromCharCode(8212);
			for (i=1; i<=day_to-day_from+1; i++) {
				g.options[i].name=day_from+i-1;
				g.options[i].value=day_from+i-1;
				g.options[i].text=day_from+i-1;
				if (day_from+i-1==day) g[i].selected=true;
			}
		}
	}
}

function DateNow(item) {
	DateNowRoot(item);
	DateNowRoot(item+"_from");
	DateNowRoot(item+"_to");
}

function DateNowRoot(item) {
	if (document.getElementById(item+"_month")) {
		g=document.getElementById(item+"_month");
		date_delete=(g.options[0].value==0);

		month_from = (date_limit && now_year==beginning_year) ? beginning_month : 1;
		month_to = (date_limit) ? now_month : 12;

		if (now_month==2)
			days = (now_year%4==0 && now_year%100!=0 || now_year%400==0) ? 29 : 28;
		else if (now_month==4 || now_month==6 || now_month==9 || now_month==11)
			days=30;
		else
			days=31;

		day_from = (date_limit && now_year==beginning_year && now_month==beginning_month) ? beginning_day : 1;
		day_to = (date_limit) ? now_day : days;

		g=document.getElementById(item+"_year");
		for (i=0; i<g.length; i++)
			if (g.options[i].value==now_year) g[i].selected=true;

		if (!date_delete) {
			g=document.getElementById(item+"_month");
			g.length=month_to-month_from+1;
			for (i=0; i<=month_to-month_from; i++) {
				g.options[i].name=month_from+i;
				g.options[i].value=month_from+i;
				g.options[i].text=months[month_from+i];
				if (month_from+i==now_month) g[i].selected=true;
			}
			g=document.getElementById(item+"_day");
			g.length=day_to-day_from+1;
			for (i=0; i<=day_to-day_from; i++) {
				g.options[i].name=day_from+i;
				g.options[i].value=day_from+i;
				g.options[i].text=day_from+i;
				if (day_from+i==now_day) g[i].selected=true;
			}
		} else {
			g=document.getElementById(item+"_month");
			g.length=month_to-month_from+2;
			g.options[0].name=0;
			g.options[0].value=0;
			g.options[0].text=String.fromCharCode(8212);
			for (i=1; i<=month_to-month_from+1; i++) {
				g.options[i].name=month_from+i-1;
				g.options[i].value=month_from+i-1;
				g.options[i].text=months[month_from+i-1];
				if (month_from+i-1==now_month) g[i].selected=true;
			}
			g=document.getElementById(item+"_day");
			g.length=day_to-day_from+2;
			g.options[0].name=0;
			g.options[0].value=0;
			g.options[0].text=String.fromCharCode(8212);
			for (i=1; i<=day_to-day_from+1; i++) {
				g.options[i].name=day_from+i-1;
				g.options[i].value=day_from+i-1;
				g.options[i].text=day_from+i-1;
				if (day_from+i-1==now_day) g[i].selected=true;
			}
		}

		if (document.getElementById(item+"_hour")) {
			g=document.getElementById(item+"_hour");
			for (i=0; i<g.length; i++)
				if (g.options[i].value==24)
					g[i].selected=true;
		}
		if (document.getElementById(item+"_minute")) {
			g=document.getElementById(item+"_minute");
			for (i=0; i<g.length; i++)
				if (g.options[i].value==60)
					g[i].selected=true;
		}
	}
}

function DateDelete(item) {
	DateDeleteRoot(item);
	DateDeleteRoot(item+"_from");
	DateDeleteRoot(item+"_to");
}

function DateDeleteRoot(item) {
	if (document.getElementById(item+"_year")) {
		g=document.getElementById(item+"_year");
		g[0].selected=true;
	}
	if (document.getElementById(item+"_month")) {
		g=document.getElementById(item+"_month");
		g[0].selected=true;
	}
	if (document.getElementById(item+"_day")) {
		g=document.getElementById(item+"_day");
		g[0].selected=true;
	}
	if (document.getElementById(item+"_hour")) {
		g=document.getElementById(item+"_hour");
		g[0].selected=true;
	}
	if (document.getElementById(item+"_minute")) {
		g=document.getElementById(item+"_minute");
		g[0].selected=true;
	}
}

function EMailLink(name, email_encoded, subject, style_class, status_text) {
	email=EMailDecode(email_encoded);
	name = (name && name!="-") ? name+" " : "";
	if (name) email="<"+email+">";
	subject = (subject && subject!="-") ? "?subject="+subject : "";
	style_class = (style_class && style_class!="-") ? " CLASS="+style_class : "";
	status_text = (status_text && status_text!="-") ? "'"+status_text+"'" : "";
	document.write("<A HREF=\"mailto:"+name+email+subject+"\" TARGET=_blank"+style_class+" onMouseOver=\"LinkActive("+status_text+"); return true;\" onMouseOut=\"LinkPassive(); return true;\">");
}

function EMailDecode(email_encoded) {
	alphabet = new Array("@", " ", ".", "!", "-", "_", "&#34;", "<", ">", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "á", "b", "c", "d", "e", "é", "f", "g", "h", "i", "í", "j", "k", "l", "m", "n", "o", "ó", "ö", "õ", "p", "q", "r", "s", "t", "u", "ú", "ü", "û", "v", "w", "x", "y", "z", "A", "Á", "B", "C", "D", "E", "É", "F", "G", "H", "I", "Í", "J", "K", "L", "M", "N", "O", "Ó", "Ö", "Õ", "P", "Q", "R", "S", "T", "U", "Ú", "Ü", "Û", "V", "W", "X", "Y", "Z");
	email_encoded=email_encoded.split("#");
	email="";
	for (i=0; i<email_encoded.length; i++) {
		j=email_encoded[i];
		email+=alphabet[j];
	}
	return email;
}

function IsEmptyField(input_string) {
	input_string=TrimString(input_string);
	if (input_string) {
		while (input_string.indexOf(" ")!=-1) input_string=input_string.replace(/ /, "");
		while (input_string.indexOf(" ")!=-1) input_string=input_string.replace(/ /, "");
		while (input_string.indexOf("-")!=-1) input_string=input_string.replace(/\-/, "");
		while (input_string.indexOf("–")!=-1) input_string=input_string.replace(/\–/, "");
		while (input_string.indexOf("—")!=-1) input_string=input_string.replace(/\—/, "");
		while (input_string.indexOf("&#149;")!=-1) input_string=input_string.replace(/&#149;/, "");
		while (input_string.indexOf("&#150;")!=-1) input_string=input_string.replace(/&#150;/, "");
		while (input_string.indexOf("&#151;")!=-1) input_string=input_string.replace(/&#151;/, "");
		while (input_string.indexOf("&#8226;")!=-1) input_string=input_string.replace(/&#8226;/, "");
		while (input_string.indexOf("&#8211;")!=-1) input_string=input_string.replace(/&#8211;/, "");
		while (input_string.indexOf("&#8212;")!=-1) input_string=input_string.replace(/&#8212;/, "");
		while (input_string.indexOf(String.fromCharCode(8226))!=-1) input_string=input_string.replace(String.fromCharCode(8226), "");
		while (input_string.indexOf(String.fromCharCode(8211))!=-1) input_string=input_string.replace(String.fromCharCode(8211), "");
		while (input_string.indexOf(String.fromCharCode(8212))!=-1) input_string=input_string.replace(String.fromCharCode(8212), "");
		while (input_string.indexOf(".")!=-1) input_string=input_string.replace(/\./, "");
		while (input_string.indexOf(",")!=-1) input_string=input_string.replace(/\,/, "");
		while (input_string.indexOf(";")!=-1) input_string=input_string.replace(/\;/, "");
		while (input_string.indexOf(":")!=-1) input_string=input_string.replace(/\:/, "");
		while (input_string.indexOf("?")!=-1) input_string=input_string.replace(/\?/, "");
		while (input_string.indexOf("\\")!=-1) input_string=input_string.replace(/\\/, "");
		while (input_string.indexOf("*")!=-1) input_string=input_string.replace(/\*/, "");
		while (input_string.indexOf("0")!=-1) input_string=input_string.replace(/0/, "");
		while (input_string.indexOf("|")!=-1) input_string=input_string.replace(/\|/, "");
	}
	return (!input_string.length);
}

var ajaxRequest=null;

function createXmlHttp() {
	var http_request=false;
	if (window.XMLHttpRequest) {
		http_request=new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType("text/html");
		}
	} else if (window.ActiveXObject) {
		try {
			http_request=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			}
		}
	}
	return http_request;
}

function URLEncode(url) {
	url=escape(url);
	while (url.indexOf("*")!=-1) url=url.replace(/\*/, "%2A");
	while (url.indexOf("+")!=-1) url=url.replace(/\+/, "%2B");
	while (url.indexOf("/")!=-1) url=url.replace(/\//, "%2F");
	while (url.indexOf("@")!=-1) url=url.replace(/@/, "%40");
	while (url.indexOf("%20")!=-1) url=url.replace(/%20/, "+");
	return url;
}

function PageWidth() {
	if (document.body && document.body.clientWidth)
		value=document.body.clientWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		value=document.documentElement.clientWidth;
	else if (window.innerWidth)
		value=window.innerWidth;
	else
		value=0;
	return value;
}

function PageHeight() {
	if (document.body && document.body.clientHeight)
		value=document.body.clientHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		value=document.documentElement.clientHeight;
	else if (window.innerHeight)
		value=window.innerHeight;
	else
		value=0;
	return value;
}

function PositionLeft() {
	if (document.body.scrollLeft && document.body.scrollLeft)
		value=document.body.scrollLeft;
	else if (document.documentElement && document.documentElement.scrollLeft)
		value=document.documentElement.scrollLeft;
	else if (window.pageXOffset)
		value=window.pageXOffset;
	else
		value=0;
	return value;
}

function PositionTop() {
	if (document.body.scrollTop && document.body.scrollTop)
		value=document.body.scrollTop;
	else if (document.documentElement && document.documentElement.scrollTop)
		value=document.documentElement.scrollTop;
	else if (window.pageYOffset)
		value=window.pageYOffset;
	else
		value=0;
	return value;
}

