// JavaScript Document - Last modified 25/06/09  - Delphine Lepers

///\brief Functions launched when DOM is ready

window.addEvent('domready', function() {

/* If mainpage, run the slideshow*/
	
		if(document.URL.indexOf('/main/index.aspx')!=-1){
		///\brief Run slideshow on the main product landing page
			runSlideShow()
		};

/* Initiate the tips class*/
	new Tips($$('.tip'));
/*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();};
	}


	
///\brief Initiate the omniture tags
		var locale = wep.locale;
		if(s.prop8){var modelname=s.prop8};
		
///\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 Specific Behaviour for GV-HD700E : product page but just the manual tab
		if(modelname){if (modelname== "GV-HD700E") {activateTab( 3 ); getModelManuals( 'GV-HD700E', 'fr', 'PV', 'DVH' )};}
	
	
///\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*/		
});



///\brief Retrives the manuals when we enter a model name*/

function showModelPage(where){

	var theModel = $( where ).value;

	var myRequest = new Request({
								method: 'get', 
								url: "/shared/code/SupportWebServs.asmx/getModelPage?site=odw_" + wep.locale + "&m=" + theModel,
								onSuccess:function(text, xml) {
									if(document.URL.indexOf('/repair/index.aspx?site')==-1){
										document.location = xml.getElementsByTagName( 'string' )[0].childNodes[0].nodeValue; 
										//If we are on the repair landing page we check if the url sent contains manuals	
									}else{
										//if it does not contain manual we go to the product page
										if(xml.getElementsByTagName( 'string' )[0].childNodes[0].nodeValue.indexOf('manuals')==-1){
											document.location = xml.getElementsByTagName( 'string' )[0].childNodes[0].nodeValue;
											//if it does contain manual we go to the repair request page
										}else{ document.location = '/repair/request/index.aspx?locale='+wep.locale+'&modelId='+theModel;}
									}

								},
								onFailure: function(text, xml) {
									document.location = text.responseText;
								}
							});
	
	myRequest.send(null);}

	

function showContactPage(){
	var theModel = $('contactSearch').value;
	var myRequest = new Request({
								method: 'get', 
								url: "/shared/code/SupportWebServs.asmx/getModelPage?site=odw_" + wep.locale + "&m=" + theModel,
								onSuccess:function(text, xml) {
									var newurl = xml.getElementsByTagName( 'string' )[0].childNodes[0].nodeValue;
									if(newurl.indexOf('/main/error.aspx')!=-1 || newurl.indexOf('/manuals/index.aspx')!=-1){
										$('search_results').addClass('openresults');
										getContactDetails();
										
									}else{document.location=newurl;}
								},
								onFailure: function(text, xml) {alertBox.alert('Failed loading the data');
									document.location = text.responseText;
								}
							});
	
	myRequest.send(null);
	if(wep.locale=='ro_RO' || wep.locale=='hu_HU' ||wep.locale=='cs_CZ'){
			$('chat_results').removeClass('hidden');
			insert_smartbut();
	}
}


function getContactDetails(){
		var req = new Request.HTML({url:'/contacts/contacts_cic.aspx?site=odw_'+wep.locale, 
		onSuccess: function(html) {
			//Clear the text currently inside the results div.
			$('search_results').set('text', '');
			btn_close = new Element('img');
	//	not working with ie6	btn_close.set({src:'/css/imgs/consumer/ssp-icon-minimize.gif',class:'right'});
			btn_close.set('src','/css/imgs/consumer/ssp-icon-minimize.gif');
			btn_close.set('id','contact_results_btn');
			btn_close.addEvent("click",function(e){
					$('search_results').removeClass('openresults');
					$('search_results').empty();
					btn_close.dispose();
			});
			$('search_results').adopt(btn_close);
				//Inject the new DOM elements into the results div.
			$('search_results').adopt(html);
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('search_results').set('text', 'The request failed.');
		}
	});
		req.send(null);
}


///\brief Used in the Product page. Shows the content of a tab box when the tab is clicked.

