﻿// ****
// FORM
// ****

function bddPostbackForm() {

	var objForm =document.getElementById("bddForm");
	var objInput = document.getElementById("frmpostback");

	if(objForm && objInput){
	
		objInput.value = "false";

		objForm.submit();

	}

}

function bddSwitchForm(display) {

	var divForm = document.getElementById("divForm");
	var divRecord = document.getElementById("divRecord");

	if(divForm && divRecord){

		if(display){
		
			divForm.className = "displayOn";
			divRecord.className = "displayOff";
		
		}	
		else{
		
			divForm.className = "displayOff";
			divRecord.className = "displayOn";

		}

	}

}

// *******
// DETAILS
// *******

function bddThrowDetails(base,id,mode,espace,name) {

	if(base=='cpcr'){ bddThrowCPCR(id) };
	if(base=='coupe'){ bddThrowCup(id) };
	if(base=='contacts'){ bddThrowContact(id) };
	if(base=='calendrier'){ bddThrowCompet(id) };
	if(base=='etalonnage'){ bddThrowEtalonnage(id) };
	
	if(id && (base=='biographies' || base=='selections' || base=='cclubs')){
	
		FFAbases = window.open('/asp.net/athletes.aspx?base=' + base + '&id=' + id + '&espace=' + espace, "FFAthle", 'width=700,height=600,scrollbars');
		FFAbases.focus();
		
	}

	if(id && (base=='resultats' || base=='bilans' || base=='podiums' || base=='records' || base=='vitessekm')){

		FFAbases = window.open('/asp.net/athletes.aspx?base=' + base + '&seq=' + id + '&espace=' + espace, "FFAthle", 'width=700,height=600,scrollbars');
		FFAbases.focus();
		
	}

}

function bddThrowAthlete(base,seq,espace,structure) {

	var urlEspace = (espace)?'&espace='+espace:'';
	var urlStructure = (structure)?'&structure=' + structure:'';
	var url = '/asp.net/athletes.aspx?base=' + base + '&seq=' + seq + urlEspace + urlStructure;

	FFAbases = window.open(url, 'FFAthle', 'width=700,height=600,scrollbars');
	FFAbases.focus();
		
}

function bddThrowCPCR(id) {

	if(id){
	
		FFAbases = window.open('/asp.net/cpcr.aspx?base=cpcr&id=' + id, 'FFAthle', 'width=700,height=600,scrollbars');
		FFAbases.focus();

	}		

}

function bddThrowCup(id) {

	if(id){

		FFAbases = window.open('/asp.net/coupe.aspx?base=coupe&id=' + id, 'FFAthle', 'width=700,height=600,scrollbars');
		FFAbases.focus();
		
	}		

}

function bddThrowContact(id) {

	if(id){

		FFAbases = window.open('/asp.net/contacts.aspx?base=contacts&id=' + id, 'FFAthle', 'width=700,height=600,scrollbars');
		FFAbases.focus();
		
	}		

}

function bddThrowCompet(id) {

	if(id){

		FFAbases = window.open('/asp.net/competitions.aspx?base=calendrier&id=' + id, 'FFAthle', 'width=700,height=600,scrollbars');
		FFAbases.focus();
		
	}		

}

function bddThrowEtalonnage(bid,cid) {

	if(bid || cid){
	
		FFAbases = window.open('/asp.net/etalonnage.aspx?base=etalonnage&bid=' + bid + '&cid=' + cid, 'FFAthle', 'width=700,height=600,scrollbars');
		FFAbases.focus();

	}		

}



function newwindow(url)
{window.open(url,'Prono','width=930,height=800,scrollbars=Yes');
}

function openstat(url)
{stat=window.open(url,'Stat','width=930,height=800,scrollbars=Yes');
stat.focus();
}

function openjury(url)
{jury=window.open(url,'Jury','width=910,height=800,scrollbars=Yes');
jury.focus();
}

function openrec(url)
{rec=window.open(url,'Rec','width=820,height=700,scrollbars=Yes');
rec.focus();
}

function openmessage(url)
{mes=window.open(url,'Rec','width=480,height=300,scrollbars=Yes');
mes.focus();
}


function goTV(url)
{window.open(url, 'TV', 'width=620,height=620,scrollbars=Yes');}



// ********
// BDD TABS
// ********

function bddRollOnTab(tab) {

	if(!mainGetActiveStatus(tab.className)){tab.className="on"};

}

function bddRollOutTab(tab) {

	if(!mainGetActiveStatus(tab.className)){tab.className="off"};

}

function bddClickTab(tab) {

	var objRegExp;
	var arrRegExp;

	objRegExp = new RegExp("(.*?)\#([0-9]+)");
	arrRegExp = objRegExp.exec(tab.id);
    
    if(arrRegExp && !mainGetActiveStatus(tab.className)){
        
        var	prefix = (arrRegExp)?arrRegExp[arrRegExp.length - 2]:"";
        var	index = (arrRegExp)?arrRegExp[arrRegExp.length - 1]:"";

        if(prefix && index){

		    for(i=1;i<=7;++i){

				var objDiv = document.getElementById(prefix.replace(/tab/gi, "Div") + "#" + i) ;
				var objTab = document.getElementById(prefix + "#" + i) ;

			    if(objTab && objDiv){

				    if(i == mainGetNumber(index)){
    				
					    objTab.className = "active";
					    objDiv.className = "displayOn";
    				
				    }
				    else{
    				
					    objTab.className = "off";
					    objDiv.className = "displayOff";

				    }
    			
			    }
    		
		    }

        }

    }

}

function bddGetTabClass(mode) {

	if(typeof(mode)=="string"){ return mode } else { return "" };

}

// *****
// INFOS
// *****

function bddWeightInfos(required) {

    if(required){
    
        alert("La requête ne peut aboutir que si ce critère est renseigné, il s'agit d'un champ imposé...");

    }
    else{
    
        alert("Une requête ne peut aboutir que si le poids total des critères de recherche renseignés est supérieur ou égal à dix, les chiffres placés à coté des champs indiquent le poids du critère en question...");

    }

}
