// JavaScript Document
var map,zoom=1,toload=0

function call(to_call){
	eval(to_call);
}
function showRoyal(){

	cur = $('current_blind').value;
	if(cur=="Partner")
	{
		Effect.BlindUp(cur);
		$('current_blind').value="";
		return;
	}
	Effect.BlindDown('Partner');

	if(cur!="") Effect.BlindUp(cur);
	$('current_blind').value= "Partner";
	document.getElementById('blockPartner').style.display="block";		
}
function showMenu(id)
{
	cur = $('current_blind').value;
	if(cur==id)
	{
		Effect.BlindUp(cur);
		$('current_blind').value="";
		return;
	}

	Effect.BlindDown(id);

	if(cur!="") Effect.BlindUp(cur);
	$('current_blind').value= id;
//	document.getElementById('blockPartner').style.display="block";		
}

function showStock(){


	cur = $('current_blind').value;
	if(cur=="Stock")
	{
		Effect.BlindUp(cur);
		$('current_blind').value="";
		return;
	}	
	Effect.BlindDown('Stock');
	if(cur!="") Effect.BlindUp(cur);
	$('current_blind').value= "Stock";
	document.getElementById('block').style.display="block";		
}
function showProduction(show){
	cur = $('current_blind').value;
	if(cur=="Stock")
	{
		Effect.BlindUp(cur);
		$('current_blind').value="";
		return;
	}	
	Effect.BlindDown('Production');
	if(cur!="") Effect.BlindUp(cur);
	$('current_blind').value= "Production";

	document.getElementById('block').style.display="none";	
	if( show=="5"){

		document.getElementById("mycontent").style.display ="none";
	}
}
function showHeader(id)
{
	
	if($('header_'+id))
	{
		$('header_'+id).style.display="inline";

	}
	if($('headerSlogan_'+id))
	{
		//$('SloganText').innerHTML = $('headerSlogan_'+id).innerHTML;		
		$('headerSlogan_'+id).show();
	}

	elem  =	$('current_type').value

	if($('header_'+elem)) $('header_'+elem).hide();
	if($('headerSlogan_'+elem)) $('headerSlogan_'+elem).hide();

	$('current_type').value = id;
}
function ChangeTextColor(elem)
{
	old  = $(elem.id).getStyle("color")
	$(elem.id).setStyle({color: '#FF0000'});

	$(elem.id).setStyle({color_old: old});	

}
function ResetTextColor(elem)
{
	old  = $(elem.id).getStyle("color_old")
	$(elem.id).setStyle({color: old});

}
function showPortfolio(show)
{
	cur = $('current_blind').value;
	if(cur=="Stock")
	{
		Effect.BlindUp(cur);
		$('current_blind').value="";
		return;
	}	
	Effect.BlindDown('Portfolio');

	if(cur!="") Effect.BlindUp(cur);
	$('current_blind').value= "Portfolio";
	document.getElementById('block').style.display="block";	


}
function showWatch()
{
	Effect.BlindDown('Watch');
	cur = $('current_blind').value;

	Effect.BlindUp(cur);
	$('current_blind').value= "Watch";
	document.getElementById('block').style.display="block";	


}
function showSub(id){

	last =document.getElementById('last_famille').value;
	try{
	ok = document.getElementById("real_"+id).innerHTML;
	ok = document.getElementById(id).innerHTML;
	}catch (ex)
	{

		return
	}
	if(last==id){
		Effect.BlindUp('real_' +id);
		//document.getElementById('real_' +id).innerHTML="";
		document.getElementById('last_famille').value="";
		return;
	}
	if(last!=""){
		Effect.BlindUp('real_' +last);
		//document.getElementById('real_' +last).innerHTML="";
	}
	document.getElementById('real_'+id).style.display="none";
	document.getElementById('real_'+id).innerHTML= document.getElementById(id).innerHTML;
	Effect.BlindDown('real_'+id);
	document.getElementById('last_famille').value=id;
	
}

function showImg(artnr,img){

	document.getElementById("Big"+artnr).src = img.src;
}

 //


    function load() {

    }
	function showEParking(){
		map.openInfoWindow(new GLatLng( 50.81498,4.3190909),
                   document.createTextNode("Entrée du parking"));
	}
	function showEntrance(){
		map.openInfoWindow(new GLatLng( 50.814554,4.3209094),
                   document.createTextNode("Entrée bureau"));
	}
	function showParking(){
		map.openInfoWindow(new GLatLng(50.814703,4.320709),
                   document.createTextNode("Parking client"));
	}
	function zoomEParking(){
		map.panTo(new GLatLng(50.81498,4.3190909));
		if( zoom=1){
				map.zoomIn();
		map.zoomIn();
		map.zoomIn();
				map.zoomIn();
		map.zoomIn();
		map.zoomIn();
		zoom=0;
		}
	
	}
	function zoomEntrance(){
		showEntrance();
		map.panTo(new GLatLng(50.814554,4.3209094));
			if( zoom=1){
				map.zoomIn();
		map.zoomIn();
		map.zoomIn();
				map.zoomIn();
		map.zoomIn();
		map.zoomIn();
		zoom=0;
		}
	}
	function zoomParking(){
		 map.panTo(new GLatLng(50.814703,4.320709));
		if( zoom=1){
				map.zoomIn();
		map.zoomIn();
		map.zoomIn();
				map.zoomIn();
		map.zoomIn();
		map.zoomIn();
		zoom=0;
		}
	}		
	function showPic(object)
	{
		$('mainpic').src = object.src;	
	}
	
function validate_form_demande()
{
	erreur=0;
	if(isValid('nom')) erreur=  1 ;
	if(isValid('prenom')) erreur =1 ;
	if(isValid('tel'))erreur =1 ;
	if(isValid('email')) erreur =1 ;
	if(isValid('commentaire')) erreur =1 ;
	if(!IsEmail('email'))	erreur=1;
	if(erreur){
		alert('Please fill all fields.');	
		return false;
		
	}
	return true;
}
function trim(str, chars) {
	chars = " ";
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function IsEmail(elem)
{
		Expression = $(elem).value;
        if (Expression == null)
                return (false);

        var supported = 0;
        if (window.RegExp)
        {
                var tempStr = "a";
                var tempReg = new RegExp(tempStr);
                if (tempReg.test(tempStr)) supported = 1;
        }
        if (!supported)
                return (Expression.indexOf(".") > 2) && (Expression.indexOf("@") > 0);
        var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
        var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");

		if(!r1.test(Expression) && r2.test(Expression)) return true;
		else
		{
			
			$(elem).setStyle({backgroundColor: '#ffd2d2'});
			//$(elem).focus();
		}
        return (!r1.test(Expression) && r2.test(Expression));
}

function validate()
{
	return true;
}
function isValid(elem)
{
	if(trim($(elem).value) =="")
	{
		$(elem).setStyle({backgroundColor: '#ffd2d2'});
		//$(elem).focus();
		return 1;
	}
	$(elem).setStyle({backgroundColor: '#FFFFFF'});	
	return 0;
	
}

function disablepro(elem){
	$("state").disabled = true;
	$("vat").disabled = true;
	$("member").disabled = true;
}
function enablepro(elem){
	$("state").disabled = false;
	$("vat").disabled = false;
	$("member").disabled = false;
}
