var searchCount = 5;

function searchItems( start, options, indexurl ) {
	if ( indexurl )
		var url = indexurl + "?start="+start+"&count="+searchCount;
	else
		var url = "index.html?start="+start+"&count="+searchCount;
	if ( options ) {
		v = new Array();
		for( var key in options ) {
			v.push( key + ":" + options[key] )
		}
		
		url += "&options=" + v.join(";");
	}
	window.location.href = url;
}

function subscribeNewsletter() {
	var name = $('#newsletter_name').val();
	var email = $('#newsletter_email').val();
}

$(document).ready(function(){
	flashembed("adv1", {src:"swf/adv1.swf",wmode:'opaque'});
	flashembed("adv2", {src:"swf/adv2.swf",wmode:'opaque'});
	
	$('#search_branding').change(function(){
		var branding = $(this).val();
		searchItems( 0, { "branding": branding });
	});
	
	$('.search_type').click(function(){
		var type = $(this).attr('id').substr(12);
		if ( type ) {
			searchItems( 0, { "type": type } )
		}
	});

	$('#search_branding2').change(function(){
		var branding = $(this).val();
		searchItems( 0, { "branding": branding }, 'offerte.html' );
	});
	
	$('.search_type2').click(function(){
		var type = $(this).attr('id').substr(12);
		if ( type ) {
			searchItems( 0, { "type": type }, 'offerte.html' )
		}
	});
	
	$('.autoValue').each(function(i,item){
		$(item).data('autoValue',$(item).val());
	})
	$('.autoValue')
		.focus(function(){ if ( $(this).val() == $(this).data('autoValue') ) { $(this).val(""); } })
		.blur(function(){ if ( $(this).val() == "" ) { $(this).val($(this).data('autoValue')); } });
});
