////////////////////////////////////////////////////////////////////////////////
// ROLLOVER SCRIPTS CREATED BY DREAMWEAVER
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// POPUP WINDOWS


/////VALIDATE EMAIL///////////////////////////////////////////////////////////////////
function validate_email(fr,lang){
var status = true;
alert(fr)

                //if there is no "@" character in the email     
                if (fr.search("@") == -1){
                        if (lang=="E")
                                alert("Not a valid email address.")
                        else
                                alert("Adresse électronique invalide.")
                status = false;}
                
                //if there is "." character in the email AND "." character is the last character in the string
                if (fr.charAt(fr.length - 1) == "."){
                        if (lang=="E")
                                alert("Not a valid email address.")
                        else
                                alert("Adresse électronique invalide.")
                        status = false;}
                
                //if there is no "." character after "@" character in the string
                if  (fr.lastIndexOf(".") == -1){
                        if (lang=="E")
                                alert("Not a valid email address.")
                        else
                                alert("Adresse électronique invalide.")
                        status = false;}
                
                //if there is ".gc" without ".gc.ca" string     
                if (fr.indexOf(".gc") != -1 && fr.indexOf(".gc.ca") == -1){
                        if (lang=="E")    
                                alert("Sorry! Invalid Email Address\n\rYour email address has not been recognized as a valid Government of Canada email address.")
                        else
                                alert("Désolé ! Adresse électronique non valide.\n\rLe système ne reconnaît pas cette adresse comme adresse du gouvernement du Canada.")
                        status = false;}
}


////////////////////////////////////////////////////////////////////////////////
// FUNCTION GO used with drop down menus in campus e
function lookup(type){
  if(type == 1)
  {
    window.location.href=document.menu.theme.options[document.menu.theme.selectedIndex].value;
   
  }
  else
  {
    window.location.href=document.menu.producer.options[document.menu.producer.selectedIndex].value;
   
  }
}
////////////////////////////////////////////////////////////////////////////////
// POPUP WINDOWS
////////////////////////////////////////////////////////////////////////
//Implemented by: Marc Charron ( IT Department CCMD-CCG )
//
//Date:           February 10th, 2002
//
//input:          the location of the content, the width and the height of the
//                window desired.
//                
//output:         window and content
//
//version:        1.0
//
//details:        this script uses two input values to create the size 
//                of the window required to display a given content.
////////////////////////////////////////////////////////////////////////
function popup(message,w,h) {
   var l,t;
	//get screen width to position window horizontal middle
	l = parent.screen.width/2 - 270;
	
	//get screen height to position vertical middle
	t = parent.screen.height - ((screen.height/2) + 225);
	
	//verify for height and width if none default to 500 by 400
	if(w == "" || h == "")
	{w = 350;h = 400;}
	else	
	{
	   //browser detect	
	   if(navigator.appName == "Netscape"){
  	      tempwin = window.open('','','width='+ w +',height='+ h +',resizable=yes,scrollbars=yes,screenX='+ l +',screenY='+ t);
	   }   
	   if(navigator.appName == "Microsoft Internet Explorer"){
	      tempwin = window.open('','','width='+ w +',height='+ h +',resizable=yes,scrollbars=yes,left='+l+',top='+t);
      }

   }
   tempwin.location.href=message;
}
function ShutWin(){
   window.close();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function OpenWindow(FileURL, WindowName, Height, Width)
{
    var WindowReference;
    leftPos = 0;
        if (screen) {
                leftPos = screen.width-355;
        }
        
    WindowReference = window.open(FileURL, WindowName, 'toolbar=no,directories=no,'
        + 'status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + Width.toString() + ','
        + 'height=' + Height.toString()+'right=' + leftPos + ',top=0');
    window.onerror = doError;
    
   WindowReference.focus();
}

function updateParent(newURL) {
   opener.document.location = newURL;
	self.close();
}
function doError() {
 return true;
}
function validate() {
		var button = -1;
		for (var i = 0; i < window.document.frmquestion.optchoice.length; i++) {
			if (window.document.frmquestion.optchoice[i].checked) {
				button=i;
			}
		} 
		if (button==-1){
			alert("You must make a choice before submit.");
			return false;
		}
}
////////////////////////////////////////////////////////////////////////
//Implemented by: Marc Charron ( IT Department CCMD-CCG )
//
//Date:           February 6th, 2002
//
//input:          The language value either e or f
//                
//output:         none
//
//version:        1.0
//
//details:        this script uses an input value from a navigation menu 
//                to convert its' url to either a french or english 
//                version.
////////////////////////////////////////////////////////////////////////
function lang(l)
{
   //alert(l);
   var url_str = new String(parent.location);
   
   if(url_str.indexOf(".asp")>0){
      
	 // replace lang variable in the current url
     url_str = url_str.replace("lang=e&","");
	 url_str = url_str.replace("lang=f&","");
     url_str = url_str.replace("lang=E&","")
	 url_str = url_str.replace("lang=F&","")

	 url_str = url_str.replace("&lang=e","");
	 url_str = url_str.replace("&lang=f","");
	 url_str = url_str.replace("&lang=E","")
	 url_str = url_str.replace("&lang=F","")

	 url_str = url_str.replace("?lang=e","");
	 url_str = url_str.replace("?lang=f","");
	 url_str = url_str.replace("?lang=E","")
	 url_str = url_str.replace("?lang=F","")
       
	 var separator_str = "?";
     if(url_str.indexOf("?")>0)
	  {
	     separator_str = "&";
     }
	  url_str = url_str + separator_str +  "lang=" + l;
      
     parent.document.location = url_str;
	}
   else
   {
      //remove all escape caracters %5F created by index server.
      parent.location.href = parent.location.href.replace(/%5F/g,"_");
       
	  //switch language
	  l == 'e' ? parent.location.href = parent.location.href.replace(/_e\./,'_f.'): parent.location.href = parent.location.href.replace(/_f\./,'_e.')
   }
}  
////////////////////////////////////////////////////////////////////////
//Implemented by: Marc Charron ( IT Department CCMD-CCG )
//
//Date:           July 17, 2001
//
//input:          current object, window size
//                
//output:         none
//
//version:        1.0
//
//details:        this script uses the input values to calculate and position
//                layers according to screen resolution. 
//               
////////////////////////////////////////////////////////////////////////

function Position_layer(current_el,s_width){     //move layers to appropriate position according to screen width
var i;
		
	if(navigator.appName == "Netscape"){
      for(i = 0; i<document.layers.length; i++)
         document.layers[i].left = document.layers[i].left + (screen.width - 800) / 2;
	}
	if(navigator.appName == "Microsoft Internet Explorer"){
		current_el.left = (parseInt(current_el.left.substr(0,3)) +  ((s_width - 800) / 2) + "px").toString(); // calculate new offset, add 'px' and
   }
      
}
////////////////////////////////////////////////////////////////////////
//Implemented by: Marc Charron ( IT Department CCMD-CCG )
//
//Date:           Sept 4, 2002
//
//input:          nothing
//                
//output:         browser name
//
//version:        1.0
//
//details:        this script verifies and returns the browser name
//               
////////////////////////////////////////////////////////////////////////
function checkAppName(){
   return navigator.appName
}

