var is = new Object();
is.ie = (document.all) ? 1:0;
var newWin = null; 

function bookmarkSite()
{
	bookmarkurl = "http://www.mandg.fr/institutionnel/";
	bookmarktitle = "M&G France - Institutionnel";

	if(window.opera!=null){ 
		// opera
		alert('To bookmark the site press Ctrl + d');
	}else if(is.ie){
		window.external.AddFavorite(bookmarkurl,bookmarktitle);
	}	else if(window.opera!=null){ 	}else if (window.sidebar) {
		window.sidebar.addPanel(bookmarktitle, bookmarkurl, "")
	}

	else {
		alert('To bookmark the site press Ctrl + d');

	}
}

function loadTicker(){}

function initQuickLinks(){
	var oSelect = document.getElementById("QuickLinksSelect");
	
	if(oSelect != null){
		HookQuickLinks(oSelect);
	}
	loadTicker();
}

addOnLoadEvent(initQuickLinks);

function HookQuickLinks(oSelect){
	oSelect.onchange = function(){

		var sSelected = oSelect.options[oSelect.selectedIndex].value;
		if(sSelected != ""){

			var strTarget = "";
			for(var i=0;i<oSelect.options[oSelect.selectedIndex].attributes.length;i++)
			{
				var attr = oSelect.options[oSelect.selectedIndex].attributes[i];

				if(attr.nodeName=="target")
				{
					if(attr.nodeValue=="_blank")
					{
						strTarget = "_blank";
					}
				}
			}

			if(strTarget=="_blank")
			{
				window.open(sSelected);
			}
			else
			{
				document.location = sSelected;
			}
		}
	}
}

function checkBarrierCookie(strCookieName){
	checkBarrierCookie = false;

	var nameEQ = strCookieName + "=";

	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') {
			c = c.substring(1,c.length);
		}

		if (c.indexOf(nameEQ) == 0){
			return true;
		}
	}
	return;


}

function popUp(strURL, strType, strHeight, strWidth) { 

 if (newWin != null && !newWin.closed) 
   newWin.close(); 
 var strOptions=""; 
 if (strType=="console") 
   strOptions="status,resizable,height="+ strHeight+",width="+strWidth; 
 if (strType=="fixed") 
   strOptions="status,height="+  strHeight+",width="+strWidth; 
 if (strType=="fixedscroll") 
   strOptions="status,scrollbars,height="+  strHeight+",width="+strWidth; 
 if (strType=="elastic") 
   strOptions="status,toolbar,scrollbars,location,resizable,height="+ strHeight+",width="+strWidth;
 if (strType=="popup") 
   strOptions="status,scrollbars,resizable,height="+ strHeight+",width="+strWidth;  

newWin = window.open(strURL, 'newWin', strOptions); 

 newWin.focus(); 
}


function addOnLoadEvent(func){
	var oldLoad = window.onload;
	
	if(typeof(window.onload) != "function"){
		window.onload = func;
	} else {
		window.onload = function(){
			if(oldLoad){
				oldLoad();
			}
			func();
		} 
	}
}

function appendSearchTerm()
{
	var searchTermInput = document.getElementById("SearchBox");
	if(searchTermInput !=null)
	{
		var search = document.getElementById("searchForm");
		search.action = search.action + "?search=" + searchTermInput.value ;
	}
}

function checkEnter(e, theForm){ 
	var characterCode 
	if(e && e.which){ 
		characterCode = e.which;
	}
	else{
		e = event;
		characterCode = e.keyCode;
	}

	if(characterCode == 13){ 
		appendSearchTerm();
		theForm.submit();
		return false;
	}
	else{
		return true;
	}
}

function ReloadIFrame(){
  var rand =Math.random();
  try{
    document.getElementById("ifrm").src+="&rand=" + rand;   
  } catch(err){ }
}

addOnLoadEvent(ReloadIFrame);

function queryString(parameter) { 
  var loc = location.search.substring(1, location.search.length);
  var param_value = false;

  var params = loc.split("&");
  for (i=0; i<params.length;i++) {
      param_name = params[i].substring(0,params[i].indexOf('='));
      if (param_name == parameter) {
          param_value = params[i].substring(params[i].indexOf('=')+1)
      }
  }
  if (param_value) {
      return param_value;
  }
  else {
      return false; //Here determine return if no parameter is found
  }
}
