formMod = function() {
	$('select').each( function(i){
		var _id = 'select' + i;
		$(this).wrap('<div class="select-case" id="case' + _id + '"></div>')
		$('#case' + _id).append(
			"<div id='" + _id + "' class='select'></div>"
		);
		$('#' + _id).append('<dl></dl>');
		$($('#' + _id + ' dl')[0]).append('<dt><span>' + $(this).find('option:selected').text() + '</span><span class="formitem-decor"></span></dt>');
		$("#staticcase").append('<ul class="select-list" id="list' + _id + '"></ul>');
		var parentSelect = $(this);
		$(this).find('option').each( function(j) {
			$('#list' + _id).append('<li>' + $(parentSelect.find('option')[j]).text() + '</li>')
		});
		$('#list' + _id).addClass('active-formitem');
		$($('#' + _id + ' dl dt')[0]).css('width', parseInt($('#list' + _id).width()) + 10 + 'px');
		$('#list' + _id).removeClass('active-formitem');
		$($('#' + _id + ' dl dt')[0]).click( function() {
			if( $('#list' + _id).hasClass('active-formitem') ) {
				$('#list' + _id).removeClass('active-formitem');
			}
			else {
				$('ul.active-formitem').removeClass('active-formitem');
				$('#list' + _id).addClass('active-formitem');
				$('#list' + _id).css(
					'left',
					$('#case' + _id).offset().left -  $("#staticcase").offset().left + 0
				)
				$('#list' + _id).css(
					'top',
					$('#case' + _id).offset().top - $("#staticcase").offset().top + 22
				)
			}
		});
		$(this).css('position','absolute');
		$(this).css('left','-11111px');
		$('#list' + _id + ' li').click( function() {
			$('#' + _id + ' dt span:first').html($(this).html());
			$('ul.active-formitem').removeClass('active-formitem');
		})
	});
}

$(document).ready(function () {
	if ( $('h1').length > 0 ) {
		if ($('h1 span:first').length>0) {
			$('h1 span:last').remove();
		}
	}
	//menu
	$('.menu td').hover(
		function () {
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass('hover');
		}
	)
	
	$('.promo-menu td').hover(
		function () {
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass('hover');
		}
	)
	//Cufon
	Cufon.replace('.head .content');
	Cufon.replace('.menu td', {
		fontFamily: 'SuzukiPROHeadline',
		hover: true
	});
	Cufon.replace('.menu div', {
		fontFamily: 'SuzukiPROHeadline',
		hover: true
	});
	Cufon.replace('.promo-menu td', {
		fontFamily: 'SuzukiPROHeadline',
		hover: true
	});
	Cufon.replace('.promo-menu div', {
		fontFamily: 'SuzukiPROHeadline',
		hover: true
	});
	Cufon.replace('.promo-menu a', { fontFamily: 'SuzukiPROHeadline' });
	Cufon.replace('.models a');
	Cufon.replace('.footer span');
	Cufon.replace('.news-preview .header', { fontFamily: 'SuzukiPROHeadline' });
	Cufon.replace('.news-preview .all', { fontFamily: 'SuzukiPROHeadline' });
	Cufon.replace('.events-preview .item dt');
	Cufon.replace('.companies td a');
	Cufon.replace('.hots th p a', { hover: true });
	Cufon.replace('.buy th a', { hover: true });
	Cufon.replace('.buy td a', { hover: true });
	Cufon.replace('.photo-album-name', { fontFamily: 'SuzukiPROHeadline' });
	//Cufon

	if ( $.browser.msie && $.browser.version == 7 ) {
		setTimeout( function() {
			$('.menu td div ul').each( function() {
				var maxWidth = 0;
				$(this).css('display', 'block');
				$(this).find('li').each( function() {
					if ( $(this).width() > maxWidth ) maxWidth = $(this).width();
				})
				$(this).find('li').each( function() {
					$(this).css('width', maxWidth);
				})
				$(this).css('display','');
			});
		},10)
		
		setTimeout( function() {
			$('.promo-menu td div ul').each( function() {
				var maxWidth = 0;
				$(this).css('display', 'block');
				$(this).find('li').each( function() {
					if ( $(this).width() > maxWidth ) maxWidth = $(this).width();
				})
				$(this).find('li').each( function() {
					$(this).css('width', maxWidth);
				})
				$(this).css('display','');
			});
		},10)
	}
	if ( $.browser.msie && $.browser.version == 6 ) {
		$('.menu td div ul').each( function() {
			if ( $(this).css('width') < $(this).parent().width() )
			$(this).css('width', $(this).parent().width() )
		});
		$('.promo-menu td div ul').each( function() {
			if ( $(this).css('width') < $(this).parent().width() )
			$(this).css('width', $(this).parent().width() )
		});
	}

	//scroll
	/*if ( $('.scroll-case').length == 1 ) {
		$('.scroll-case').jScrollPane({showArrows:true, scrollbarWidth: 22});
	}*/
	//scroll

	//Actions
	$('#actions dl.events-preview dt a').each( function(i) {
		$(this).click(function(event) {
			$('#actions .event').removeClass('active');
			$($('#actions .event')[i]).addClass('active');
			event.preventDefault();
		});
	});
	$('#actions dl.events-preview dd h2 a').each( function(i) {
		$(this).click(function(event) {
			$('#actions .event').removeClass('active');
			$($('#actions .event')[i]).addClass('active');
			event.preventDefault();
		});
	});
	$('#actions dl.events-preview dd p a').each( function(i) {
		$(this).click(function(event) {
			$('#actions .event').removeClass('active');
			$($('#actions .event')[i]).addClass('active');
			event.preventDefault();
		});
	});
	//Actions

	//formMod();

	//calc
	/*$('#opencalc').click( function(event) {
		$('#activecalc').css('left','0');
		event.preventDefault();
	});
	$('#closecalc').click( function(event) {
		$('#activecalc').css('left','-11111px');
		event.preventDefault();
	});*/
	//calc
});


/*var timer = null;
 $(function() {
    $(window).load( function() {
        if (timer) {
           clearTimeout(timer);
           timer = null;
        }
        process();
    });
    timer = setTimeout( function() {
        if (checkAvailable())
           process();
        }
    }, 10*1000 );
 });

 function checkAvailable()
 {
     var available = true;
     $('img').each( function() {
         try {
             if (this.height == 0) {
                available = false;
                return false;
             }
         }
         catch (e) {
             available = false;
             return false;
         }
      });
      return available;
  }*/
/*function process() {
	if ( $('.scroll-case').length == 1 ) {
		$('.scroll-case').jScrollPane({showArrows:true, scrollbarWidth: 22});
	}
}*/
/*$(window).load(function(){  
	if ( $('.scroll-case').length == 1 ) {
		$('.scroll-case').jScrollPane({showArrows:true, scrollbarWidth: 22});
	}
}); */