function activateTab( thisId ) {
		var maxTabs = 6;
		var tabName = new Array( "none", "general", "specifications", "manuals", "compatibility", "repair", "contact" );
		activeTab=tabName[thisId];

		for( i = 1; i <= maxTabs; i++ ){ 
			if ( $( 'tabTitle_' + i ) ){$( 'tabTitle_' + i ).className = 'tab-nav-item';}
			$( 'tabTitle_' + thisId ).className = 'tab-nav-item tab-active';}
		
		for( i = 1; i <= maxTabs; i++ ){
			if ( $( 'section_' + i ) ){$( 'section_' + i ).className = 'tab-box-content sectionDeactivated';}
			$( 'section_' + thisId ).className = 'tab-box-content sectionActivated';
			}
		
	}


function getModelManuals( model, lang, mainCat, subCat ) {

		var theSection = $( "divManTable" );
		var myRequest = new Request({
									method: 'get',
									url:"/shared/code/supportwebservs.asmx/getManualsList?cat=" + mainCat + "&subCat=" + subCat + "&model=" + model + "&l=" + lang,
									onRequest:waitImg(),
									onSuccess:function(text, xml) { 
										theSection.innerHTML = xml.getElementsByTagName( 'string' )[0].childNodes[0].nodeValue;
										document.body.style.cursor='default';
										var thelinks = $$('.manual-table a')
										thelinks.each(function(lien,i){
											lien.setAttribute("target","_blank");
											lien.onclick=function(){
											pageTracker._trackPageview( '/Manuals/Downloads/' + mainCat + '/' + subCat + '/' + model + '/' + lien.href );
											}		  
										})
									},
									onFailure: function(text, xml) {theSection.innerHTML="An error occurred during the treatment.";}
								});
		myRequest.send(null);
	

	}	

function waitImg(){
	var my_img = new Element ( 'img' , { 'src' : '/dl_img/wait.gif'});
	my_img.injectInside($('divManTable'));
	document.body.style.cursor='wait';
	}

///\brief Check the validity of the feedback before sending it - Should be optimised
function sendFeedback( position ) {
	var rating = -1;
	var txtCom = '';
	var txtTab = '';
	if ( typeof ActivDiv == 'undefined'){ActivDiv = ""}
	if ( typeof activeTab == 'undefined'){activeTab = ""}
	
	if ( position == 'left' ) {
		var rates = $('feedbackLeft').options;
		var rating = rates [rates .selectedIndex].value;
		txtCom = $( 'fbl_txt' ).value; 
		if ( rating != -1 ) $( 'fbl_txt' ).value = '';
	} 
	
	else if ( position == 'bottom' ) {
		var rates = $('feedbackBott').options;
		var rating = rates [rates .selectedIndex].value;
		txtCom = $( 'fbb_txt2' ).value;
		if ( rating != -1 ) $( 'fbb_txt2' ).value = '';
	}

	if ( rating != -1 ) {	
		if ( $defined($( 'activeTab' )) ) {
				txtTab = $( 'activeTab' ).value;
			}else if($defined(activeTab)){
				txtTab=activeTab;
			}else {txtTab="NoTabClicked"};
			
		storeFBInfoInDB(rating, txtCom, txtTab );
		
		// Hide the feedback in order to avoid multiple submits 
		if ( $( 'feedbackBox' ) ) { $( 'feedbackBox' ).style.display = 'none';}
		if ( $( 'feedbackBottomBox' ) ) {$( 'feedbackBottomBox' ).style.display = 'none';}
		
	} else {
		alertBox.alert( "Please select an option" );
	}
	return false;
}

///\brief Function used to store the results of the survey in the database.
function storeSurveyResult(owner,theRating){
	var myRequest = new Request({
								method:'get',
								url: '/shared/code/supportwebservs.asmx/storeSurveyData?owner=' + owner + theRating + "&locale=" + wep.locale,
								onSuccess:function(text,xml){
									var txt = xml.getElementsByTagName( 'boolean' )[0].childNodes[0].nodeValue;
									}
								});
	myRequest.send(null);

	}

