/* Damian Gajda 1999. Based on Eric Krock code.
   Permission granted to reuse and distribute.
*/

function checkIE(inputData){
if (inputData == '4'){
	var re = /.*(MSIE 4\.).*/;
}
if (inputData == '5'){
	var re = /.*(MSIE 5\.0).*/;
}
	re.exec(navigator.userAgent);
	var ver = RegExp.$1;
	if (ver == "") {
		return false;
	} else {
		return true;
	}
}

function browserVersion() {
	var agt = navigator.userAgent.toLowerCase();

	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);

	this.nav    = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)));
	this.nav4up = this.nav && (this.major >= 4);
	this.navonly = this.nav && (this.major < 5);

	this.gecko	= (agt.indexOf("gecko") != -1);

	this.ie     = (agt.indexOf("msie") != -1);
	this.ie4	= this.ie && (checkIE('4') == true);
	this.ie4and5= this.ie && (checkIE('4') == true || checkIE('5') == true);
	this.ie4up  = this.ie  && (this.major >= 4);

	this.opera = (agt.indexOf("opera") != -1);

	this.ver4up = (this.ie4up || this.nav4up );
	
	this.sys_x11 = (agt.indexOf("x11") != -1);
	}

var browser = new browserVersion();
var bv = browser;
// ----------------------------------------------------------------
//    Copyright e-point.S.A.
// ----------------------------------------------------------------

var windows = {};
var UNDEF = top._undefined_;

function openPopUp(url, name, width, height) {
	var top  = (screen.height-height-40)/2;
	var left = (screen.width-width-10)/2;
	if(!windows[name] || windows[name].closed) {
		windows[name] = window.open ("", name, 'top='+top+',left='+left+',toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height);
	}
	windows[name].document.location.href = url;
	windows[name].focus();
}
// ----------------------------------------------------------------
//    Copyright e-point.S.A.
// ----------------------------------------------------------------

function validator() {
	this.is_email = function (value) {
		return /^[\w\-]+(\.[\w\-]+)*@[\w\-]+(\.[\w\-]+)*(\.[a-zA-Z]{2,4})$/.test(value);
	}
	this.is_zipcode = function (value) {
		return /^\d{2}-\d{3}$/.test(value);
	}
	this.is_notempty = function (value) {
		if ( (new string()).trim(value).length != 0 ) return true;
		return false;
	}
	this.is_empty = function (value) {
		if ( value.length == 0 ) return true;
		return false;
	}
	this.is_number = function (value) {
		return /^[0-9]+((,|\.)[0-9]+)?$/.test(value);
	}
	this.is_numberPL = function (value) {
		return /^[0-9]+(,[0-9]+)?$/.test(value);
	}
	this.is_numberEN = function (value) {
		return /^[0-9]+(\.[0-9]+)?$/.test(value);
	}
	this.is_price = function (value) {
		return /^[0-9]+(,[0-9]{1,2})?$/.test(value);
	}
	this.is_checked = function (field) {
		var l = field.length; 
		var oneChosen = false;

		for (i = 0; i<l; i++) { if (field[i].checked) { oneChosen = true; } }
		return oneChosen;
	}
}

var v = new validator();function flashInitializer(flashUrl, flashWidth, flashHeight, flashBackground, sschema, node)
{
	f = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+ sschema +'://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+flashWidth+'" height="'+flashHeight+'">'
	+ '<param name=movie value="'+flashUrl+'">'
	+ '<param name=quality value=high>'
	+ '<param name=wmode value="transparent">'
	+ '<param name=bgcolor value="'+flashBackground+'">'
	+ '<embed src="'+flashUrl+'" wmode="transparent" quality="high" bgcolor="'+flashBackground+'" width="'+flashWidth+'" height="'+flashHeight+'" type="application/x-shockwave-flash" pluginspage="'+sschema+'s://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>'
	+ '</object>';
	if (typeof node == 'undefined') {
		document.write(f);
	} else {
		node.innerHTML = f;
	}
}var http_request = false;
function ajax(url, postData) {
	if (window.XMLHttpRequest) { // Mozilla, Safari, Opera ...
    	http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
        	http_request.overrideMimeType('text/xml');
        }
	} else if (window.ActiveXObject) { // IE
    	http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (!http_request) {
        return false;
    } else {
	}
	http_request.onreadystatechange = resultEncoding;
    http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    http_request.send(postData);
}

function resultEncoding() {
	if (http_request.readyState == 4) {
    	if (http_request.status == 200) {
        	document.getElementById('ajaxResult').innerHTML = http_request.responseText;
        }
   	}
}

function printFAQs(url, name, width, height, expandFAQs) {
	url = url+"&expandFAQs="+expandFAQs.join(",");
	openPopUp(url,name,width,height);
}
