var preview_code_tmp="";
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			//document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
			document.getElementById(changeImages.arguments[i]).src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		home_over = newImage("http://www.zimovka.ru/images/home-over.jpg");
		about__over = newImage("http://www.zimovka.ru/images/about--over.jpg");
		software_over = newImage("http://www.zimovka.ru/images/software-over.jpg");
		solutions_over = newImage("http://www.zimovka.ru/images/solutions-over.jpg");
		support_over = newImage("http://www.zimovka.ru/images/support-over.jpg");
		contacts_over = newImage("http://www.zimovka.ru/images/contacts-over.jpg");
		preloadFlag = true;
	}
}
function setTarif(tarif){
	document.getElementById("tarif").value=tarif;
	document.getElementById("tarif").focus();
}
function popImage(imageURL, ttl, width, height){
	if(!width) width=100;
	if(!height) height=100;
	if(!ttl) ttl="...";
        var opt='scrollbars=no,resizable=yes,width='+width+',height='+height+',left='+(window.screen.width-width)/2+',top='+(window.screen.height-height)/2+',status=yes';
        imgWin = window.open('','',opt);
        with (imgWin.document) {
                writeln('<html><head><title>'+ttl+'</title><style type="text/javascript">body {overflow: auto; margin: auto; margin:0; padding: 0;}</style>');
                writeln('<sc'+'ript type="text/javascript">');
                writeln('function resizePopup() {');
                writeln('width = document.images[0].width + 10; ');
                writeln('height = document.images[0].height + 50; ');
                writeln('window.resizeTo(width,height); ');
                writeln('if (window.innerWidth) { window.innerWidth = width - 10; window.innerHeight = height - 30; }');
                writeln('}');
                writeln('</s' + 'cript>');
		writeln('</head><body bgcolor="#FFFFFF" onload="resizePopup();">')
                writeln('<img src="'+imageURL+'" alt="закрыть" onclick="window.close();" border="0" style="position: absolute; left: 0px; top: 0px; cursor: pointer;"/></body></html>');
                close();
        }
}
function openPopup(url,w,h){
	win=open(url,
		"popup","toolbar=no,location=no,directories=no,"+
		"status=no,scrollbars=no,resizable=yes,"+
		"copyhistory=no,left="+(window.screen.width-w)/2+",top="+
		(window.screen.height-h)/2+",width="+w+",height="+h);
	win.focus();
}
function chooseTemplate(template_id, template_image){
	document.getElementById("unstandard_template_id").value=template_id;
	var preview_code="<a href=\"javascript:void(0);\" onclick=\"popImage('/preview_image.php?image="+template_image+"&width=600&height=600', 'Просмотр шаблона', 600, 600);\"><img src=\"/preview_image.php?image="+template_image+"&width=100&height=100\" width=\"100\" height=\"100\" alt=\"увеличить\" border=\"1\" style=\"border-color:#000000;\"/></a><br/>";
	preview_code_tmp=preview_code;
	setTimeout("document.getElementById(\"unstandard_template_preview\").innerHTML=preview_code_tmp;", 100);
	document.getElementById("template_unstandard").checked=true;
	//document.getElementById("unstandard_template_preview").innerHTML=preview_code;
}