///\brief Sends feedback to the database
function storeFBInfoInDB(theRating, theComments, theActiveTab ) {
	var myRequest = new Request({
								method:'get',
								url:'/shared/code/supportwebservs.asmx/storeFeedbackData?theLocation=' + escape( document.location ) + '&theRating=' + theRating +'&theComments=' + theComments + '&theActiveTab=' + theActiveTab + '&theModel=',
								onSuccess:function(text,xml){
									var txt = xml.getElementsByTagName( 'boolean' )[0].childNodes[0].nodeValue;
									}
								});
	myRequest.send(null);

}

///\brief reloads the contact page when the product type has been chosen
/* Obsolete
function CallMe(control,site){
	var Types = document.theForm.selType.options;
	var Type = Types [Types .selectedIndex].value;
	window.parent.location= "/contacts/index.aspx" + "?site=" + site + "&tp=" + Type;}


///\brief reloads the contact page when the country has been chosen	
function CallMeAgain(control,site){
	var Types = document.theForm.selType.options;
	var Type = Types [Types .selectedIndex].value;
	var Countries = document.theForm.selCountry.options;
	var Country = Countries[Countries .selectedIndex].value;
	window.parent.location= "/contacts/index.aspx" + "?site=" + site + "&tp=" + Type + "&cn=" + Country;}
*/


///\brief  Function used in ??

function swapImages( obj, img1, img2, altTxtImg1, altTxtImg2 ){
    
    objImg = obj.src
    currentImg = objImg.substr( objImg.lastIndexOf("/") + 1 );
    
    if ( currentImg == img1 ) {
        obj.src = objImg.substr( 0, objImg.lastIndexOf("/") + 1 ) + img2;
        obj.alt = altTxtImg2;
    } else {
        obj.src = objImg.substr( 0, objImg.lastIndexOf("/") + 1 ) + img1;
        obj.alt = altTxtImg1;
    }
    
}
///\brief   Function used in ??
function showHideSpan( objSpan ){
	
	theSpan = $( objSpan );
	theSpan.style.display = ( ( theSpan.style.display == "block" ) ? "none" : "block" );}

///\brief   Function used in the left menu to change country
function ChangeSite( CurrentSite, NewSite ) {
	var CurrentPage = window.location.href;
	var NewPage;
	var reg;

	if (NewSite.value) {var SiteRepl = NewSite.value;}
	else {var SiteRepl = NewSite;}	
	
	/* Additionnal check for when a , is added in front of the site parameter */
	if ( CurrentPage.indexOf( "?site=," ) != -1 ) {
		reg = /\?site=,odw_[a-z]{2}_[A-Z]{2}/i;
		NewPage = CurrentPage.replace( reg, '?site=' + SiteRepl );
	}
	else if ( CurrentPage.indexOf( "?site=" ) != -1 ) {
		reg = /\?site=odw_[a-z]{2}_[A-Z]{2}/i;
		NewPage = CurrentPage.replace( reg, '?site=' + SiteRepl );
	}	
	else if ( CurrentPage.indexOf( "&site=" ) != -1 ) {
		reg = /&site=odw_[a-z]{2}_[A-Z]{2}/i;
		NewPage = CurrentPage.replace( reg, '&site=' + SiteRepl );
	}
	else {
		// var NewPage = CurrentPage + "l=" + LangRepl;
		if ( CurrentPage.indexOf( "?" ) != -1 ) {
			NewPage = CurrentPage.replace( "?", "?site=" + SiteRepl + "&" );
		}
		else {
			NewPage = CurrentPage + "?site=" + SiteRepl;
		}
	}
	Cookie.write('site', SiteRepl, {duration: 365});

	window.location = NewPage;
}

///\brief   Function that creates cookie- Has been replaced with mootools cookie.write

function createCookie(name,value,days){
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";}

///\brief   Function that reads the cookies, Has been replaced with mootools 
function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;}

