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 viewBlock(ptable, link){
	var obj = document.getElementById(ptable);
	obj.className = obj.className == 'none' ? 'visible' : 'none';
	if(link)
		link.className = link.className == 'cur' ? '' : 'cur';
}
	
function showMenu(obj){
	var menublock = document.getElementById('productsList');
	
	if(obj.className == 'select'){
		menublock.className = 'none';
		obj.className = 'over';
	}
	else{
		var siteblock = document.getElementById('headerBg');
		menublock.className = 'visible';
		
		menublock.style.left = siteblock.offsetLeft + 220 + obj.offsetLeft;
		menublock.style.top =  100;
		
		obj.className = 'select';
	}
}

function closePreview(){
	preview_bg.className = 'none';
}

function openPreview(img, w, h){
	preview_bg.className = 'visible';
	preview_bg.style.height = document.getElementById('siteBlock').offsetHeight;
	image_preview.src = img;
	image_preview.width = w;
	image_preview.height = h;
	
	preview_block.style.left = (document.body.offsetWidth/2) - (preview_block.offsetWidth/2);
	preview_block.style.top =  (document.body.offsetHeight/2) + document.body.scrollTop - (preview_block.offsetHeight/2);
	document.onkeydown = escapePreview;
}

function fixPng(){
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent) && navigator.userAgent.search("Opera") < 0){
		preview_bg.id = 'imagePreviewBgFix';
		preview_bg = document.getElementById('imagePreviewBgFix');
	}
}

function escapePreview (event)
	{
		if (window.event) event = window.event;
		var code = event.keyCode ? event.keyCode : event.which ? event.which : null;
		if (code == 27)
		{
			preview_bg.className = 'none';
	
			document.onclick = null;
			document.onkeydown = null;
		}
	}


function MailSend(){		
	f = document.forms['support_form'];
	var check = true;
	
	var name = f.elements['name'];
	var email = f.elements['email'];
	var question = f.elements['question'];
	
	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(question.value == ""){
		question.className = 'error';
		question.parentNode.parentNode.firstChild.style.color = '#c13000';
		check = false;
	}
	
	if(check){
		document.getElementById('orderSent').className = 'visible';
		f.submit();
		}
	else
		return false;
		
}

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';
		}
}