if (navigator.appName.indexOf("Microsoft Internet Explorer")==-1) {
	HTMLElement.prototype.contains = function(oElement){
		if (oElement == this) 
			return true;
		if (oElement == null) 
			return false;
		return this.contains(oElement.parentNode);
	};
}
var isVisible=false;
function CarRangeShowDetails(div, show, counter, top, step){
	var details = document.getElementById(div);	
		
		if (show == true) {
		isVisible=true;
		if (navigator.appName == "Microsoft Internet Explorer") {
			if (counter == 0) {
				details.style.filter = "alpha(opacity=0)";
			}
			details.style.display = "block";
			counter += step;
			if (counter < top) {
				details.style.filter = "alpha(opacity=" + counter + ")";
				setTimeout("CarRangeShowDetails('" + div + "'," + show + "," + counter + "," + top + "," + step + ")", 1);
			}
			else {
				details.style.filter = "alpha(opacity=" + top + ")";
			}
		}
		else {
			if (counter == 0) {
				details.style.opacity = "0.0";
			}
			details.style.display = "block";
			counter += step;
			if (counter < top) {
				if (counter < 10) 
					details.style.opacity = "0.0" + counter;
				else 
				details.style.opacity = "0." + counter;
				setTimeout("CarRangeShowDetails('" + div + "'," + show + "," + counter + "," + top + "," + step + ")", 1);
			}
			else {
				if (top == 100) {
					details.style.opacity = "1.0";
				}
				else {
					details.style.opacity = "0." + top;
				}
			}
		}
	}
	else {
	isVisible=false;
		if (navigator.appName == "Microsoft Internet Explorer") {
			details.style.filter = "alpha(opacity=" + top + ")";
			counter -= step;
			if (counter > step) {
				details.style.filter = "alpha(opacity=" + counter + ")";
				setTimeout("CarRangeShowDetails('" + div + "'," + show + "," + counter + "," + top + "," + step + ")", 1);
			}
			else {
				details.style.filter = "alpha(opacity=0)";
				details.style.display = "none";
			}
		}
		else {
			if (top == 100) 
				details.style.opacity = "1.0";
			else 
				details.style.opacity = "0." + top;
				counter -= step;
			if (counter > step) {
				if (counter < 10) 
					details.style.opacity = "0.0" + counter;
				else 
					details.style.opacity = "0." + counter;
					setTimeout("CarRangeShowDetails('" + div + "'," + show + "," + counter + "," + top + "," + step + ")", 1);
			}
			else {
				details.style.opacity = "0.0";
				details.style.display = "none";
			}
		}
	}
}



var roolin=null;
var roolout=null;
var roolout2=null;
var prevElement=null;
function CarRangeShowHideDetailsPopup(evt, id, visibility) {
 
		      window.clearInterval(roolin);
		      window.clearInterval(roolout);
		      
		      
		     var startValue=100;
		     if(visibility==true) {startValue=0 } 
		     if(visibility==false) {startValue=100 }
		     
		    // var lista = document.getElementById("eventlista");
		     
		     if(id!=prevElement && prevElement!=null) {
		         window.setTimeout("CarRangeShowDetails('" + prevElement + "'," + false + "," + startValue + "," + 100 + "," + 11 + ")", 0);
		         visibility=true;
		         isVisible=false;
		     }
		     
		     if(isVisible==false && visibility==true) {
		            //lista.options[lista.length] = new Option('2' + id, 'yourValue');
			        roolin=window.setTimeout("CarRangeShowDetails('" + id + "'," + true + "," + startValue + "," + 100 + "," + 10  + ")", 600); 
			  }
			  
			  if(isVisible==true && visibility==false) {
			        roolout=window.setTimeout("CarRangeShowDetails('" + id + "'," + false + "," + startValue + "," + 100 + "," + 11 + ")", 0);
			        //lista.options[lista.length] = new Option('3' + id, 'yourValue');
			  }
			  prevElement=id;
}


function showHideCarElement(elem, container) {


	viewsCont = document.getElementById(container);
	viewsList = viewsCont.getElementsByTagName('div');
	for(a=0; a<viewsList.length; a++)
	{
		if(viewsList[a].className=='CarElementView')
		{
			viewsList[a].style.display = "none";
		}
	}
 var CarElementView = document.getElementById(elem);
 CarElementView.style.display = 'block';
 
}

