function browseIt(){
    this.ver=navigator.appVersion;
    this.agent=navigator.userAgent;
    this.dom=document.getElementById?1:0;
    this.opera=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0;
	this.opera7 = (this.opera && parseInt(navigator.appVersion) >= 7);
    //this.ie=(this.ver.indexOf("MSIE")>-1 && this.dom && !this.opera)?1:0;
	this.ie = (this.navigator.userAgent.indexOf("MSIE") > -1) ? 1 : 0;
    this.macOS=this.agent.indexOf("Mac")>-1;
	this.mac=(this.macOS && parseInt(this.ver) >= 7) ?1:0;
    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.moz=(this.agent.indexOf("gecko")>-1)
    this.b=(this.ie || this.ns6 || this.opera7 || this.mac || this.moz || this.dom);
    return this;
}

var px = window.opera ? "" : "px";
var b = browseIt();

function makeObj(obj){
		this.elem= !b.dom?document.all[obj]:document.getElementById(obj);
	   	this.css= this.elem.style;
		return this;
}

var widthPrint = "100%";
var mlogoSrcPrint = "img/mlogop.gif";
var mlogoSrcScreen = "img/mlogo.gif";

function createObj(){
	oContent = new makeObj("dContent");
	oContainer = new makeObj("dContainer");
	oRightBg = new makeObj("dRightBg");
	iMlogo = new makeObj("mlogo");
}

if(b.ie) {
	window.attachEvent ("onbeforeprint", printOn);
	window.attachEvent ("onafterprint", printOff);
	function printOn() {createObj(); oContainer.css.width = widthPrint; iMlogo.elem.src = mlogoSrcPrint;}
	function printOff() {createObj(); oContainer.css.width = widthScreen; iMlogo.elem.src = mlogoSrcScreen;}
}

function CheckForm(form){
	mess = 'Вы не указали ';
	temp = form.elements["service[fio]"];
	if ( temp.value.length == 0 ) {
		alert(mess+'ФИО');
		temp.style.backgroundColor='#FFDFDF';
		temp.focus();
		return false;
	}
	temp = form.elements["service[phone]"];
	if ( temp.value.length == 0 ) {
		alert(mess+'номер телефона');
		temp.style.backgroundColor='#FFDFDF';
		temp.focus();
		return false;
	}
	temp = form.elements["service[email]"];
	if ( temp.value.length == 0 ) {
		alert(mess+'e-mail');
		temp.style.backgroundColor='#FFDFDF';
		temp.focus();
		return false;
	}
	temp = form.elements["service[model]"];
	if ( temp.value.length == 0 ) {
		alert(mess+'модель автомобиля');
		temp.style.backgroundColor='#FFDFDF';
		temp.focus();
		return false;
	}
	temp = form.elements["service[regnumber]"];
	if ( temp.value.length == 0 ) {
		alert(mess+'гос.номер автомобиля');
		temp.style.backgroundColor='#FFDFDF';
		temp.focus();
		return false;
	}
	temp = form.elements["service[reason]"];
	if ( temp.value.length == 0 ) {
		alert(mess+'причину записи');
		temp.style.backgroundColor='#FFDFDF';
		temp.focus();
		return false;
	}
	temp = form.elements["service[dat]"];
	if ( temp.value.length == 0 ) {
		alert(mess+'дату');
		temp.style.backgroundColor='#FFDFDF';
		temp.focus();
		return false;
	}
	temp = form.elements["service[tim]"];
	if ( temp.value.length == 0 ) {
		alert(mess+'время');
		temp.style.backgroundColor='#FFDFDF';
		temp.focus();
		return false;
	}
	return true;
}

var parentHeight;
//var imgB = new Image;
function show(src){
	imgB = new Image;
	imgB.src = src;
	parentHeight = document.getElementById('dContent').childNodes[0].offsetHeight;
	prev = document.getElementById('Preview');
	prev.style.backgroundImage = 'url(' + src + ')';
	prev.style.width = imgB.width + 'px';
	prev.style.height = imgB.height + 'px';
	prev.style.display = 'block';
	if(b.ie) prev.focus();
}
function clos(obj){
	obj.style.display = 'none';
	//document.getElementById('dContent').childNodes[0].style.height = parentHeight + 'px';
}

document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
};

function m(){
	c = 'autograd.';
	d = 'ua';
	mail = document.getElementsByClassName('m');
	tmp = new Array();
	mails = mail.length;
	for (i = 0; i < mails; i++ ) {
		tmp[i] = mail[i].innerHTML;
		mail[i].innerHTML = '<a h' + 're' + 'f="ma' + 'ilt' + 'o:' + tmp[i] + '@' + c + d +'">' + tmp[i] + '@' + c + d + '</a>';
	}
}

