function overCar(carPosition)
{
	$('carPos'+carPosition).addClassName('over'); 
}

function outCar(carPosition)
{
	if ($('carPos'+carPosition).hasClassName('over')) 
	{
		$('carPos'+carPosition).removeClassName('over'); 
	}
}

function showNewsletter()
{
	$('searchFilter').hide();
	$('newsletter').show();
}
function showFilter()
{
	$('searchFilter').show();
	$('newsletter').hide();
}

function onClickRow(itemId)
{
	var element = document.getElementById("selectedRowSection");
	if (element != null)
	{
		element.innerHTML = "<input type='hidden' name='selectedRowIndex' value='" + itemId + "'/>";
		document.getElementById("form1").submit();
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}
function showCity(id)
{
	var city = new getObj('mesto'+id);
	city.style.display='block';
}
function hideCity(id)
{
	var city = new getObj('mesto'+id);
	city.style.display='none';
}
function showTop(id)
{
	var thumb = new getObj('highlight'+id);
	thumb.style.opacity = 0;
	if (document.all)
	{
		thumb.obj.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0;
	}
	var cartype = new getObj('lnkCar'+id);
	cartype.style.backgroundPosition='0px -16px';
}
function hideTop(id)
{
	var thumb = new getObj('highlight'+id);
	thumb.style.opacity = 0.5;
	if (document.all)
	{
		thumb.obj.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 50;
	}
	var cartype = new getObj('lnkCar'+id);
	cartype.style.backgroundPosition='0px 2px';
}

function overFolder(index)
{
	var cnt = new getObj('cnt_'+index);
	var lc = new getObj('lc_'+index);
	var rc = new getObj('rc_'+index);
	cnt.style.backgroundPosition = '0px -25px';
	lc.style.backgroundPosition = '0px -25px';
	rc.style.backgroundPosition = '0px -25px';
}
function outFolder(index)
{
	var cnt = new getObj('cnt_'+index);
	var lc = new getObj('lc_'+index);
	var rc = new getObj('rc_'+index);
	cnt.style.backgroundPosition = '0px -50px';
	lc.style.backgroundPosition = '0px -50px';
	rc.style.backgroundPosition = '0px -50px';
}
function overOffer(element)
{
	element.style.backgroundImage = 'url(images/bg_offer_row.gif)';
}
function outOffer(element)
{
	element.style.backgroundImage = 'none';
}
function showPreview(image_src)
{
	var preview = new getObj('preview');
	preview.obj.src = image_src;
}

function clearValue(element,value)
{
	if (element.value == value) element.value =''
}
function setValue(element,value)
{
	if (element.value == '') element.value =value;
}

function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

