// au changement de langue on redirige
function setLanguage(language,path)
	{
	if(language != '')
		{
		if(language == 'eu')
			{ window.location = path+'../en/index.php'; }
		else if(language == 'af')
			{ window.location = path+'../af/index.php?l=af'; }
		else if(language == 'me')
			{ window.location = path+'../me/index.php?l=me'; }
		else if(language == 'be-fr')
			{ window.location = path+'../be-fr/index.php?l=be-fr'; }
		else if(language == 'be-nl')
			{ window.location = path+'../be-nl/index.php?l=be-nl'; }	
		}
	}
	
// affiche / cache	
	function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

// Pour la recherche globale
function clear_input(id,string)
	{ 
	if(document.getElementById(id).value == string)
		{ 
		document.getElementById(id).value = ""; 
		document.getElementById(id).className = 'input_search_on';
		}
	}

function reset_input(id,string)
	{
	if(document.getElementById(id).value == "")
		{ 
		document.getElementById(id).value = string; 
		document.getElementById(id).className = 'input_search';
		}
	}

function submit_search(id,string)
{
if(document.getElementById(id).value == '' || document.getElementById(id).value == string)
	{ return false; }
}

// cache le message de retour
function hide_content(id)
	{
	$("#"+id).fadeOut("fast");
	}
// affiche le message de retour
function show_content(id,message)
	{
	$(function() {
		document.getElementById(id+"_content").innerHTML = message;
		$("#"+id).fadeIn("fast");
		});

	}
/////////////////////////////////////////////////////////

//recherche dans un tableau
function in_array(array, p_val) {
    for(var i = 0, l = array.length; i < l; i++) {
        if(array[i] == p_val) {
            rowid = i;
            return true;
        }
    }
    return false;
}

//scroll sur la page
function myscroll(id)
	{ $.scrollTo( '#'+id, 600 ); }

function my_nyromodal_manual(my_url)
{
$.nyroModalManual({
             url : my_url
       });
	return false;
}

// verifie la validite d'un email
function VerificationEmail(elm)
{
var error = 0;
if ((elm.indexOf('@',0)==-1) || (elm.indexOf('.',0)==-1)) 
	{ error = 1; }
	
var nb_arob = substr_count (elm,"@");
if(nb_arob > 1)
	{ error = 1; }

if(!elm.match('^[-_\.0-9a-zA-Z]{1,}@[-_\.0-9a-zA-Z]{1,}[\.][0-9a-zA-Z]{2,}$')) 
	{ error = 1; }

if(error == 1)
	{ return false; }
else
	{ return true; }
}

function substr_count( haystack, needle, offset, length ) {
	 
    var pos = 0, cnt = 0;
 
    if(isNaN(offset)) offset = 0;
    if(isNaN(length)) length = 0;
    offset--;
 
    while( (offset = haystack.indexOf(needle, offset+1)) != -1 ){
        if(length > 0 && (offset+needle.length) > length){
            return false;
        } else{
            cnt++;
        }
    }
 
    return cnt;
}
////////////////////////////////////////////////////////////	

/********************************************************************/
// ABOUT US

// Contact

// change le détails des pays
function change_details(){
	var xhr_object = null; 
	var country = document.form_contact.country.value;
	   
	if(window.XMLHttpRequest) // Firefox 
		xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		return; 
	}
	
	xhr_object.open("POST", "../../common/aboutus/contact-details.php", true); 
	     
	xhr_object.onreadystatechange = function() { 
		if(xhr_object.readyState == 4){
			var result = xhr_object.responseText;
			document.getElementById("contact_details").innerHTML = result;
		}
	} 
	
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
	var data = "country="+country; 
	xhr_object.send(data); 
} 

// pour afficher le détails d'une réclamation
function get_glaim(value){
	if(value == 'Claims' || value =='Reclamation' || value=='Anspruch' || value=='Reclamo')
		{ document.getElementById('hidden_claim').style.display = 'block'; }
	else
		{ document.getElementById('hidden_claim').style.display = 'none'; }
}

// recupère la liste des produits
function get_product(){
	var f = document.form_contact;
	var f_name = "form_contact";
	var l1    = f.elements["id_category"]; 
	var l2    = f.elements["id_product"]; 
	var index = l1.selectedIndex; 

	if(index < 1) 
		l2.options.length = 0; 

	else { 
		var xhr_object = null; 
		     
		if(window.XMLHttpRequest) // Firefox 
			xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			return; 
		} 
		 
		xhr_object.open("POST", "../../common/aboutus/contact-get-product.php", true); 
		     
		xhr_object.onreadystatechange = function() { 
			if(xhr_object.readyState == 4){
				$("#id_product").html(xhr_object.responseText);
			}
		} 
		 
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
		var data = "id_category="+escape(l1.options[index].value); 
		xhr_object.send(data); 
	} 
}
/********************************************************************/


// PRODUITS

/** DIVERS *****************************************/
//confirm delete
function confirm_delete_generique(message){
	if(!confirm(message))
		{ return false; }
}

