/* APCHQ 2010 - par Multiple-Media             */

/*---------------------------------------------*/
/* Fonction d'affichage des zone réactive
/* utilisé par la carte des région
/*---------------------------------------------*/

function visibToggleSplash(tagId, showHide) {
				
switch (showHide){
	case 'showBlock':
		document.getElementById(tagId).style.display='block';
		document.getElementById('link'+tagId).className='selected';
		break;
	case 'hide':
		document.getElementById(tagId).style.display='none';
		document.getElementById('link'+tagId).className='';
		break;
	default:
		return false;
	}
}
/*---------------------------------------------*/
/* Fonction générique de show/hide
/*---------------------------------------------*/

function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}

/*---------------------------------------------*/
/* Fonction d'affichage des accordéons
/*---------------------------------------------*/
function showHideDl(id) {
var dt = document.getElementById('dt'+id);
var dd = document.getElementById('dd'+id);
if(dt.className == 'showDD'){
	dt.className="hideDD";
	dd.style.display='block';
       
	}
else{
	dt.className="showDD";
	dd.style.display='none';
} }		
/*---------------------------------------------*/
/* Fonction d'affichage du second menu
/* permet la compatibilité IE6
/*---------------------------------------------*/
function showSubMenu (eventType,subMenuId,MenuItemId) {

/*onmouseout*/
if(eventType=="over")
	{
	document.getElementById(MenuItemId).style.position='relative';
	document.getElementById(subMenuId).className='subMenu';
	if(document.getElementById('share'))
           {document.getElementById('share').style.visibility='hidden';}
	}


/*onmouseout*/
if(eventType=="out")
	{
	document.getElementById(subMenuId).className='hideObj';
	document.getElementById(MenuItemId).style.position='static';
	if(document.getElementById('share'))
		{document.getElementById('share').style.visibility='visible';}
	} 

}
/*---------------------------------------------*/
/* Fonction vidage du champ recherche
/*---------------------------------------------*/

function ClearContent(para, remind){
	obj = document.getElementById("SearchField");
	if (para == 0){
	   if (obj.value==remind)
	     obj.value="";
	}
	else
	{
		 if (obj.value==""){
	     obj.value=remind;
	     obj.select();
	   }
	}
}
/*---------------------------------------------*/
/* Fonction d'affichage (autoprolongement du menu)
/*---------------------------------------------*/

function getMenuWidth(){
 w=document.getElementById('mainMenu').clientWidth;
 var newW=959-w;
 if (newW > 0)
 document.getElementById('lastMenuItem').style.width=newW+"px";
 else{
  document.getElementById('lastMenuItem').style.display="none"}
 }
/*---------------------------------------------*/
/* Fonction d'impression
/*---------------------------------------------*/

function imprimer(){window.print();}
/*---------------------------------------------*/
/* Fonction partage dans les media sociaux
/*---------------------------------------------*/

function commonPopup(url, width, height, toolsInd, wname)
{
    var options = "width=" + width + ",height=" + height + ",top=" + ((screen.height - height) / 4).toString() + ",left=" + ((screen.width - width) / 2).toString();

    switch (toolsInd)
    {
        case 1:
            options += ",toolbar=no,status=no,resizable=no,scrollbars=yes";
            break;
        case 2:
            options += ",resizable=no,scrollbars=no,status=no,menubar=no,toolbar=no,directories=no,location=no";
            break;
        case 3:
            options += ",menubar=yes,toolbar=yes,status=yes,resizable=yes,location=yes,scrollbars=yes";
            break;
        case 4:
            options += ",top=50,left=50,resizable=yes,scrollbars=yes,status=no,menubar=no,toolbar=no,location=yes";
            break;
        default:
            //do nothing
            break;
    }

    if (!wname)
    {
        wname = "reutersPopup";
    }

    popupWindow = window.open(url, wname, options);

    if (popupWindow)
    {
        popupWindow.focus();
    }
}

var articleURL = location.href;
//add
var articleTitle = document.title;
var articleBlurb = "";

if (location.href.search("\\?") != -1) {
	articleURL = location.href.split("?")[0];
}