///\brief   Function that erases cookies, Has been replaced with mootools Cookie.dispose
function eraseCookie(name){
	createCookie(name,"",-1);}

///\brief   Function used in the contact page to display the help box
function showHideHelp( objSpan, status ){

	var theSpan = $( objSpan );
	
	if ( status == 1 ) {
		var x = 0;
		var y = 0;
		var theRef  = $( 'selType' );
		var element = theRef;

		while ( element ) {
			x += element[ 'offsetLeft' ];
			y += element[ 'offsetTop' ];
			element = element.offsetParent;
		}
		
		theSpan.style.left = x + 'px';
		theSpan.style.top  = y + ( theRef.offsetHeight * 3 ) + 'px';
		theSpan.style.display = "block";
	} 
	else {
		theSpan.style.display = "none";
	}
}	


///\brief   Fonction used in the compatibility pages to show the table depending on the model selected /*<select id="selModel" onchange="changeModel( '{$site}', this.value,'{$pathurl}' );">*/*/
function changeModel( site, model, linkP ) {
				window.location = linkP+'?site=' + site + '&m=' + model;
			}



///\brief  Function used in the hotnews dna/hotnews/hotnews.aspx?site=&m=&f=nwz_s7x_announcement to check serial */

function check_wm_serial(model, serial){
	var affected = "Please contact our Customer Information Center, when the headphones supplied with WALKMAN have these symptoms. Sony will replace the damaged headphones with new ones without charge.";
	var not_affected = "Your WALKMAN is not affected by this issue. You can continue enjoying your WALKMAN.";
	var wm_message = $("wm_message");
	
	if (serial.length < 7) wm_message.value = "The serial number must contain 7 digits.";
	else if (model == "NWZ-S738F" && serial >= "5000001" && serial <= "5031355") wm_message.value = affected;
	else if (model == "NWZ-S739F" && serial >= "5000001" && serial <= "5014255") wm_message.value = affected;
	else wm_message.value = not_affected;
}


///\brief  Function used in the FAQs display*/

function toggleFAQSection( oSectionHeader, sectionId ){

	// -- Toggle the images +/-
	with ( $( 'img_' + sectionId ) ) 
		src = ( src.indexOf( 'plus.gif' ) > -1 ) ? '/images/tables/book_minus.gif' : '/images/tables/book_plus.gif';
	
    // Highlight the section's text if necessary
    oSectionHeader.className = oSectionHeader.className == 'faq_secHeader' ? 'faq_secHeader_bold' : 'faq_secHeader';
    
    // -- Show/Hide the span    
	var oSpan = $( 'section_' + sectionId );
	
	oSpan.style.display = ( ( oSpan.style.display == 'block' ) ? 'none' : 'block' );}
	
///\brief   used in ?
function ToggleSpanImg( spanObj, imgObj ){ 

	var theSpan = $( spanObj );
	var theImg	= $( imgObj );
	
	// -- Toggle the +/- image
	var theSrc = theImg.src
	if ( theSrc.substr( theSrc.length - 10 ) == 'icon_+.gif' ) {
		theImg.src = theSrc.substring( 0, theSrc.lastIndexOf( 'icon_+.gif' ) ) + 'icon_-.gif';
	} else {
		theImg.src = theSrc.substring( 0, theSrc.lastIndexOf( 'icon_-.gif' ) ) + 'icon_+.gif';
	}
	
	// Show/hide the span
	// theSpan.style.display == "block" ? theSpan.style.display = "none" : theSpan.style.display = "block"
	theSpan.style.display = theSpan.style.display == "block" ? "none" : "block";
}

///\brief Function used in dime/compatibility/dsr/dsr_flash/flash.aspx?site=voe_en_GB_cons&m=DSLR-A200#endofpage*/
function toggleFlashComp( spanObj ){ 
	spanTags=$$('.lensDetails');
	spanTag = $(spanObj); 
	spans = $$('');
	for ( var i = 0; i < spanTags.length; i++ ) { 
		spanTags[i].style.display = "none";
	}

	var theSpan = $( spanObj );
	theSpan.style.display == "block" ? theSpan.style.display = "none" : theSpan.style.display = "block"
}	

