// 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;

			}				  
	});
	pageTracker._trackPageview('/general/ModelPage/'+wep.locale+'/'+model_used);
	if(model_used!=''){pageTracker._trackPageview('/Models/'+manMainCat+'/'+manSubCat+'/'+manModel)};

///\brief Specific Behaviour for GV-HD700E : product page but just the manual tab

//	if (s.prop8== "GV-HD700E") {activateTab( 3 ); getModelManuals( 'GV-HD700E', 'fr', 'PV', 'DVH' );}
	if (s.prop23=="MAN"){getModelManuals( manModel, s.prop3, manMainCat, manSubCat );activateTab( 3 );}


/*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*/

});

