// JavaScript Document
var timeoutVar1;
var NewsFlashCount = 0;
var CurrentNewsFlash = 1;
var NewsFlashTimer;
function loopNewsFlash(inNR){
	if(NewsFlashCount>0){
		if(isDefined(inNR)==true){
			clearTimeout(NewsFlashTimer);
			document.getElementById('playButton').src = 'images/icons/Pause.gif';
			document.getElementById('NewsFlash_' + (CurrentNewsFlash)).style.display = 'none';
			CurrentNewsFlash=inNR;
			if(CurrentNewsFlash>NewsFlashCount){CurrentNewsFlash = 1}
			if(CurrentNewsFlash<1){CurrentNewsFlash = NewsFlashCount}
			document.getElementById('NewsFlash_' + (CurrentNewsFlash)).style.display = 'block';
			document.getElementById('NewsFlashTop').innerHTML = CurrentNewsFlash + ' útav ' + NewsFlashCount;
		}else{
			CurrentNewsFlash++;
			document.getElementById('NewsFlash_' + (CurrentNewsFlash-1)).style.display = 'none';
			if(CurrentNewsFlash>NewsFlashCount){CurrentNewsFlash = 1}
			document.getElementById('NewsFlash_' + (CurrentNewsFlash)).style.display = 'block';
			NewsFlashTimer = setTimeout('loopNewsFlash()',5000);
			document.getElementById('playButton').src = 'images/icons/Play.gif';
			document.getElementById('NewsFlashTop').innerHTML = CurrentNewsFlash + ' útav ' + NewsFlashCount;
		}
		
		
	}
}



function alertMe(isOK, text){
	var alerter = document.getElementById('alerter');
	var alerterText = document.getElementById('alerterText');
	if(isOK){alerter.className = 'okBox16';}
	else{alerter.className = 'errBox16';}
	alerterText.innerHTML = text;
	alertGrow(0,14);
}
function alertShrink(currentHeight){
	var alerter = document.getElementById('alerter');
	var alerterText = document.getElementById('alerterText');
	currentHeight = currentHeight - 3;
	if(currentHeight<0){currentHeight=0};
	alerter.style.height = parseInt(currentHeight) + 'px';
	if(currentHeight <= 1){
		alerterText.innerHTML = '';
		alerter.className = '';
	}else{
		timeoutVar1 = setTimeout('alertShrink(' + currentHeight + ')',50)	
	}
}
function alertGrow(currentHeight, endHeight){
	var alerter = document.getElementById('alerter');
	currentHeight = currentHeight + 3;
	alerter.style.height = currentHeight + 'px';
	if(currentHeight >= endHeight){
		timeoutVar1 = setTimeout('alertShrink(' + currentHeight + ')',3000)	
	}else{
		timeoutVar1 = setTimeout('alertGrow(' + currentHeight + ',' + endHeight + ')',50)
	}
}

function checkEnter(e){

	var characterCode;

	if(e && e.which)
		{e = e
		characterCode = e.which}
	else
		{e = event
		characterCode = e.keyCode}

	if(characterCode == 13)
		{return true;}
	else
		{return false;}
}

function Mid(str, start, len)
{
		if (start < 0 || len < 0) return "";

		var iEnd, iLen = String(str).length;
		if (start + len > iLen)
				iEnd = iLen;
		else
				iEnd = start + len;

		return String(str).substring(start,iEnd);
}
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function isDefined(variable)
{
return (!(!( variable||false )))
}

function goTabs(theCaller){
	var temp = getElementsByClass('tab2');
	for (x in temp){
		temp[x].className = 'tab1';
	}
	theCaller.className = 'tab2';
}

function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function doArray(theString,inValue,action){
	if(isNull(theString)==true||theString==''){theString='0'}
	var temp = theString
	temp.split(',')
	var exists = inList(theString,inValue)
	if(action==true && exists==false){
		theString += ',' + inValue
	}else if(exists==true){
		theString = theString.replace(',' + inValue,'')
	}
	//alert(inValue + ',' + exists + '\n' + theString);
	return theString;
}
function inList(str,inValue){
	var temp = str;
	var exists = false;
	temp = temp.split(',')
	for (x in temp){
		if(temp[x]==inValue){
			exists = true;
		}
	}
	return exists;
}

function doSearch(postData,varName,currValue,Value,specialUser){
	postData = postData.replace(varName + '=' + currValue,varName + '=' + Value);
	ajaxGet('modules/car/a_filter.asp?specialUser=' + specialUser,'filters',false,postData);
	//ajaxGet('modules/car/a_search.asp','content',false,postData);
}

function isNull(val){return(val==null);}

function validateEmail(str){
	//var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var emailReg = ".+@.+\\.[a-z]+";
	var regex = new RegExp(emailReg);
	return regex.test(str);
}


var min=8;
var max=18;
function increaseFontSize() {
   //document.body.style.fontSize = '12px';
}
function decreaseFontSize() {
   //document.body.style.fontSize = '10px';
}

