function Buttons(){

/*
    inputs = document.getElementsByTagName('input');
    for(i = 0; i < inputs.length; i++){
        if(inputs[i].type != 'image')
            inputs[i].className='input';
        if(inputs[i].type == 'submit')
            inputs[i].className='button';
    }*/
	 
	 $("input[type=text]").addClass("input");
	 $("input[type=password]").addClass("input");
	 $("input[type=submit]").addClass("button");
	 $("input[type=button]").addClass("button");
	 $("input[type=checkbox]").addClass("noBord");
}
function Init(){
    Buttons();
}

function imageScale(sender, max_size) {
    p=0;
    if (sender.width > max_size) {
        p = (max_size / sender.width);
    }
    else {
        if (sender.height > max_size) {
            p = (max_size / sender.height);
        }
    }
    if(p > 0) {
        sender.width = p * sender.width;
    }
}

function hide(tid){
if (document.getElementById){
	target=document.getElementById(tid);
	target.style.display="none";
	}
}

function show(tid){
if (document.getElementById){
	target=document.getElementById(tid);
	target.style.display="block";
	}
}
function setHeight(){
var hajt1=document.body.clientHeight;
var width1=document.body.clientWidth;
var hajt2=hajt1-127;
var hajt=hajt1-21;
if (hajt2!=null) $("#centerSide").css({height:hajt2});
if (hajt!=null) $("#bottomMenu").css({position:'absolute',width:width1,top:hajt+'px',left:0})

 test1=$("a.recImg/img").css('height');

}
function RGBToHex(value)
{
	var re = /\d+/g;
	var matches = value.match(re);
	if (matches){
		var r = parseInt(matches[0]);
		var g = parseInt(matches[1]);
		var b = parseInt(matches[2]);
		return "#" + r.toString(16) + g.toString(16) + b.toString(16);
	}
	else return value;
}
$(document).ready(function(){

	$("#categoryList li:has(ul)").each(function(){
	
		var ul1=$(this).children("ul");
		
		$(this).children("a").attr("href","#").click(function(){
			$(".cat2Dspl").removeClass("cat2Dspl").hide();
			ul1.toggle().addClass("cat2Dspl");
			return false;
	});
	});
	$("#infoNav a:last").css({"color":"#039"});
		var baskOptions=$("#attrib .selectR");
	  	if (baskOptions.length>2) {
			$(baskOptions).each(function(){
				$(this).css({"float":"left","margin-right":"11px"})
			});
			$("#infoXSubm").css({"clear":"left"});
	  		/*	$("#infoPrice").css({top:((baskOptions.height()+1)*baskOptions.length+6)+"px"})*/
			//	$("#infoAvail").css({top:((baskOptions.height()+1)*baskOptions.length+20)+"px"})
						
			p=document.getElementById('prodChange');
			if (p) p.remove(0);			
		}
		else{
			for (n=0;n<baskOptions.length;n++){
	/*			if (n==0) 
					t="";
				else
					t=n;*/

	  			p=document.getElementById('prodChange'+(n==0?"":n));
				if (p) p.remove(0);
			}
		}
		
	var bodyBG=$("#imageBg").css("background-image");
	if (bodyBG.indexOf("bg.jpg")!=-1){
		$("#content a").each(function(){
			var col=RGBToHex($(this).css("color"));
			if (col=="#ffffff"||col=="#fff")
				$(this).addClass("invert");
		});
	}
	$("#productDescr").jScrollPane({showArrows:true});
	$("#basketScroll").jScrollPane({showArrows:true});
	$("#scrollFile").jScrollPane({showArrows:true});	
	$("#scroll2").jScrollPane({showArrows:true});
	$(".scroll-pane").jScrollPane({showArrows:true});

		$("#banner3").append('<img src="/themes/base/bmw2009/img/close.png" alt="close window" id="closeWindow"/>').children("#closeWindow").css({"position":"absolute","right":"-9px","top":"10px","cursor":"pointer"}).click(function(){
			$("#banner3 object").stop();
			$("#banner3").remove();
		});

});