function FlashTag(src, uid, param, wmode, width, height)
{
    this.src       = src;
    this.uid       = uid;
    this.param     = param;
    this.width     = width;
    this.height    = height;
    this.version   = '7,0,14,0';
    this.id        = null;
    this.bgcolor   = 'ffffff';
    this.wmode     = wmode;
    this.flashVars = null;
}

FlashTag.prototype.setVersion = function(v)
{
    this.version = v;
}

FlashTag.prototype.setId = function(id)
{
    this.id = id;
}


FlashTag.prototype.setFlashvars = function(fv)
{
    this.flashVars = fv;
}

FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
    if (ie)
    {
        flashTag += '<object id="' + this.uid + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        flashTag += '<param name="quality" value="high"/>';
		flashTag += '<param name="wmode" value="'+this.wmode+'"/>';
        flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>';
        //flashTag += '<param name="allowScriptAccess" value="sameDomain"/>';
        if (this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="'+this.flashVars+'&'+this.param+'"/>';
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed id="' + this.uid + '" src="'+this.src+'" ';
        flashTag += 'quality="high" '; 
        flashTag += 'bgcolor="#'+this.bgcolor+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'" ';
		flashTag += 'wmode="'+this.wmode+'" ';
	//	flashTag += 'allowScriptAccess="sameDomain" ';
        flashTag += 'type="application/x-shockwave-flash" ';
        if (this.flashVars != null)
        {
            flashTag += 'flashvars="'+this.flashVars+'&'+this.param+'" ';
        }
        if (this.id != null)
        {
            flashTag += 'name="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
	op_n=1;

    return flashTag;
}

FlashTag.prototype.fetch = function()
{
    return this.toString();
}

function o(id)
{
	return document.getElementById(id);
}

function validateEmail(email){
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(email.match(emailRegEx)){
		return true;
	}else{
		return false;
	}
}

function sendKontakt() {
	var imie = o('imie').value;
	var email = o('email').value;
	var telefon = o('telefon').value;
	var pytanie = o('pytanie').value;
	
	if(imie=='')
	{
		o('errMsg').innerHTML = "proszę podać imię i nazwisko";
		o('errMsg').style.display = "block";
		o('imie').focus();
		return;
	}
	
	if(validateEmail(o('email').value)==false)
	{
		o('errMsg').innerHTML = "proszę podać prawidłowy adres e-mail";
		o('errMsg').style.display = "block";		
		o('email').focus();
		return;
	}
	
	if(telefon=='')
	{
		o('errMsg').innerHTML = "proszę podać numer telefonu";
		o('errMsg').style.display = "block";		
		o('telefon').focus();
		return;
	}
	
	if(pytanie=='')
	{
		o('errMsg').innerHTML = "proszę wpisać pytanie";
		o('errMsg').style.display = "block";		
		o('pytanie').focus();
		return;
	}
//	o('imie').value = '';
//	o('email').value = '';
//	o('telefon').value = '';
//	o('pytanie').value = '';
	o('errMsg').style.display = "none";	
	o('wyslane').style.display = "block";
	setTimeout(function(){o('wyslane').style.display="none";},10000);
	xajax_sendKontaktForm(imie, email, telefon, pytanie);
}

function init()
{
	try {  Shadowbox.init(); } catch(e) { }
	try {  o('left').style.display = "block"; } catch(e) { }
	try {  o('leftNone').style.display = "block"; } catch(e) { }
	
	try {  o('baner').innerHTML = baner.fetch(); } catch(e) { }
	try {  o('motto').innerHTML = motto.fetch(); } catch(e) { }
	
	try {
		if (GBrowserIsCompatible()) {
	        var map = new GMap2(o("map"));
	        map.setCenter(new GLatLng(49.784511,22.788069), 15);
	        map.setMapType(G_NORMAL_MAP);
			map.addControl(new GSmallMapControl());
			var point = new GLatLng(49.782411,22.788069);
	    	map.addOverlay(new GMarker(point));
			map.openInfoWindowHtml(point,"<b>Klinika okulistyczna<Br>dr Jan Witkiewicz</b><br><Br>ul. Mickiewicza 38<br>37-700 Przemyśl<Br>16 676-80-40, 16 678 50 76"); // tekst do dymku
	      }
	}catch(e) { };
	
}

(window.attachEvent)?attachEvent('onload', init) : addEventListener('load', init, false);
