nn4 = (document.layers) ? true : false;

ie4 = (document.all) ? true : false;

dom = (document.createTextNode)? true : false;


function popupWindow(fileUrl, winW, winH, winN, scrollB) {

	var winWidth = (winW)? winW : 740;
	
	var winHeight = (winH)? winH : 520;

	var winName = (winN)? winN : 'popupWin';
	
	winWidth = parseInt(winWidth) + 18;
	winHeight = parseInt(winHeight) + 27;
		
	var scrollBars = (scrollB)? scrollB : 'auto';

	if (nn4 || ie4 || dom) {

		if (screen.width < winWidth + 50) { winWidth = screen.width - 50; scrollbars = 'yes'; }

		if (screen.height < winHeight + 100) { winHeight = screen.height - 100; scrollbars = 'yes'; }

		posX = Math.round((screen.width - winWidth) / 2);

		posY = Math.round((screen.height - winHeight) / 2);

		posCode = (nn4)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;

	} else {

		posCode = "";

	}
	
	var popupWin = window.open(fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,resizable=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);

	if (popupWin) popupWin.focus();

}

function pngLoader()
{	
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent) && navigator.userAgent.search("Opera") < 0)
	{
		var ill = document.getElementById('homeIll').getElementsByTagName("div");
		for (var i = 0; i< ill.length; i++){
			ill[i].className += "_fix";
		}
		
	}
}

	function viewBlock(ptable, link){
		var obj = document.getElementById(ptable);
		obj.className = obj.className == 'none' ? 'visible' : 'none';
		if(link)
			link.className = link.className == 'cur' ? '' : 'cur';
	}

function MailSend(){		
	f = document.forms['car_order'];
	var check = true;
	
	var name = f.elements['name'];
	var email = f.elements['email'];
	var phone = f.elements['phone'];
	var text = f.elements['text'];
	
	if(name.value == ""){
		name.className = 'error';
		name.parentNode.parentNode.firstChild.style.color = '#c13000';
		check = false;
	}
	
	if(email.value == ""){
		email.className = 'error';
		email.parentNode.parentNode.firstChild.style.color = '#c13000';
		check = false;
	}
	
	if(phone.value == ""){
		phone.className = 'error';
		phone.parentNode.parentNode.firstChild.style.color = '#c13000';
		check = false;
	}
	
	if(text.value == ""){
		text.className = 'error';
		text.parentNode.parentNode.firstChild.style.color = '#c13000';
		check = false;
	}
	
	if(check){
		document.getElementById('carOrder').className = 'none';
		document.getElementById('orderSent').className = 'visible';
		//f.submit();
		}
	else
		return false;
}

function closePopUp(){
	var order_sent = document.getElementById('orderSent');
	if(order_sent.className == 'visible')
		order_sent.className = 'none';	
}

function input_focus(obj){
	
	if(obj.className == 'text')
		obj.className = 'textfocus';
		
	else if(obj.className == 'textfocus')
		obj.className = 'text';
		
	else if(obj.className == 'error'){
		obj.className = 'textfocus';
		obj.parentNode.parentNode.firstChild.style.color = '#333333';
		}
}

function viewCar(obj_id){
		var blockArr = document.getElementById('catalogueTable').getElementsByTagName("div");
		
		if(obj_id == 'full')
		{
			for (var i = 0; i< blockArr.length; i++){
				if(blockArr[i].id != '')
					blockArr[i].className = "visible";
			}
			document.getElementById('tableFull').className = 'cur';
			document.getElementById('tableHeader').className = '';
		}
		else if(obj_id == 'header')
		{
			for (var i = 0; i< blockArr.length; i++){
				if(blockArr[i].id != '')
					blockArr[i].className = "none";
			}
			document.getElementById('tableFull').className = '';
			document.getElementById('tableHeader').className = 'cur';
		}
		else{
			var block = document.getElementById("block" + obj_id);
			block.className = block.className == 'none' ? 'visible' : 'none';
			
			var none = 0;
			var vis = 0;
			document.getElementById('tableFull').className = 'cur';
			document.getElementById('tableHeader').className = 'cur';
			
			for (var i = 0; i< blockArr.length; i++){
				if(blockArr[i].className == "visible")
					vis = 1;
				else if(blockArr[i].className == "none")
					none = 1;	
			}
			
			if(vis)
				document.getElementById('tableHeader').className = '';
			if(none)
				document.getElementById('tableFull').className = '';
		}
	}

