// JavaScript Document

//used in Categories Landing pages 

window.addEvent('domready', function() {
									 
	
	var locale = wep.locale;
	var site = odw;
	/* For each drop box, add an onchange event that redirect to the href of the current model section, removes all variables and adds the locale + model name*/
	/* In the model page in xsl/ProductSections/model.xslt*/
	
	var models = $$('.model_sel');
	models.each( function(Drop, i){
		Drop.onchange=function(){
			var parentlink =window.location.href.substring(0,window.location.href.lastIndexOf('?'));
			var mod = Drop.getSelected();
			var model = mod[0].get('html');
			window.location.href= parentlink + "?site=odw_" + wep.locale + "&m=" + model;

			}				  
	});


/*If there is no model in the url */		
	
	if(window.location.href.indexOf("&m=") == -1){
		/* if there is only one model, show the page*/
		var optionNr = document.models.m.options.length;
		if (optionNr <3){
			var parentlink = window.location.href.substring(0,'?');
			var model = document.models.m.options[1].get('html');
			window.location.href = parentlink + "?site=" + site +'&m=' + model;
			
		}; 
		/*If there is a model in the url and there is only one model, hide the select box
		+ Extra condition for ie7 that does not recognize the options from inside the kasa frame : don't do this for kasa*/
	}else if (window.location.href.indexOf("&temp=") == -1){if(document.models.m.options.length <3){$$('.model_sel').setStyle('display', 'none');};}

	
	if (document.referrer.indexOf('/repair/index.aspx')!= -1){
		if($('tabTitle_5')){		
				activateTab( 5 );
				if(wep.locale == 'en_GB' || wep.locale == 'nl_NL'|| wep.locale == 'fr_BE' ||wep.locale == 'nl_BE'||wep.locale == 'pl_PL'||wep.locale == 'de_AT'|| wep.locale == 'fr_FR'){
					if(window.location.href.indexOf("stg.") == -1) {showSparrow('prod');}else{showSparrow('stg');};}
		}
	}
	
	if (document.referrer.indexOf('/contacts/index.aspx')!= -1){
		if($('tabTitle_6')){activateTab( 6 );}
	}
	else{};

/*End of onload*/

});

function showRowSelected( oRow, status ) {

	switch ( status ) { 
	   case "on" : 
	   	  mnlRowBackground 			 = oRow.style.backgroundColor;
	   	  oRow.style.backgroundColor = '#FFFFD2'; 
	   	  oRow.style.cursor 		 = 'pointer';
	      break;
	   case "off" : 
	   	  oRow.style.backgroundColor = mnlRowBackground;
	   	  oRow.style.cursor			 = 'none';
	      break;
	}
}