function changeCarElementsSet(nr) {

		middleContentEl = document.getElementById('MiddleContent');
		divList = middleContentEl.getElementsByTagName('div');
		for (a = 0; a < divList.length; a++) {
			if (divList[a].className == 'CarElements') {
				divList[a].style.display = "none";
			}
		}
	
		block = document.getElementById("CarElements" + nr);
		block.style.display = "block";
		
	var carElementsDescription = document.getElementById('CarElementsDescriptions').childNodes;
	for(var i=0; i<carElementsDescription.length; i++) {
		if(carElementsDescription[i].className == 'CarElementsDescription') {
			carElementsDescription[i].style.display = 'none';
		}
	}
	document.getElementById('CarElementsDescription_'+nr).style.display = 'block';

		
	var CarElementsList = document.getElementById('CarElementsList').childNodes;
	for(var i=0; i<CarElementsList.length; i++) {
		if(CarElementsList[i].nodeName.toUpperCase() == 'LI') {
			CarElementsList[i].className = '';
		}
	}
	document.getElementById("CarElementsListItem_"+nr).className = 'CarElementsListCurrent';

}

function changePhotoGalleryImage(elem) {
	var thumbsList = elem.parentNode.parentNode.childNodes;
	var itemIndex;
	var listIndex = 0;
	for(var i =0; i<thumbsList.length; i++) {
		if (thumbsList[i].nodeName.toUpperCase() == "LI") {
			listIndex++;
			if (thumbsList[i] == elem.parentNode) {
				itemIndex = listIndex;
			}
		}
	}
	
	var galleryScreen = document.getElementById('PhotoGalleryScreen').childNodes;
	var galleryItem = 0;
	for(var i=0; i<galleryScreen.length; i++) {
		if(galleryScreen[i].nodeName.toUpperCase() == "IMG") {
			galleryItem++;
			if(galleryItem == itemIndex) {
				galleryScreen[i].className = '';
			} else {
				galleryScreen[i].className = 'hidden';
			}
		}
	}
}


function changeColorInCarColorsPage(elem) {
	var mediumId = elem.id.replace(/small/gi, 'medium');
	var mediumDescriptionId = elem.id.replace(/small/gi, 'mediumDescription');
	var bigId = elem.id.replace(/small/gi, 'big');
	
	var mediumObj = document.getElementById(mediumId);
	var mediumDescriptionObj = document.getElementById(mediumDescriptionId);
	var bigObj = document.getElementById(bigId);
	
	
	//remove red frame from 'small' image
	var colorSelectorSamplesDiv = elem.parentNode.parentNode.parentNode;
	for(var i = 0; i < colorSelectorSamplesDiv.childNodes.length; i++){ //for each group
    if(colorSelectorSamplesDiv.childNodes[i].nodeName.toUpperCase() == 'UL'){ //if this is list with images for group
    	for(var j = 0; j < colorSelectorSamplesDiv.childNodes[i].childNodes.length; j++){ //for each image in processed group
        colorSelectorSamplesDiv.childNodes[i].childNodes[j].className = '';
    	}
    }
  }//END: for(var i = 0; i < colorSelectorSamplesDiv.childNodes.length; i++){
	
	//show red frame to 'elem'
	elem.parentNode.className = 'ColorSelectorSelectedSample';
	
	
	
	//remove 'medium' img
	for(var i = 0; i < mediumObj.parentNode.childNodes.length; i++){
    if((mediumObj.parentNode.childNodes[i].nodeName.toUpperCase() == 'IMG') || (mediumObj.parentNode.childNodes[i].nodeName.toUpperCase() == 'P')){
      mediumObj.parentNode.childNodes[i].style.display = 'none';
    }
	}
	
	//show 'medium' img
	mediumObj.style.display = 'inline';
	mediumDescriptionObj.style.display = 'inline';
	
	
	
	//remove 'big' img
	for(var i = 0; i < bigObj.parentNode.childNodes.length; i++){
    if(bigObj.parentNode.childNodes[i].nodeName.toUpperCase() == 'IMG'){
      bigObj.parentNode.childNodes[i].style.display = 'none';
    }
	}
	
	//show 'big' img
	bigObj.style.display = 'block';
	
	
	
}


function checkParrentElement(evt) {
 if (evt.target)
  {
    targ=evt.target;
  }
else if (evt.srcElement)
  {
    targ=evt.srcElement;
  }
if (targ.nodeType==3) // defeat Safari bug
  {
    targ = targ.parentNode;
  }
var tname;
tname=targ.tagName;
//tname=targ.id;
return tname;
}


function drawFrameOnScene(selectedElement, switcherContainer, block, blockContainer) {

switchCont = document.getElementById(switcherContainer);
//delete all border from switcher
imgList = switchCont.getElementsByTagName('img');
	for (i=0;i<imgList.length;i++) 
	{ 
		imgList[i].setAttribute((document.all ? 'className' : 'class'),'sceneUnSelected');
	}
	//add border to clicked switch
	selectedElement.setAttribute((document.all ? 'className' : 'class'),'sceneSelected');
	
	blockCont = document.getElementById(blockContainer);
	blockList = blockCont.getElementsByTagName('div');
	for(a=0; a<blockList.length; a++)
	{
		if(blockList[a].className=='CarElementsSet')
		{
			blockList[a].style.display = "none";
		}
	}
	bl = document.getElementById(block);
	
	bl.style.display = "block";
}



