function plus(e){
	document.getElementById("plus").style.overflow="visible";
	document.getElementById("plus").style.height="auto";
	e.style.display="none";
}
var ajaxObjects = new Array();
function removeProductFromBasket(productId){
	var productRow = document.getElementById('shoping_cart_items_product' + productId);
	var productHrRow = document.getElementById('shoping_cart_hr_product' + productId);
	productRow.parentNode.removeChild(productRow);	
	productHrRow.parentNode.removeChild(productHrRow);	
	ajaxRemoveProduct(productId);	
}
function ajaxValidateRemovedProduct(ajaxIndex){
	if(ajaxObjects[ajaxIndex].response!='') eval(ajaxObjects[ajaxIndex].response);
}
function ajaxRemoveProduct(productId){
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = '/ajax/removeProduct.php?productIdToRemove=' + productId;
	ajaxObjects[ajaxIndex].onCompletion = function(){ ajaxValidateRemovedProduct(ajaxIndex); };
	ajaxObjects[ajaxIndex].runAJAX();
}
function faireinsertion(){
	var valid = new Validation('formu');
    var result = valid.validate();
	if (result == true){
		return true;
	}else{
		return false;
	}
}
function callback(){
	document.getElementById('image_envoyer').style.display='none';
	var url = '/templates/www.francecasse.fr/infosinsert_ajax.php';
	var myAjax = new Ajax.Request(
	url,
	{
		method: 'post',
		postBody: $('formu').serialize()+'&action=envoie',
		onComplete: insertiondemande
	});
}
function faireinsertionuk(){
	var valid = new Validation('formu', {onSubmit:false});
    var result = valid.validate();
	if (result == true){
		var elt = document.getElementById("imgenvoi");
		elt.style.visibility = "hidden";
		parent.appelbox();
		var url = '/templates/www.car-scrapyards.co.uk/infosinsert_ajax.php';
		var myAjax = new Ajax.Request(
			url,{
				method: 'post',
				postBody: $('formu').serialize()+'&action=envoie',
				onComplete: insertiondemandeuk
			}
		);
	}
}
function faireinsertiones(){
	var valid = new Validation('formu', {onSubmit:false});
    var result = valid.validate();
	if (result == true){
		parent.appelbox();
		var url = '/templates/www.recambios-coches.es/infosinsert_ajax.php';
		var myAjax = new Ajax.Request(
			url,{
				method: 'post',
				postBody: $('formu').serialize()+'&action=envoie',
				onComplete: insertiondemandees
			}
		);
	}
}
function insertiondemande(xhr){
	if (xhr.status == 200){
		parent.confirmbox(xhr.responseText);
	}else{
		alert ('Un problème est survenu');
	}
}
function insertiondemandeuk(xhr){
	if (xhr.status == 200){
		parent.confirmbox(xhr.responseText);
	}else{
		alert ('A problem has occured');
	}
}
function insertiondemandees(xhr){
	if (xhr.status == 200){
		parent.confirmbox(xhr.responseText);
	}else{
		alert ('Hubo un error');
	}
}
function lostpassclient(){
	var url = '/ajax/connexion_ajax.php';
	var myAjax = new Ajax.Request(
		url,{
			method: 'get',
			parameters: {action: 'passclient'},
			onComplete: reponsepassclient
		}
	);
}
function reponsepassclient(xhr){
	if (xhr.status == 200){
        $('connexion_client_contenu').innerHTML = xhr.responseText;
    }else{
		$('connexion_client_contenu').innerHTML = xhr.status;
	}
}
function lostpasscasse(){
	var url = '/ajax/connexion_ajax.php';
	var myAjax = new Ajax.Request(
		url,{
			method: 'get',
			parameters: {action: 'passcasse'},
			onComplete: reponsepasscasse
		}
	);
}
function reponsepasscasse(xhr){
	if (xhr.status == 200){
        $('connexion_casse_contenu').innerHTML = xhr.responseText;
    }else{
		$('connexion_casse_contenu').innerHTML = xhr.status;
	}
}
function checkimmat(key,val2){
	var immat = $F('immatriculation['+key+']['+val2+']');
	var taille = immat.length;
	var dernier = immat.substr(taille-1,1);
	var conditionalpha = /[a-zA-Z]/; var conditionnum = /[0-9]/;
	var conditionsigne = /\-/; var conditionspace = / /;
	if(dernier.match(conditionalpha) || dernier.match(conditionnum) || dernier.match(conditionsigne) || dernier.match(conditionspace)){
		var tab = immat.split('');
		var tailletab = tab.length;
		if(tab[0].match(conditionalpha)){
			document.getElementById('immatriculation['+key+']['+val2+']').maxLength=9;
			for(var i=0;i<=tailletab-1;i++){
				if(tab[i].match(conditionspace)){
					tab[i] = tab[i].replace(tab[i],'');
				}
			}
			if(tailletab>9){
				var immatcorrigee = immat.substring(0, 9);
			}else{
				if(tab[4]!=null){
					if(tab[1].match(conditionalpha) && tab[2]!='-' && tab[2].match(conditionnum) && tab[3].match(conditionnum) && tab[4].match(conditionnum)){
						tab[2] = tab[2].replace(tab[2],'-'+tab[2]);
					}
				}
				if(tab[7]!=null){
					if(tab[1].match(conditionalpha) && tab[2].match(conditionsigne) && tab[3].match(conditionnum) && tab[4].match(conditionnum) && tab[5].match(conditionnum) && tab[6]!='-' && tab[7].match(conditionalpha)){
						tab[6] = tab[6].replace(tab[6],'-'+tab[6]);
					}
				}
				var immatcorrigee = tab.join('');
			}
		}else if(tab[0].match(conditionnum)){
			document.getElementById('immatriculation['+key+']['+val2+']').maxLength=11;
			for(var i=0;i<=tailletab-1;i++){
				if(i>0){
					var precedent = tab[i-1];
					if(tab[i].match(conditionalpha)){
						if(precedent.match(conditionnum)){
							tab[i] = tab[i].replace(tab[i],' '+tab[i]);
						}
					}else if(tab[i].match(conditionnum)){
						if(precedent.match(conditionalpha)){
							tab[i] = tab[i].replace(tab[i],' '+tab[i]);
						}
					}else if(tab[i].match(conditionsigne)){
						tab[i] = tab[i].replace(tab[i],'');
					}
				}
			}
			var immatcorrigee = tab.join('');
		}else{
			var immatcorrigee = immat.substr(0,taille-1);
		}
		document.getElementById('immatriculation['+key+']['+val2+']').value = immatcorrigee;
	}else{
		var immatcorrigee = immat.substr(0,taille-1);
		document.getElementById('immatriculation['+key+']['+val2+']').value = immatcorrigee;
	}
}
function ajoute_photo(modeleid,pieceid,sessionid,numerophoto){
	if(numerophoto<5){
		var nouveaunumerophoto=parseInt(numerophoto)+1;
		maDiv = document.createElement("div");
		maDiv.id = 'photo-'+modeleid+'-'+pieceid+'-'+nouveaunumerophoto;
		maDiv.innerHTML='<object type="application/x-shockwave-flash" data="http://www.francecasse.fr/flash/fileUpload10.swf" width="270" height="25"><param name="movie" value="http://www.francecasse.fr/flash/fileUpload10.swf"><param name="wmode" value="transparent"><param name="flashvars" value="filtre=*.jpg&amp;sessionid='+sessionid+'&amp;modeleid='+modeleid+'&amp;pieceid='+pieceid+'&amp;numerophoto='+nouveaunumerophoto+'" /><param name="allowFullScreen" value="true"></object>';
		$('photo-'+modeleid+'-'+pieceid+'-'+numerophoto).appendChild(maDiv);
		
	}
}
