

function submitform(obname)
{
	document.getElementById(obname).submit();
}

function GetXmlHttpObject(handler)
{
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return objXMLHttp
}


function stateChangedRollOverStyle()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("rolloverStyle").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedPays()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResult").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedNote()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResult").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedCousin()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResultCousin").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedLabel()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResultLabel").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedLabelRe()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResultLabelRe").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedDistributeur()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResultDistributeur").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedImage()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResultImage").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}


function stateChangedMorceaux()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResultMorceaux").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedContact()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResultContact").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

function stateChangedRessource()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById("txtResultRessource").innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

/**
 *   Array convenience method to remove element.
 *
 *   @param object element
 *   @returns boolean
 */
Array.prototype.remove = function (element) {
	var result = false;
	var array = [];
	for (var i = 0; i < this.length; i++) {
		if (this[i] == element) {
			result = true;
		} else {
			array.push(this[i]);
		}
	}
	this.length = 0;
	for (var i = 0; i < array.length; i++) {
		this.push(array[i]);
	}
	array = null;
	return result;
};

// Will populate data based on input
function htmlData(url, qStr,idajax)
{

    if (url.length==0)
    {
        document.getElementById("txtResult").innerHTML=""; 
        return;
    }
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }

    url=url+"?"+qStr; 
    url=url+"&sid="+Math.random();
    if(idajax==1)
    {
        xmlHttp.onreadystatechange=stateChangedPays;
    }
    else if(idajax ==2)
    {
        xmlHttp.onreadystatechange=stateChangedCousin;
    }
    else if(idajax ==3)
    {
        xmlHttp.onreadystatechange=stateChangedRollOverStyle;
    }
    else if(idajax ==4)
    {
        xmlHttp.onreadystatechange=stateChangedLabel;
    }
    else if(idajax ==5)
    {
        xmlHttp.onreadystatechange=stateChangedLabelRe;
    }
    else if(idajax ==6)
    {
        xmlHttp.onreadystatechange=stateChangedDistributeur;
    }
    else if(idajax==7)
    {
        xmlHttp.onreadystatechange=stateChangedImage;
    }
    else if(idajax==8)
    {
        xmlHttp.onreadystatechange=stateChangedMorceaux;
    }
    else if(idajax==9)
    {
        xmlHttp.onreadystatechange=stateChangedContact;
    } 
    else if(idajax==10)
    {
        xmlHttp.onreadystatechange=stateChangedRessource;
    }       
    xmlHttp.open("GET",url,true) ;
    xmlHttp.send(null);
}

var arSelected = new Array();
var arSelectedId = new Array();
var arSelectedIdAll;
var arSelectedIdStyles;
var arSelectedIdStyleParent;

function getMultiple(ob) {

    for (var i = 0; i < ob.options.length; i++)
         if (ob.options[ i ].selected && !arSelected.inArray(ob.options[i].text)) 
         {
            arSelected.push(ob.options[ i ].text);
            arSelectedId.push(ob.options[ i ].value);
        }
        else if (!(ob.options[ i ].selected)) 
        {
            if(arSelected.inArray(ob.options[i].text))
            {
                arSelected.remove(ob.options[ i ].text);
                arSelectedId.remove(ob.options[ i ].value);
            }

        }
 }
 
 function getSingleById(idob){
    arSelected = document.getElementById(idob).value;
}

function getSingle(ob){
    arSelected = ob.value;
 }
 

function getMultipleIdAll() {
    ob = document.getElementById("idallpays");
    arSelectedIdAll = ob.value;
 }
 
 function getMultipleIdStyles() {
    ob = document.getElementById("idstyles");
    arSelectedIdStyles = ob.value;
    ob = document.getElementById("idstyleparent");
    arSelectedIdStyleParent = ob.value;
    
    arSelected = new Array();
    arSelectedId = new Array();
 }

 
var arNomCousin ;
var arIdCousin;

function getNomCousin(obname,obname1) {
    ob = document.getElementById(obname);
    arNomCousin = ob.value;
    
    ob1 = document.getElementById(obname1);
    if(ob1==null)
    {
        arIdCousin = 0;
        return false;
    }
    else
    {
        arIdCousin = ob1.value;
        return true;
    }  
 }
 
var filterPa;
var filterStatus;
var filterNumMag;
var filterChroniqueur;
var filterInfoContact;
var filterImages;
var filterVideos;
var filterSound;
var filterDistributeur;
var filterLabel;

function getChroniqueFilter() {
    ob = document.getElementById("filterpa");
    filterPa = ob.value;
    
    ob = document.getElementById("filterstatus");
    filterStatus = ob.value;
    
    ob = document.getElementById("filternummag");
    filterNumMag = ob.value;
    
    ob = document.getElementById("filterchroniqueur");
    filterChroniqueur = ob.value;
    
    ob = document.getElementById("filterdistributeur");
    filterDistributeur = ob.value;
    
    ob = document.getElementById("filterlabel");
    filterLabel = ob.value;
    
    ob = document.getElementById("filterinfocontact");
    filterInfoContact = ob.value;
    
    ob = document.getElementById("filterimages");
    filterImages = ob.value;

    ob = document.getElementById("filtervideos");
    filterVideos = ob.value;

    ob = document.getElementById("filtersound");
    filterSound = ob.value;
        
    window.location='chroniques.php?action=showall&fpa='+filterPa+'&fstatus='+filterStatus+'&fchro='+filterChroniqueur+'&flabel='+filterLabel+'&fdistrib='+filterDistributeur+'&finfocontact='+filterInfoContact+'&fnummag='+filterNumMag+'&fnbimages='+filterImages+'&fnbvideos='+filterVideos+'&fnbsound='+filterSound;
    
    return true;
 }
 
var filterStatus;
var filterChroniqueur;
var filterRubrique;
var filterImages;
var filterVideos;


function getMediathekFilter() {
    
    ob = document.getElementById("filterstatus");
    filterStatus = ob.value;
    
    ob = document.getElementById("filterchroniqueur");
    filterChroniqueur = ob.value;
    
    ob = document.getElementById("filterrubrique");
    filterRubrique = ob.value;
    
    ob = document.getElementById("filterimages");
    filterImages = ob.value;

    ob = document.getElementById("filtervideos");
    filterVideos = ob.value;

    window.location='mediatek.php?action=showall&fstatus='+filterStatus+'&fchro='+filterChroniqueur+'&frubrique='+filterRubrique+'&fnbimages='+filterImages+'&fnbvideos='+filterVideos;
    
    return true;
 }
 
 

var filterNbChros;
var filterNbPosts;
var filterGroupe;


function getMediathekFilterMedias() {
    
    ob = document.getElementById("filterchro");
    filterNbChros = ob.value;
    
    ob = document.getElementById("filterpost");
    filterNbPosts = ob.value;
    
    ob = document.getElementById("filtergroupe");
    filterGroupe = ob.value;
    
    window.location='mediatek.php?action=video&fnbchro='+filterNbChros+'&fnbpost='+filterNbPosts+'&fidgroupe='+filterGroupe;
    
    return true;
 }