/*
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features).focus();
}
*/

/*
function getImageName(attr){

//		$.alerts.horizontalOffset = -200;

		var img_str = '';	
		var img_folder='konfigurator/small_images';
		
		var img_bezug; 		
		if (attr['bezug'] == 'softex-schwarz' ){
			img_bezug = '_black' ;
		} else if (attr['bezug'] == 'alcantara-rot' ){
			img_bezug = '_red' ;
		} else if (attr['bezug'] == 'alcantara-grau' ){
			img_bezug = '_grey' ;
		} else if (attr['bezug'] == 'alcantara-tuerkis' ){
			img_bezug = '_turquoise' ;
		} else if (attr['bezug'] == 'alcantara-blau' ){
			img_bezug = '_royal' ;
		} else if (attr['bezug'] == 'alcantara-terracotta' ){
			img_bezug = '_terra' ;
		} else if (attr['bezug'] == 'alcantara-curry' ){
			img_bezug = '_' ;
		} else if (attr['bezug'] == 'alcantara-schwarz' ){
			img_bezug = '_black' ;
		} else if (attr['bezug'] == 'alcantara-sand' ){
			img_bezug = '_sand' ;
		} else if (attr['bezug'] == 'alcantara-ice-blau' ){
			img_bezug = '_ice' ;
		} else if (attr['bezug'] == 'leder-schwarz' ){
			img_bezug = '_leather_black' ;
		} else if (attr['bezug'] == 'care' ){
			img_bezug = '_white' ;
		} else if (attr['bezug'] == 'sattel-schwarz' ){
			img_bezug = '_sattelschwarz' ;
		} else if (attr['bezug'] == 'sattel-grau' ){
			img_bezug = '_sattelgrau' ;
		} else if (attr['bezug'] == 'swoppster-green' ){
			img_bezug = '_green' ;
		} else if (attr['bezug'] == 'swoppster-blue' ){
			img_bezug = '_blue' ;
		} else if (attr['bezug'] == 'swoppster-orange' ){
			img_bezug = '_orange' ;
		} else if (attr['bezug'] == 'swoppster-red' ){
			img_bezug = '_red' ;
		}
			
	
	
	
		var img_gestell;		
		if (attr['gestell'] == 'anthrazit' ){
			img_gestell = '' ;
		} else if (attr['gestell']  == 'titan' ){
			img_gestell = '_titan' ;
		} else if (attr['gestell']  == 'care' ){
			img_gestell = '_care' ;
		} 
	
	
	
	
	
		var img_lehne;		
		if (attr['lehne'] == 'ohne' ){
			img_lehne = '' ;
		} else if (attr['lehne'] == 'design' ){
			img_lehne = 'DE' ;
		} else if (attr['lehne']  == 'dynamic' ){
			img_lehne = 'DY' ;
		} 
		
		
		
		
		

		var img_rollen;		
		if (attr['rollen'] == 'false' ){
			img_rollen = '' ;
		} else if (attr['rollen'] == 'true' ){
			img_rollen = '_R' ;
		} 	
	
	
	
	
		if (((attr['bezug'] == 'sattel-grau') || (attr['bezug'] == 'sattel-schwarz')) &&  ( (attr['lehne'] == 'design')  || (attr['lehne'] == 'dynamic') ) ) {
			jAlert('Die Kombination Sattelsitz mit Lehne ist leider nicht möglich.','Hinweis bzgl. Kombinationsmöglichkeiten');			
			document.forms['konfigurator'].elements['lehne'].selectedIndex = 0;	 
			img_lehne = '' ;
		}	
	
	
	
		if (( (attr['bezug'] == 'sattel-schwarz' ) || (attr['bezug'] == 'sattel-grau' ) || (attr['bezug'] == 'softex-schwarz' )  || (attr['bezug']  == 'leder-schwarz') || (attr['bezug']  == 'care') ) && (attr['polster'] == 'tempur') ) {
			 jAlert('Die Tempur-Polsterung ist nur in Kombination mit den Alcantara-Bezügen möglich','Hinweis bzgl. Kombinationsmöglichkeiten');
			 document.forms['konfigurator'].elements['polster'].selectedIndex = 0;	 
		}
		
	
		if (attr['gestell']  =='care' )  {
			 jAlert('Den Fußring Care gibt es nur in Kombination mit Rollen und weißem Sitzbezug ohne Tempur-Plosterung. Die Kombination mit Lehne ist möglich. Die Feder ist nur in der Stärke für 60 bis 120 kg Körpergewicht erhältlich.','Hinweis bzgl. Kombinationsmöglichkeiten');		 
			 document.forms['konfigurator'].elements['polster'].selectedIndex = 0;			
			 document.forms['konfigurator'].elements['bezug'].selectedIndex = 10;					 
			 document.forms['konfigurator'].elements['rollen'].selectedIndex = 1;			 
			 document.forms['konfigurator'].elements['koerpergewicht'].selectedIndex = 0;						 			 
			 konf_rollen = '_R';
			 konf_bezug = '_white' 	;		 
		}
			
		
		
		if ((attr['bezug'] == 'swoppster-green') || (attr['bezug'] == 'swoppster-red') ||(attr['bezug'] == 'swoppster-orange') ||(attr['bezug'] == 'swoppster-blue') ){
			img_str = img_folder + '/' + 'SWOPPSTER' + img_bezug + '.jpg';

		} else {
			var img_str = img_folder + '/' + 'SWOP' + img_lehne + img_gestell + img_bezug + img_rollen + '.jpg';			

		}		
									
		return img_str;							
}

*/  
  

 

