var br = "<?=$wb?>";
var brDOM = document.getElementById;
var upb = new Array();
//var upbrand = '';
//var newrate = 0;

if (brDOM && (document.all && document.all.item && !(window.opera && brDOM))) br = "IE5";
else if (brDOM && navigator.appName == "Netscape") br = "MZL";
else if ((window.opera && brDOM) && document.readyState) br = "OP7";
else if ((window.opera && brDOM) && window.print) br = "OP6";
else if (window.opera && brDOM) br = "OP5";
else if (document.all && document.all.item && !(window.opera && brDOM)) br = "IE4";
else if (document.layers) br = "NN4";
else br = "UND";
//
function OpenNewWindow(loc, width, height, scroll) {
            if (document.getElementById)
        		var xMax = screen.width, yMax = screen.height;
    		else
        		if (document.layers)
            	var xMax = window.outerWidth, yMax = window.outerHeight;
        		else
            	var xMax = 640, yMax=480;

    		var xOffset = (xMax - width)/2, yOffset = (yMax - height)/2;
            nw = window.open(loc, "INFO",'width='+width+',height='+height+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',status=yes,toolbar=no,scrollbars='+scroll+',menubar=no,location=no');
            nw.focus();
}
function Buy(id) {
            if (document.getElementById) var xMax = screen.width, yMax = screen.height;
    		else {
        		if (document.layers) var xMax = window.outerWidth, yMax = window.outerHeight;
        		else var xMax = 640, yMax=480;
            }
            var loc = 'newwin/order.htm?id='+id;
    		var xOffset = (xMax - 500)/2, yOffset = (yMax - 480)/2;
            nw = window.open(loc, "INFO",'width=500,height=480,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no');
            nw.focus();
}
//

var repeat = "FALSE";

