﻿function beginsWith( $str, $sub ) {
   return ( substr( $str, 0, strlen( $sub ) ) == $sub );
}


//Transparence des PNG pour IE 5 et 6



function pngtrans(){

var arVersion = navigator.appVersion.split("MSIE")

var version = parseFloat(arVersion[1])

//alert();

if ((version >= 5.5) && (version < 7) && (document.body.filters)) 

{

   for(var i=0; i<document.images.length; i++)

   {

      var img = document.images[i]

      var imgName = img.src.toUpperCase()

      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")

      {

         var imgID = (img.id) ? "id='" + img.id + "' " : ""

         var imgClass = (img.className) ? "class='" + img.className + "' " : ""

         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "

         var imgStyle = "display:inline-block;" + img.style.cssText 

         if (img.align == "left") imgStyle = "float:left;" + imgStyle

         if (img.align == "right") imgStyle = "float:right;" + imgStyle

         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle

         var strNewHTML = "<span " + imgID + imgClass + imgTitle

         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"

         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"

         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 

         img.outerHTML = strNewHTML

         i = i-1

      }

   }

}
}



function accordion(el) {

    if (Element.hasClassName(el.parentNode.id+'-body','visible')){

        //do not need to perform an actions

        return;

    }

    var eldown = el.parentNode.id+'-body';

    var apanels = document.getElementsByClassName('panel_body',el.parentNode.parentNode);

    for (var i=0;i<apanels.length;i++){

        if (Element.hasClassName(apanels[i].parentNode.id+'-body','visible'))

            var elup = apanels[i].parentNode.id+'-body';

    }

    new Effect.Parallel([ new Effect.SlideUp(elup), new Effect.SlideDown(eldown) ], {duration: 0.5});

    Element.removeClassName(elup,'visible');

    Element.addClassName(eldown,'visible');

}



//pass in ID of container element that has all instances of apanels

function accordion_init(id) {



    var apanels = document.getElementsByClassName('panel_body',id);

    for (var i=0;i<apanels.length;i++){



        apanels[i].style.display = 'none';

    }

	

    var velems = document.getElementsByClassName('visible');

    for (var i=0;i<velems.length;i++){



        $(velems[i]).style.display = 'block';

    }

	

	



}



function switchRub(idrub,idpan){

new Effect.Fade("maincontent", { duration: 0.5, queue: { position: "end", scope: "myQueue" } });




	var apanels2 = document.getElementsByClassName('visible_rub');

    for (var i=0;i<apanels2.length;i++){

		Element.removeClassName(apanels2[i],'visible_rub');
		//var tempdid=Element.id
		//alert (apanels2[i].id)
    }
	
	var apanels3 = document.getElementsByClassName('panel_title');

    for (var i=0;i<apanels3.length;i++){
	
		var tempdid=apanels3[i].id.slice(10);
		
		apanels3[i].innerHTML='<a href="#"><img src="IMG/rubon' + tempdid + '.png"  onmouseover="this.src=\'IMG/ruboff'+ tempdid + '.png\'" onmouseout="this.src=\'IMG/rubon' + tempdid 
		+'.png\'"  width="176" height="37"/></a>';

    }
		
		
$('titreimage'+idrub).innerHTML='<a href="#"><img src="IMG/ruboff' + idrub + '.png"  class="spip_logos" width="176" height="37"/></a>';

pngtrans();
	  
	  new Ajax.Updater('maincontent', 'spip.php?page=rubrique_appel&id_rubrique='+idrub,{onLoading:function(request){Element.show('indicatorwait');},onComplete:function(){new Effect.Appear("maincontent", { duration: 3, queue: { position: "end", scope: "myQueue" },afterFinish:function(){pngtrans();}  });Element.hide('indicatorwait');}, evalScripts:true, asynchronous:true});
	  

}


function switchArt(idart){
new Effect.Fade("maincontent", { duration: 0.5, queue: { position: "end", scope: "myQueue" } });

	  new Ajax.Updater('maincontent', 'spip.php?page=article_appel&id_article='+idart,{onLoading:function(request){Element.show('indicatorwait');}, onComplete:function(){new Effect.Appear("maincontent", { duration: 3, queue: { position: "end", scope: "myQueue" },afterFinish:function(){pngtrans();}  });Element.hide('indicatorwait');}, evalScripts:true, asynchronous:true});

//pngtrans();

}


function switchSSRub(idrub){
new Effect.Fade("maincontent", { duration: 0.5, queue: { position: "end", scope: "myQueue"}});

	  new Ajax.Updater('maincontent', 'spip.php?page=rubrique_appel&id_rubrique='+idrub,{onLoading:function(request){Element.show('indicatorwait');},onComplete:function(){new Effect.Appear("maincontent", { duration: 3, queue: { position: "end", scope: "myQueue" },afterFinish:function(){pngtrans();} });Element.hide('indicatorwait');}, evalScripts:true, asynchronous:true});

//pngtrans();

}






function changemoodimage(urlmood){
	
		$('mood_rubrique').innerHTML='<img src='+urlmood+'>';

	}








function demarrer_article2(){

//menu

accordion_init('myfirst_accordion');

pngtrans();



}

function demarrer_rubrique2(idrubcon){

//menu

accordion_init('myfirst_accordion');

pngtrans();
//switchRub(idrubcon,'10');


}

var ShipFirst = "";
var ShipLast = "";
var ShipEmail = "";
var ShipCompany = "";
var ShipAddress1 = "";
var ShipAddress2 = "";
var ShipCity = "";
var ShipState = "";
var ShipCountryIndex = 0;
var ShipZip = "";
var ShipPhone = "";

function InitSaveVariables(form) {
ShipFirst = form.ship_first_name.value;
ShipLast = form.ship_last_name.value;
ShipCompany = form.ship_company_name.value;
ShipAddress1 = form.ship_address_one.value;
ShipAddress2 = form.ship_address_two.value;
ShipCity = form.ship_city.value;
ShipZip = form.ship_postal_code.value;
ShipPhone = form.ship_phone.value;
ShipState = form.ship_state_or_province.value;
ShipCountryIndex = form.ship_country.selectedIndex;
ShipCountry = form.ship_country[ShipCountryIndex].value;

}

function ShipToBillPerson(form) {
if (form.copy.checked) {
InitSaveVariables(form);

form.ship_first_name.value = form.bill_first_name.value;
form.ship_last_name.value = form.bill_last_name.value;
form.ship_company_name.value = form.bill_company_name.value;
form.ship_address_one.value = form.bill_address_one.value;
form.ship_address_two.value = form.bill_address_two.value;
form.ship_city.value = form.bill_city.value;
form.ship_postal_code.value = form.bill_postal_code.value;
form.ship_phone.value = form.bill_phone.value;
form.ship_state_or_province.value = form.bill_state_or_province.value;

form.ship_country.selectedIndex = form.bill_country.selectedIndex;

}
else {
form.ship_first_name.value = ShipFirst;
form.ship_last_name.value = ShipLast;
form.ship_company_name.value = ShipCompany;
form.ship_address_one.value = ShipAddress1;
form.ship_address_two.value = ShipAddress2;
form.ship_city.value = ShipCity;
form.ship_postal_code.value = ShipZip;

form.ship_phone.value = ShipPhone;
form.ship_state_or_province.value = ShipState;

form.ship_country.selectedIndex = ShipCountryIndex;

   }

}