$(document).ready(function(){
	$("select.swopper-config-select").change(function () {
		  var str = "";
		  var attr = new Array();
		  $("select.swopper-config-select option:selected").each(function () {
				attr[$(this).parent().attr("name")] = $(this).attr("value") ;
			  });			  
			// Bild austauschen  
			str = getImageName(attr); 			
			$('#swopper-configurator-img').attr("src",  '/'+str);		  

			// eventuell haben sich mit getImage selectfeld-selects geändert...
			attr = new Array();
			$("select.swopper-config-select option:selected").each(function () {
				attr[$(this).parent().attr("name")] = $(this).attr("value") ;
			  });	
			
			// Preis austauschen
			var params = "";
			for (var i in attr) {
				//alert(attr[i]);
				params += '&'+i+'='+attr[i];
			}			
			
			// Link-Ziel austauschen				
			$('#putToBasket-link').attr("href",  basket_base_url+'?'+params+'&putToBasket=true');
			
			$.getJSON("/typo3conf/ext/pw_swop_config/pi1/json.php?"+params, function(json) {				
				$('#swop-preis').html(json[0].price);
				$('#swop-preis-skonto').html(json[0].price_skonto);
			});
			
			// Im Formular vorführmodell auf false setzen
//			document.getElementById('swopconf-vorfuehrmodell').value = 'false';	
//			document.getElementById('vorfuhrmodell_text').innerHTML = '';	
			
			
		})
		.change();	
});



function getImageURL(){
	var str = "";
	var attr = new Array();
	$("select.swopper-config-select option:selected").each(function () {
		attr[$(this).parent().attr("name")] = $(this).attr("value") ;
	});			  
	// Bild austauschen  
	str = getImageName(attr); 
	return str;
}


function setSelectedLehne(value){
    var i = 0; 
	$("#swopconf-lehne option").each(function () {
		if (value == ($(this).attr("value"))) {
			document.getElementById('swopconf-lehne').selectedIndex = i;	
		}
		i++;
	});		
}
function setSelectedBezug(value){
    var i = 0; 
	$("#swopconf-bezug option").each(function () {
		if (value == ($(this).attr("value"))) {
			document.getElementById('swopconf-bezug').selectedIndex = i;	
		}
		i++;
	});		
}
function setSelectedPolster(value){
    var i = 0; 
	$("#swopconf-polster option").each(function () {
		if (value == ($(this).attr("value"))) {
			document.getElementById('swopconf-polster').selectedIndex = i;	
		}
		i++;
	});		
}
function setSelectedGestell(value){
    var i = 0; 
	$("#swopconf-gestell option").each(function () {
		if (value == ($(this).attr("value"))) {
			document.getElementById('swopconf-gestell').selectedIndex = i;	
		}
		i++;
	});		
}
function setSelectedRollen(value){
    var i = 0; 
	$("#swopconf-rollen option").each(function () {
		if (value == ($(this).attr("value"))) {
			document.getElementById('swopconf-rollen').selectedIndex = i;	
		}
		i++;
	});		
}
function setSelectedKoerpergewicht(value){
    var i = 0; 
	$("#swopconf-koerpergewicht option").each(function () {
		if (value == ($(this).attr("value"))) {
			document.getElementById('swopconf-koerpergewicht').selectedIndex = i;	
		}
		i++;
	});		
}





function getParamStr(){
	  var attr = new Array();
	  $("select.swopper-config-select option:selected").each(function () {
			attr[$(this).parent().attr("name")] = $(this).attr("value") ;
	  });			  
      
      var params = "";
	  for (var i in attr) {
		 params += '&'+i+'='+attr[i];
	  }
	  return params;
}


/*
$(document).ready(function(){
	$("select.swopper-config-select").hover(function() {
	  $(this).next("em").animate({opacity: "show"}, 10);
	}, function() {
	  $(this).next("em").animate({opacity: "hide"}, 10);
	});
});

$(document).ready(function(){
	$("span.form-select-headline").hover(function() {		
	  $(this).next("select").next("em").animate({opacity: "show"}, 10);
	}, function() {
	  $(this).next("select").next("em").animate({opacity: "hide"}, 10);
	});
});
*/

$(document).ready(function(){
	$(".form-select-headline-info").hover(function() {
 	  if($(this).parent().next("em").height() < 226){
		  $(this).parent().next("em").height(229);
	  }
	  $(this).parent().next("em").animate({opacity: "show"}, 10);
	  
	}, function() {
	  $(this).parent().next("em").animate({opacity: "hide"}, 10);
	});
});



