$(function(){
	
		$("#tabs-1").preloadify({ imagedelay:100 });
		$("#tabs-2").preloadify({ imagedelay:100 });
		$("#tabs-3").preloadify({ imagedelay:100 });
		$("#tabs-4").preloadify({ imagedelay:100 });
		$("#tabs-5").preloadify({ imagedelay:100 });
		$("#tabs-6").preloadify({ imagedelay:100 });
		$(".photos").preloadify({ imagedelay:100 });
		$(".caritems").preloadify({ imagedelay:100 });
		$(".tabPicture").preloadify({ imagedelay:500 });
		
		
		});

$(document).ready(function(){

// $("#searcher").autocomplete({
                // source: "jsony.php",
                // minLength: 2,
                // select: function(event, ui) {
                    // $('#car_id').val(ui.item.id);
                    
                // }
            // });

  $("#tableOferta tr:even").css("background-color", "#D6D7D8");
  $("#tableOferta tr:odd").css("background-color", "#E2E2E2");
  
  $(".caritems tr:even").css("background-color", "#D6D7D8");
  $(".caritems tr:odd").css("background-color", "#E2E2E2");
  

$('.carfeat').easyListSplitter({ 
			colNumber: 3,
			direction: 'vertical'
		
		});


  
  $("#shipping tr:odd").addClass("odd");

 $('#tableOferta .child').hide();
                $('#tableOferta p.actiona').click(function(){
                    var id = $(this).attr('id');
					var iler = $(this).attr('rel');
                    id = id.split('-');
                    //$("."+id[1]).toggle();
					 $("."+id).toggle();
					
					$.ajax({
			type: "post",
			url: "buyerfees2.php",
			data: "k="+ iler, 
			success: function (data) {
							$('#oplaty'+id).hide().html(data).fadeIn();
							
		}	
  		
});
					
					
					
					
					
					
					
                });
  
  
				$('#tabs').tabs({ collapsible: true });
            
  
$( "#accordion" ).accordion({ autoHeight: false,
alwaysOpen: false,
active: false
		});
  
  $("a.thickbox").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">'  + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});

	
  
  });
  
  		// jQuery(function( $ ){
			// $.localScroll();
		// });

	$(document).ready(function() {

	$("#producent2").attr("disabled","disabled");
	$("#producent").attr("disabled","disabled");
	$("#model").attr("disabled","disabled");
	
	
	$('#lang')
      //.find('option')
      .change(function(){
         var destLang = $(this).attr('value');
		 
		 $('body').translate( 'pl', {    
          not: 'select, #lang,.adres'
		 })
          .translate( 'pl', destLang, {    
          not: 'select, #lang,.adres',  
          fromOriginal: true,   
                         not: 'select',
                         walk: true,
						  async:  true,
						toggle: true,
                         start: function(){ $('#throbber').show() },   // show loading icon
          complete: function(){ $('#throbber').hide()  },  // hide loading icon
          error: function(){ $('#throbber').hide() }  // hide loading icon
         })   
		 
         $.cookie('destLang', destLang );
         return false;
      }); 
 
 
 var destLang= $.cookie('destLang'); 
    if( destLang )  
        $('body').translate( 'pl', destLang, {
    not: 'select, #lang,.adres', 
    fromOriginal: true,
    async:  true,
    toggle: true,
    walk: true,
    start:         function(){   $('#throbber').show() },
		complete:  function(){   $('#throbber').hide()  },
				error:         function(){   $('#throbber').hide()   }
  });

		
		});
		
		
		function prod()
{

$("#model").removeAttr("disabled");	
	$.get("getmodels.php", {type: $('#typ_pojazdu').val(), make: $('#producent').val() }, 
	function(data)
	{
   		$("#model").html(data);
 	});
} 

function typy()
{
$("#producent").removeAttr("disabled");
	$.get("getmakes.php", {type: $('#typ_pojazdu').val()}, 
	function(data)
	{
   		$("#producent").html(data);
   		
 	});
}





function cars()
{
$("#producent2").removeAttr("disabled"); 

	$.get("getmakesa.php", {type: $('#typ_pojazdu2').val()}, 
	function(data)
	{
   		$("#producent2").html(data);
   		
 	});
}


  //** Dynamic Drive Equal Columns Height script v1.01 (Nov 2nd, 06)
//** http://www.dynamicdrive.com/style/blog/entry/css-equal-columns-height-script/

var ddequalcolumns=new Object()
//Input IDs (id attr) of columns to equalize. Script will check if each corresponding column actually exists:
ddequalcolumns.columnswatch=["leftcolumn", "rightcolumn", "contentwrapper"] 

ddequalcolumns.setHeights=function(reset){
var tallest=0
var resetit=(typeof reset=="string")? true : false
for (var i=0; i<this.columnswatch.length; i++){
if (document.getElementById(this.columnswatch[i])!=null){
if (resetit)
document.getElementById(this.columnswatch[i]).style.height="auto"
if (document.getElementById(this.columnswatch[i]).offsetHeight>tallest)
tallest=document.getElementById(this.columnswatch[i]).offsetHeight
}
}
if (tallest>0){
for (var i=0; i<this.columnswatch.length; i++){
if (document.getElementById(this.columnswatch[i])!=null)
document.getElementById(this.columnswatch[i]).style.height=tallest+"px"
}
}
}

ddequalcolumns.resetHeights=function(){
this.setHeights("reset")
}

ddequalcolumns.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}

ddequalcolumns.dotask(window, function(){ddequalcolumns.setHeights()}, "load")
ddequalcolumns.dotask(window, function(){if (typeof ddequalcolumns.timer!="undefined") clearTimeout(ddequalcolumns.timer); ddequalcolumns.timer=setTimeout("ddequalcolumns.resetHeights()", 200)}, "resize")




/*********************
//* jQuery Multi Level CSS Menu #2- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last update: Nov 7th, 08': Limit # of queued animations to minmize animation stuttering
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/

//Update: April 12th, 10: Fixed compat issue with jquery 1.4x

//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):
var arrowimages={down:['downarrowclass', 'images/down.gif', 14], right:['rightarrowclass', '']}

var jqueryslidemenu={

animateduration: {over: 100, out: 100}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
			$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
				'<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
				+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
				+ '" style="border:0;" />'
			)
			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(jqueryslidemenu.animateduration.out)
				}
			) //end hover
			$curobj.click(function(){
				$(this).children("ul:eq(0)").hide()
			})
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="myslidemenu" on page:
jqueryslidemenu.buildmenu("myslidemenu", arrowimages)

function Szowtips() {		
	$('td a#atooltip').tooltip({
		delay: 0,
		showURL: false,
		track: true,
		//fixPNG: true,
		//showBody: " - ",
		bodyHandler: function() {
			ChildImgSrc = $(this).attr('rel');
			return $('<img/>').attr('src', ChildImgSrc);
		}
	});
}

function Szowopis() {
$(".ptooltip2").tooltip({ 
	track: true,
	delay: 0,
	showURL: false,
	showBody: " - ",
	fade: 250
})
}