///\brief   Function used in the downlads pages (cf http://43.221.4.12/dime/downloads/downloads.aspx?site=odw_en_GB&m=HDR-CX7E&f=PMB_V3300 */ 

function dnld(loc){
	if ($('conditionsbox').checked==1){
		show('backupsol');
		window.open(loc,'mywindow','width=430,height=350');
		return false;
	}else{
		alertBox.alert(agreetxt);
		return false;
	};
}

///\brief   Function used in the multiple downlads pages (cf http://43.221.4.12/TV/downloads/downloads.aspx?site=odw_de_DE&f=LFA */ 

function dnld_mult(loc,n){
	var boxes = $$('.conditionsboxes');
	var backups = $$('.backupsol');
		if (boxes[n-1].checked==1){
			window.open(loc,'mywindow','width=430,height=350');
			show(backups[n-1]);
			return false;
		}else{
			alertBox.alert(agreetxt);
			return false;
		};
}
	
///\brief   Function used to show or hide sections in the tutorials with buttons and lists of links showing subdivs*/	
function hideAndToggle(){
	
		//target subelements
		var list = $$('.subdiv');
		//target above elements
		var suplist = $$('.supdiv');	
		//list of 'a' to be clicked on
		var headings = $$('.bularw');
		var imgheadings = $$('.settingsmenu');

		//array to store all of the collapsibles
		var solutions = new Array();
		var solsuplist = new Array();
		
		headings.each( function(heading, i) {
				//for each element create a slide effect
				var collapsible = new Fx.Slide(list[i], {
						duration: 400,
						transition: Fx.Transitions.Pow.easeOut
				});
		
				//save the solutions effects
				solutions[i] = collapsible;
				
				//add event listener
				heading.onclick = function(){
						collapsible.show();
						for(var j = 0; j < solutions.length; j++){
							if(j!=i) solutions[j].hide();
						}
						return false;
				}
				//collapse all solutions
				collapsible.hide();
		});
		
		imgheadings.each( function(imgheading, k) {
				//for each element create a slide effect
				var collapsuplist = new Fx.Slide(suplist[k], {
						duration: 400,
						transition: Fx.Transitions.Pow.easeOut
				});
		
				//save the solutions effects
				solsuplist[k] = collapsuplist;
				//collapse all solutions
				collapsuplist.hide();
				//add event listener
				imgheading.onclick = function(){
						collapsuplist.show();
						for(var l = 0; l < solsuplist.length; l++){
							if(l!=k) solsuplist[l].hide();
						}
						for(var l = 0; l < solutions.length; l++){
							if(l!=k) solutions[l].hide();
						}
						return false;
				}
			
		});	
	
	
}



///\brief  
function show(target){
	theDiv = $(target);
	theDiv.style.display == "block" ? theDiv.style.display = "none" : theDiv.style.display = "block"
	}
///\brief  
function hideallcontent() {
	var divs = document.getElementsByTagName("div");
	for (var i=0;i<divs.length;i++) {
		if ((divs[i].id.substr(0,3)=="ddc") && divs[i].style.display=="") {
			hide(divs[i]);
		}
	}
}
///\brief  
function inittogglers(){
	var source = $$('.toggler');
	var target = $$('.toggled');
	var temptable = new Array();
	
	source.each( function(linktoggler, i) {

		var placer = new Fx.Slide(target[i], {
			duration: 400,
			transition: Fx.Transitions.Pow.easeOut
		});
		
				//save the solutions effects
		temptable[i] = placer;
			
		//add event listener
		linktoggler.onclick = function(){
			placer.show();
			target[i].setStyle('height','700px');
			for(var j = 0; j < temptable.length; j++){
				if(j!=i) temptable[j].hide();
			}
		return false;
		}
		placer.hide();
		});
		  
						  
	}

