function start() {
	//start
	
	if(jskomShow&&$('komunikat')) {
		jskomAppear();
		$('komunikat').observe('click',jskomFadeOut);
	}
}
window.onload = start;

var aktCount=0;
var katCount=0;
function aktPlus() {
	aktCount++;
}
function katPlus() {
	katCount++;
}

var aktLeftPos=1;
var katLeftPos=1;
var aktLeft=0;
var katLeft=0;
function aktRight() {
	aktLeftPos+=1;
	aktLeft-=170;
	$('akt').setStyle({ left:aktLeft+'px' });	
	if (aktLeftPos+1>=aktCount) {
		$('akt_but').hide();
		$('akt_but_back').show();		
	}
}
function katRight() {
	katLeftPos+=1;
	katLeft-=85;
	$('kat').setStyle({ left:katLeft+'px' });	
	if (katLeftPos+3>=katCount) {
		$('kat_but').hide();	
		$('kat_but_back').show();		
	}
}
function aktBack() {
	aktLeftPos=0;
	aktLeft=0;
	$('akt').setStyle({ left:aktLeft+'px' });	
	$('akt_but').show();
	$('akt_but_back').hide();		
}
function katBack() {
	katLeftPos=1;
	katLeft=0;
	$('kat').setStyle({ left:katLeft+'px' });	
	$('kat_but').show();
	$('kat_but_back').hide();		
}

function setText(oTextInput) {
	if(oTextInput.value=='') oTextInput.value = oTextInput.defaultValue;
}
function clearText(oTextInput) {
	if(oTextInput.value==oTextInput.defaultValue) oTextInput.value = '';
}

function isEmail(address) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return(reg.test(address));
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function selectedRadioValue(oForm, sRadioName) {
	var retval = '';
	for(var i=0;i<oForm.elements.length;i++) {
		if(oForm.elements[i].type!='radio'||oForm.elements[i].name!=sRadioName) continue;
		if(oForm.elements[i].checked) retval = oForm.elements[i].value;
	}
	return retval;
}

function showKom(kom,kom_status) {
	if(kom_status=='error') {
		$('komunikat').setStyle({backgroundColor:'#E1E6FA', border: '5px solid #183152', color:'#183152'});
		$('kom_img').src = 'images/ico_kom_error.png';
	}
	else if(kom_status=='info') {
		$('komunikat').setStyle({backgroundColor:'#E1E6FA', border: '5px solid #183152', color:'#183152'});
		$('kom_img').src = 'images/ico_kom_info.png';
	}
	else {
		$('komunikat').setStyle({backgroundColor:'#E1E6FA', border: '5px solid #183152', color:'#183152'});
		$('kom_img').src = 'images/ico_kom_ok.png';
	}
	$('kom_text').update(kom);
	jskomAppear();
}
var jskomShow=false;
var jskomZostaw=true;
var peJskom;
function jskomAppear() {
	try{
		//Effect.Appear('jskom');
		$('komunikat').show();
	}
	catch (exc) {
		$('komunikat').show();
	}
	if(!jskomZostaw) peJskom = new PeriodicalExecuter(function(peJskom) {
			jskomFadeOut();
		}, 4);
}
function jskomFadeOut() {
	try{
		Effect.Fade('komunikat');
		}
	catch (exc) {
		$('komunikat').hide();
	}
	//$('komunikat').update('');
	if(peJskom) peJskom.stop();
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function basename (path, suffix) {
    var b = path.replace(/^.*[\/\\]/g, '');
    
    if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
        b = b.substr(0, b.length-suffix.length);
    }
    
    return b;
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
function viewportDims() {
	var viewportwidth;
	var viewportheight;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
	}
 	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined'&& typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0) {
		viewportwidth = document.documentElement.clientWidth,
		viewportheight = document.documentElement.clientHeight
	}
	// older versions of IE
	else {
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	return {width:viewportwidth,height:viewportheight};
}

function postToURL(url, values)
{
    values = values || {};

    var form = new Element("form", {action: url,
                                      method: "POST",
                                      style: "display: none"});
    for (var property in values)
    {
        if (values.hasOwnProperty(property))
        {
            var value = values[property];
            if (value instanceof Array)
            {
                for (var i = 0, l = value.length; i < l; i++)
                {
                    form.insert(new Element("input", {type: "hidden",
                                                             name: property,
                                                             value: value[i]}));
                }
            }
            else
            {
                form.insert(new Element("input", {type: "hidden",
                                                         name: property,
                                                         value: value}));
            }
        }
    }
    document.body.insert(form);
    form.submit();
    form.remove();
	return false;
}

