// JavaScript Document
///\brief Functions launched when DOM is ready

window.addEvent('domready', function() {

		if($('frm-search')){$('frm-search').setStyle('display','block');}
		if($('feedbackBox')){$('feedbackBox').setStyle('display','block');}
		new Tips($$('.tip'));
		if($$('.faq')){faqlaunch();}
/*Used in the download pages to hide only if there is javascript*/	
		if($$('.dl_sections')){$$('.dl_sections').set('style','display:none');}		
/*function used by the NPS survey */
function openSurvey(){
		odw=location.href.substring(location.href.lastIndexOf("site")+5);
		myWin=window.open ('/contacts/participate.aspx?site='+odw,"Participate","menubar=no, status=no, scrollbars=no, width=440, height=300");	
		Cookie.write('survey', 'y', {duration: 365, path: '/'});	
		 }
	
	if(Cookie.read('survey')=='y'){
			//do nothing
	}else{
		if(location.href.lastIndexOf("temp=kasa")==-1){	
			openSurvey();};
}

function faqlaunch(){
	var questions = $$('.faq h4');
	var answers = $$('.faq .response');
	questions.each(function(h4,i){
				answers[i].setStyle('display','none');
				h4.setStyle('cursor','pointer');
				var status=0;
				h4.addEvent("click",function(e){
					if(status==0){
						answers[i].setStyle('display','block');
						h4.set('class','faq_open');
						status=1;
						pageTracker._trackPageview( '/FAQ/'+s.prop2+'/'+model_used+'/'+s.pageName.replace(/\s+/g,'')+'/'+(i+1));
					}else{
						answers[i].setStyle('display','none');
						h4.erase('class');
						status=0;
					}
			});
		});
	}
if(!(Browser.Engine.name=="trident" && Browser.Engine.version=="4")) {InitTabNav();};
///\brief Initiate the omniture tags
		var locale = wep.locale;
		if(model_used){var modelname=model_used};
		
///\brief if belgium, offer the alternat language
		if($('lg_change')){
			$('lg_change').addEvent('click', function(e){
				changeLANG();	
				return false;
				});
		}

///\brief Initialize the function allowing to show the manuals when we enter a model name*/
		if($('globalModelSearch')){acGeneral = new AC(	'globalModelSearch', 'globalModelSearch', 'showModelPage("globalModelSearch")');}
///\brief  Initialize the function allowing to show the manuals if the user click on the GO button*/
		if($('globalModelSearch')){
			$('frm-search').addEvent('submit', function(e){
				showModelPage("globalModelSearch" );	
				return false;
			});
			$('globalModelSearch').setAttribute("autocomplete","off");
			}
///\brief Initialize the function allowing to show the contact details when we enter a model name on the contact page*/		
		if($('contactSearch')){acGeneral = new AC('contactSearch','contactSearch','showContactPage()');}
		if($('contactSearch')){
			$('contactSearch').setAttribute("autocomplete","off");
			if(wep.locale!='pl_PL'){
				$('contactSearch').addEvent('focus',function(e){
					$('search_results').removeClass('openresults');
					$('search_results').empty();
				});
			};
			$('contactSearch').addEvent('submit',function(e){
				showContactPage();
				return false;
			});
		};
		
///\brief  Initialize the function allowing to show the manuals when clicking the recently viewed*/
		if($('RV1')){
			$('RV1').addEvent('click', function(e){
				showModelPage($('RV1id') );	
				return false;
				});
			}	
			
	
///\brief Initialize the function allowing to show the repair tab when we enter a model name in the repair searchox (for the moment it is the same as for the model name*/
		if($('globalRepairSearch')){acGeneral = new AC(	'globalModelSearch', 'globalModelSearch', 'showModelPage("globalModelSearch" )');}


		///\brief allow to retrieve the manuals when the manuals tab is clicked */
		if($('selMainCat')){ac1 = new AC( 'searchModelName', 'searchModelName', 'showManualsForModel( "", wep.locale)' );}
		

///\brief If there is .settingmenuhover class launch the scripts that hide the information and add the click / show / hide of sections*/
		if($('troubleshoot')){hideAndToggle();}
		
///\brief Specific for videotransfet tutorial (DIME/Tutorials*/	
		if($('videotrans')){ 
			hideAndToggle(); 
			hideVideos();
			};
		
		if($('BDP_out')){hideVideos();};
		
///\brief On the contact page If the second select box already exists (country select box) and there is no cn variable, automatically call the CallMeAgain function
		if ((document.URL.indexOf('cn=')==-1) && document.URL.indexOf('/contacts/index.aspx')!=-1){ 
			if($('selCountry')){
				CallMeAgain( this, "odw_"+wep.locale);
			}
		};
/* End of onload scripts*/		
});		