//Google
function shareGoogle() {
	commonPopup('http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(articleURL)+'&title='+encodeURIComponent(articleTitle)+'&annotation='+encodeURIComponent(articleBlurb)+'&labels=', 860, 640, 1, 'googlePopup');
}

//Delicious
function shareDelicious() {
	commonPopup('http://del.icio.us/post?url='+encodeURIComponent(articleURL)+'&title='+encodeURIComponent(articleTitle)+'&notes='+encodeURIComponent(articleBlurb)+'&tags=news', 860, 640, 1, 'deliciousPopup');
}

//Favorites (of your browser)
function shareFavorites() {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(articleTitle, articleURL,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( articleURL, articleTitle); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

//Facebook
function shareFacebook() {
	commonPopup('http://www.facebook.com/sharer.php?u='+encodeURIComponent(articleURL)+'&t='+encodeURIComponent(articleTitle), 860, 640, 1, 'facebookPopup');
}

//Live
function shareLive() {
	commonPopup('http://spaces.msn.com/BlogIt.aspx?SourceURL='+encodeURIComponent(articleURL)+'&Title='+encodeURIComponent(articleTitle), 860, 640, 1, 'livePopup');
}

//Digg
function shareDigg() {
	commonPopup('http://digg.com/remote-submit?phase=2&url='+encodeURIComponent(articleURL)+'&title='+encodeURIComponent(articleTitle)+'&bodytext='+encodeURIComponent(articleBlurb), 860, 640, 1, 'diggPopup');
}

//Yahoo MyWeb
function shareYahoo() {
	commonPopup('http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+encodeURIComponent(articleTitle)+'&u='+encodeURIComponent(articleURL)+'&ei=UTF-8'+'&d='+encodeURIComponent(articleBlurb)+'&tag=news', 860, 640, 1, 'yahooPopup');
}

//Furl
function shareFurl() {
	commonPopup('http://www.furl.net/storeIt.jsp?u='+encodeURIComponent(articleURL)+'&t='+encodeURIComponent(articleTitle), 860, 640, 1, 'furlPopup');
}

//StumbleUpon
function shareStumble() {
	commonPopup('http://www.stumbleupon.com/submit?url='+encodeURIComponent(articleURL)+'&title='+encodeURIComponent(articleTitle), 860, 640, 1, 'stumbleUponPopup');
}


function shareNewsvine() {
	commonPopup('http://www.newsvine.com/_wine/save?aff=reuters&h='+encodeURIComponent(articleTitle)+'&t=world-news&u='+encodeURIComponent(articleURL)+'&e='+encodeURIComponent(articleBlurb), 860, 640, 1, 'newsvinePopup');
}

function shareMixx() {
	commonPopup('http://www.mixx.com/submit/story?title='+encodeURIComponent(articleTitle)+'&page_url='+encodeURIComponent(articleURL)+'&partner=REU&description='+encodeURIComponent(articleBlurb), 860, 640, 1, 'mixxPopup');
}

function shareTwitter() {
	commonPopup('http://twitter.com/home?status='+encodeURIComponent(articleTitle)+'%20-%20'+encodeURIComponent(articleURL), 860, 640, 1, 'twitterPopup');
}


function shareTechnorati() {
	commonPopup('http://technorati.com/favorites/?sub=addfavbtn&add='+encodeURIComponent(articleURL), 860, 640, 1, 'TechnoratiPopup');
}

function shareReddit() {
	commonPopup('http://www.reddit.com/login?dest=%2Fsubmit%3Furl%3D'+encodeURIComponent(articleURL)+'%26title%3D'+encodeURIComponent(articleTitle), 860, 640, 1, 'RedditPopup');
	}

function shareZoomit() {
	commonPopup('http://www.zoomit.ca/login.php?return=/submit.php?url='+encodeURIComponent(articleURL), 960, 640, 1, 'zoomitPopup');
}


function gup( name ) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}



function popPage( page, ancho, alto ) { 
	var menubar     = "no";  // The File, Edit, View Menus 
	var scrollbars  = "no"; // Horizontal and vertical scrollbars 
	var location = "no";  // The location box with the site URL 
	var directories = "no";  // the "What's New", "What Cool" links 
	var resizable   = "no";  // Can the window be resized? 
	var status   = "no";  // Status bar (with "Document: Done") 
	var toolbar = "no";  // Back, Forward, Home, Stop toolbar 
	var width = ancho;
	var height = alto;
	var top    = (screen.height - height)/2;
	var left   = (screen.width  - width)/2;

	features = "" + 
		"width=" + width + "," + 
		"height=" + height + "," + 
		"top=" + top + "," + 
		"left=" + left + ""; 
	features += "" + 
		(",menubar=" + menubar) + 
		(",scrollbars=" + scrollbars) + 
		(",location=" + location) + 
		(",directories=" + directories) + 
		(",resizable=" + resizable) + 
		(",status=" + status) + 
		(",toolbar=" + toolbar); 

//	alert(features);

	window.open( page, 'fullPopup', features ); 
}



function parseQuery ( query ) {
   var Params = new Object ();
   if ( ! query ) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
} 

//site names
var regionLink=new Array();
regionLink[0]="abitibi";
regionLink[1]="beauceappalaches";
regionLink[2]="boisfrancs";
regionLink[3]="centreduquebec";
regionLink[4]="cotenord";
regionLink[5]="estduquebec";
regionLink[6]="estrie";
regionLink[7]="hauteyamaska";
regionLink[8]="lacstjean";
regionLink[9]="lanaudiere";
regionLink[10]="mauricie";
regionLink[11]="montreal";
regionLink[12]="outaouais";
regionLink[13]="quebec";
regionLink[14]="saguenay";
regionLink[15]="suroit";


//region codes
var regionCode=new Array();
regionCode[0]="05";
regionCode[1]="09";
regionCode[2]="01";
regionCode[3]="13";
regionCode[4]="15";
regionCode[5]="12";
regionCode[6]="08";
regionCode[7]="14";
regionCode[8]="16";
regionCode[9]="03";
regionCode[10]="11";
regionCode[11]="04";
regionCode[12]="02";
regionCode[13]="06";
regionCode[14]="07";
regionCode[15]="10";


function setSelectedItem(combo, valor) {

	var length = combo.options.length;
	for (var i=0; i < length; i++) {
		if (combo.options[i].value == valor) {
			combo.options[i].selected = true;
			break;
		}
	}
	
}