///\brief   hides the bif divs in the videotransfer tutorial*/
function hideVideos(){
	
		var source = $$('.togglerVid');
		var target = $$('.toggledVid');	
		
		source.each( function(linktoggler, i) {
							
			linktoggler.onclick = function(){
			for(var j = 0; j < target.length; j++){
				
					target[j].setStyle('display','none');
				}
				show(target[i]);
				return false;
			
			}
		});		
	
	}

///\brief  OBSOLETE 
function disappear(obj){
	
	//alert(obj.id);
	
	var NS6 = (!document.all && document.getElementById)?true:false;
	var IE  = ((document.all)&&(navigator.appVersion.indexOf("MSIE"!=-1)))?true:false;
	var m=0;
	var k = 0;
	var pos = 0;
	var j = 0;
	
	//if (IE || NS6){
		var spanTags = "";
		spanTags = document.getElementsByTagName( 'span' ); 
		var spans = new Array();
			
		for (var i = 0; i < spanTags.length; i++ ) { 
			if ((spanTags[i].id != "" )&& (spanTags[i].id.indexOf('item')!= -1)){
				spans[m] = spanTags[i];
				m  = m + 1;
			}
		}
		m = 0;
		for (var j = 0; j < spans.length; j ++){
			//if (spans[j].id == document.getElementById(obj).id){
			if (spans[j].id == obj.id){
				var pos = 0;
				pos = j;
				break;
			}	
		}
	
		j = 0;

		for ( var k = 0; k < spans.length; k++) { 
			if (k == pos) {
				if (spans[k].style.display == 'none'){
					spans[k].style.display = '';
				} else if (spans[k].style.display == ''){
					spans[k].style.display = 'none'	;
				}	
			}else{
				if (spans[k].style.display == ''){
					spans[k].style.display = 'none'	;
				}
			}	
		} 
 	//}
}
///\brief  
function clearFBtextbox( txtTheFeedback ) 
{
	var oFBComments = $( txtTheFeedback )
	if ( oFBComments.value.replace(/^\s+|\s+$/g, '') == '' )  // just TRIM the string to see if it is empty
		oFBComments.value = '';
}

///\brief  REPLACED WITH MOOTOOLS - OBSOLETE
function getHttpRequest() 
{
	try {
		return new XMLHttpRequest(); }
	catch ( tryMicrosoft ) {
		try {
			return new ActiveXObject( "Msxml2.XMLHTTP" ); }	
		catch ( otherMicrosoft ) {
			try {
				return new ActiveXObject( "Microsoft.XMLHTTP" ); }
			catch ( failed ) {
				return false;
			}
		}
	}
}

///\brief  Initiate the value of activDiv- used for the feedback  TO BE RAPPATRIATED
function SetActivDIV(name){
	ActivDiv = name;
	}

///\brief  used in that page http://support.sony-europe.com/dime/faq/faq.aspx?site=odw_en_GB&m=DSLR-A200&f=DI_DSLR_A
function showFAQs( theOption, theLanguage ) {

	var theParams = theOption.split( '|' );
	var theLoc	  = 'faq.aspx?site=' + odw + '&sc=' + theParams[0];
	if ( theParams[1] && theParams[1] != '' ) {theLoc += '&m=' + theParams[1];}
	if ( theParams[2] && theParams[2] != '' ) {theLoc += '&f=' + theParams[2];}
	location.href = theLoc;
}




/* Function used on the contact page*/
function insert_smartbut(){
  $('smartimg').innerHTML='&nbsp;<img src="http://rs.instantservice.com/resources/smartbutton/6058/22636/available.gif?' + 
    Math.floor(Math.random()*10001) + '" style="width:0;height:0;visibility:hidden;position:absolute;"' + ' onLoad="agents_available()" onError="agents_not_available()">';}