//new parameter added
function RemoteScriptV(select) {
    var btn = document.getElementById('submit');
	if (select.value == ' ') {btn.disabled=true; btn.style.color='#808080'; btn.style.backgroundColor='#D4D0C8'; btn.style.cursor='default'; return;}
    else if (document.getElementById('brand')) EnableSubmitV(document.getElementById('brand'));
    else not = 0;
	var href = 'if/remote-v.htm';
	var w = document.getElementById('watch');
    w.style.visibility = 'visible';
	var temp = document.getElementById('temp');
    if (temp) document.lastChild.lastChild.removeChild(temp);
	var span = null;
    var n = document.createElement('SPAN');
    span = document.lastChild.lastChild.appendChild(n);
	span.setAttribute('id', 'temp');
	span.style.display = 'none';
	span.innerHTML = '.<s'+'cript></' + 'script>';
	setTimeout(function() {
    	var s = span.getElementsByTagName("script")[0];
		s.language = "JavaScript";
        if (select.id == 'auto') {
        	href += '?auto='+select.value;
            document.getElementById('body').disabled=true;
            if (repeat=="TRUE") {
            	if (document.getElementById('brand')) {
                	document.getElementById('podbor').innerHTML='';
	                var brand = document.getElementById('brand');
	                brand.disabled=true;
                    if (window.opera && document.getElementById) {
                    brand.setAttribute('class', 'opera');
                    }
                    else if (br == "MZL") {
                    brand.style.cssText='background: #D4D0C8;';
                    }
                    else {
                    brand.style.cssText='background: #fff; color: #808080;';
                    }
                    if (brand.selectedIndex != 0) {
                    brand[0].selected = true;
                    }
	            }
                if (document.getElementById('r')) {
                    document.getElementById('podbor').innerHTML='';
                    var radius = document.getElementById('r');
                    radius.disabled=true;
                    if (window.opera && document.getElementById) {
                    radius.setAttribute('class', 'opera');
                    }
                    else if (br == "MZL") {
                    radius.style.cssText='background: #D4D0C8;';
                    }
                    else {
                    radius.style.cssText='background: #fff; color: #808080;';
                    }
                    if (radius.selectedIndex != 0) {
                    radius[0].selected = true;
                    }
                }
            btn.style.color='#808080';
            btn.style.backgroundColor='#D4D0C8';
            btn.style.cursor='default';
            btn.disabled=true;
            if (window.opera && document.getElementById) {
            	if (document.getElementById('podbor')) document.getElementById('buttonz').innerHTML='<input id="submit" type="button" disabled="disabled" name="submit" value="Подобрать диск" onmouseup="GetResultV(this)">';
                else document.getElementById('button').innerHTML='<input id="submit" type="submit" disabled="disabled" value="Подобрать диск">';
            }
            }
            document.getElementById('bodySel').innerHTML='<select id="body" name="body" disabled="disabled"><option selected="selected" value="">Кузов</option></select>';
            repeat="FALSE"
        }
        else if (select.id == 'model') {
        	href += '?model='+select.value;
            document.getElementById('body').disabled=false;
            btn.disabled = true;
            btn.style.color='#808080';
            btn.style.backgroundColor='#D4D0C8';
            btn.style.cursor='default';
            if (document.getElementById('brand')) {
            	var brand = document.getElementById('brand');
            	brand.disabled=false;
                if (window.opera && document.getElementById) brand.setAttribute('class', 'aktiv');
                else brand.style.cssText='background: #666; color: #fff;';
                repeat="TRUE";
               }
            else {
            	btn.disabled=false;
                if (!(window.opera && document.getElementById)) btn.style.cssText = 'color: #fff; background: #666; border: 1px solid #000; cursor: pointer;';
                else btn.setAttribute('class', 'btn');
	            repeat="TRUE";
            }
            if (document.getElementById('r')) {
            	var radius = document.getElementById('r');
            	radius.disabled=false;
                if (window.opera && document.getElementById) radius.setAttribute('class', 'aktiv');
                else radius.style.cssText='background: #666; color: #fff;';
                repeat="TRUE";
            }
        }
        else if (select.id == 'marka') {
        	href += '?marka='+select.value+'&did='+document.getElementById('did').value;
            if (repeat=="TRUE") {
            	btn.style.color='#808080';
	            btn.style.backgroundColor='#D4D0C8';
	            btn.style.cursor='default';
	            btn.disabled=true;
	            if (window.opera && document.getElementById) {
	                if (document.getElementById('podbor')) document.getElementById('buttonz').innerHTML='<input id="submit" type="button" disabled="disabled" name="submit" value="Подобрать диск" onmouseup="GetResultV(this)">';
	                else document.getElementById('button').innerHTML='<input id="submit" type="submit" disabled="disabled" value="Подобрать диск">';
	            }
            }
            document.getElementById('bodySel').innerHTML='<select id="body" name="body" disabled="disabled"><option selected="selected" value="">Кузов</option></select>';
            repeat="FALSE"
        }
        else if (select.id == 'smodel') {
        	//alert(select.id);
        	href += '?smodel='+select.value;
            //document.getElementById('body').disabled=false;
            btn.disabled = true;
            btn.style.color='#808080';
            btn.style.backgroundColor='#D4D0C8';
            btn.style.cursor='default';
            btn.disabled=false;
            if (!(window.opera && document.getElementById)) btn.style.cssText = 'color: #fff; background: #666; border: 1px solid #000; cursor: pointer;';
            else btn.setAttribute('class', 'btn');
	        repeat="TRUE";
        }
        else {
            href += "?brand="+select.value+"&auto_id="+document.getElementById('model').value;
        }
		if (s.setAttribute) s.setAttribute('src', href);
        else s.src = href;
    }, 10);
    return repeat;
}
//
function EnableSubmitV(select, b) {
	     if (b == 2) btn = document.getElementById('ch2but');
         else btn = document.getElementById('submit');
	     if (select.value == ' ') {btn.disabled=true; btn.style.color='#808080'; btn.style.backgroundColor='#D4D0C8'; btn.style.cursor='default'; return;}
         btn.disabled=false;
         if (!(window.opera && document.getElementById)) btn.style.cssText = 'color: #fff; background: #666; border: 1px solid #000; cursor: pointer;';
         else btn.setAttribute('class', 'btn');
}
//
function GetResultV(select, cho) {
	if (select.value == ' ') return;
    var href = 'if/remote-v.htm';
    var w = document.getElementById('watch');

    switch (cho) {
	case 2:
        var wide = document.getElementById('WIDE');
    	var dim = document.getElementById('DIM');
    	var dim1 = document.getElementById('DIM1');
        var et = document.getElementById('ET');
        var dia = document.getElementById('DIA');
        var pcd1 = document.getElementById('pcd1');
        var w = document.getElementById('watch');
        w.style.visibility = 'visible';
        var tmp = document.getElementById('tmp');
    	if (tmp) document.lastChild.lastChild.removeChild(tmp);
		var s = null;
    	var n = document.createElement('SPAN');
    	s = document.lastChild.lastChild.appendChild(n);
		s.setAttribute('id', 'tmp');
		s.style.display = 'none';
		s.innerHTML = '.<s'+'cript></' + 'script>';
        setTimeout(function() {
    	var sc = s.getElementsByTagName("script")[0];
		sc.language = "JavaScript";
        href += '?submit=2&wide='+wide.value+'&dim='+dim.value+'&dim1='+dim1.value+'&et='+et.value+'&pcd1='+pcd1.value;
        if (dia.value != '') href += '&dia='+dia.value;
        //if (body.value != '') href += '&body='+body.value;
        //if (r.value != ' ') href += '&radius='+r.value;
		if (sc.setAttribute) sc.setAttribute('src', href);
        else sc.src = href;
    	}, 10);
	    break
	default:
    var brand = document.getElementById('brand');
    if (window.opera && document.getElementById) {
    	if (brand.value == ' ') return;
	}
    var auto = document.getElementById('auto');
    var model = document.getElementById('model');
    var body = document.getElementById('body');
    //add. parameter
    var r = document.getElementById('r');
    w.style.visibility = 'visible';
	var temp2 = document.getElementById('temp2');
    if (temp2) document.lastChild.lastChild.removeChild(temp2);
	var span2 = null;
    var n2 = document.createElement('SPAN');
    span2 = document.lastChild.lastChild.appendChild(n2);
	span2.setAttribute('id', 'temp2');
	span2.style.display = 'none';
	span2.innerHTML = '.<s'+'cript></' + 'script>';

    setTimeout(function() {
    	var s2 = span2.getElementsByTagName("script")[0];
		s2.language = "JavaScript";
        //href += '?submit=1&auto='+auto.value+'&model='+model.value+'&brand='+brand.value;
        href += '?submit=1&auto='+auto.value+'&model='+model.value+'&brand='+brand.value;
        if (body.value != '') href += '&body='+body.value;
        if (r.value != ' ') href += '&radius='+r.value;
		if (s2.setAttribute) s2.setAttribute('src', href);
        else s2.src = href;
    }, 10);
}//eos

}
//
function RemoteDia(select) {
	var href = '/if/remote-v.htm';
	var w = document.getElementById('watch2');
    w.style.visibility = 'visible';
    var wide = document.getElementById('WIDE');
    var dim = document.getElementById('DIM');
    var dim1 = document.getElementById('DIM1');
    var et = document.getElementById('ET');
    var pcd1 = document.getElementById('pcd1');
	var temp3 = document.getElementById('temp3');
    if (temp3) document.lastChild.lastChild.removeChild(temp3);
	var span = null;
    var n = document.createElement('SPAN');
    span = document.lastChild.lastChild.appendChild(n);
	span.setAttribute('id', 'temp3');
	span.style.display = 'none';
	span.innerHTML = '.<s'+'cript></' + 'script>';
    	setTimeout(function() {
    	var s = span.getElementsByTagName("script")[0];
		s.language = "JavaScript";
        if (select.id == 'ET') href += '?dias=1&pcd1='+pcd1.value+'&wide='+wide.value+'&dim='+dim.value+'&dim1='+dim1.value+'&et='+select.value;
        if (s.setAttribute) s.setAttribute('src', href);
        else s.src = href;
    }, 10);
    return;
}
//
//
function RemoteSteel(a, pcd1, active) {
	//
	var aList = document.getElementById('rad').getElementsByTagName('a');
	for (var i=0;i<aList.length;i++) {
    if (aList[i].getAttribute('class')) aList[i].removeAttribute('class');
    if (aList[i].getAttribute('className')) aList[i].removeAttribute('className');
    }
    active.setAttribute('className', 'act');
    active.setAttribute('class', 'act');
	//
	var href = '/if/remote-v.htm';
	var w = document.getElementById('watch');
    w.style.visibility = 'visible';
	var temp3 = document.getElementById('temp3');
    if (temp3) document.lastChild.lastChild.removeChild(temp3);
	var span = null;
    var n = document.createElement('SPAN');
    span = document.lastChild.lastChild.appendChild(n);
	span.setAttribute('id', 'temp3');
	span.style.display = 'none';
	span.innerHTML = '.<s'+'cript></' + 'script>';
    href += '?a='+a+'&pcd1='+pcd1;
    	setTimeout(function() {
    	var s = span.getElementsByTagName("script")[0];
		s.language = "JavaScript";
        if (s.setAttribute) s.setAttribute('src', href);
        else s.src = href;
    }, 10);

}
//
function move() {if (document.getElementById('lim')) {if (fIE || br.indexOf('OP')!=-1) div1.style.top=document.documentElement.scrollTop;else return;}}
var fIE = false;
onscroll=move;
///

function twentySec() {
		document.getElementById('upload').disabled=true;
        setTimeout("document.getElementById('upload').disabled=false", 20000);
}