function agents_available(){    

	var theChatURL ='';
	odw = location.href.substring(location.href.lastIndexOf('site')+9,location.href.lastIndexOf('site')+14);

	switch(wep.locale){
		case 'ro_RO' : theChatURL = "/contacts/chat/chat.aspx?site=odw_ro_RO"; break;
		case 'cs_CZ' : theChatURL = "/contacts/chat/chat.aspx?site=odw_cs_CZ"; break;
		case 'hu_HU' : theChatURL = "/contacts/chat/chat.aspx?site=odw_hu_HU"; break;
		default : theChatURL = '';
		};
		
	$('smartbutton').set('html','<img src="https://admin.instantservice.com/brands/instantservice/images/clickhere.gif" onclick="javascript:window.open(\''+theChatURL+'\',\'_blank\',\'menubar=no, status=no, width=600,height=600\'); return false;">');
return true; } 
   
  // IF AGENTS ARE NOT AVAILABLE:
function agents_not_available(){
	
	var theSentence ='';
	switch(wep.locale){
		case 'ro_RO' : theSentence = "Nici un agent nu este disponibil &#238;n acest moment.<br/>Va rugam sa ne trimiteti <a href=\"/contacts/email/email.aspx?site="+ odw +"\">ane-mail</a>.<br/>"; break;
		case 'cs_CZ' : theSentence = "Jelenleg minden oper&#225;torunk foglalt.<br/>K&#233;rj&#252;k, k&#252;ldj&#246;n <a href=\"/contacts/email/email.aspx?site="+ odw +"\">emailt.</a><br/>"; break;
		case 'hu_HU' : theSentence = "Omlouv&#225;me se, ale &#382;&#225;dn&#237; pracovn&#237;ci nejsou moment&#225;lne k dispozici.<br/>Pros&#237;m, za&#353;lete n&#225;m <a href=\"/contacts/email/email.aspx?site="+ odw +"\">e-mail.</a><br/>"; break;
		default : theSentence = '';
		};	
   $('smartbutton').set('html',theSentence);
   return true;
  }
  
///\brief  Allows to change the language for countries with several lg 
function changeLANG(){
	  		var CurrentPage = window.location.href;
			var NewPage;
			var reg;
		
			if (wep.locale=='fr_BE') {var SiteRepl = 'odw_nl_BE';}
			else if (wep.locale=='nl_BE') {var SiteRepl = 'odw_fr_BE';}
			else if (wep.locale=='de_LU') {var SiteRepl = 'odw_fr_LU';}
			else if (wep.locale=='fr_LU') {var SiteRepl = 'odw_de_LU';}
			else if (wep.locale=='de_CH') {var SiteRepl = 'odw_fr_CH';}
			else if (wep.locale=='fr_CH') {var SiteRepl = 'odw_de_CH';}
			
			/* Additionnal check for when a , is added in front of the site parameter */
			if ( CurrentPage.indexOf( "?site=," ) != -1 ) {
				reg = /\?site=,odw_[a-z]{2}_[A-Z]{2}/i;
				NewPage = CurrentPage.replace( reg, '?site=' + SiteRepl );
			}
			else if ( CurrentPage.indexOf( "?site=" ) != -1 ) {
				reg = /\?site=odw_[a-z]{2}_[A-Z]{2}/i;
				NewPage = CurrentPage.replace( reg, '?site=' + SiteRepl );
			}	
			else if ( CurrentPage.indexOf( "&site=" ) != -1 ) {
				reg = /&site=odw_[a-z]{2}_[A-Z]{2}/i;
				NewPage = CurrentPage.replace( reg, '&site=' + SiteRepl );
			}
			else {
				// var NewPage = CurrentPage + "l=" + LangRepl;
				if ( CurrentPage.indexOf( "?" ) != -1 ) {
					NewPage = CurrentPage.replace( "?", "?site=" + SiteRepl + "&" );
				}
				else {
					NewPage = CurrentPage + "?site=" + SiteRepl;
				}
			}
			Cookie.write('site', SiteRepl, {duration: 365});
		
			window.location = NewPage;
			}
		