var targetfield = "";
var formTarget = "";
var textAreaFormat = "";

var reqSpanNames = ['s1','s2','s3','s4','s5','r1','r2','r3','r4','r5']; 


function openWindow(url,x,y) {
mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=30,top=30,width=' + x + ',height=' + y + '');
mywin.focus();
}

function openNewWindow(url,x,y, winName) {
mywin = window.open(url,winName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=30,top=30,width=800,height=650');
mywin.focus();
}

function openNewWindowTech(url,x,y, winName) {
mywin = window.open(url,winName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,left=30,top=30,width=' + x + ',height=' + y + '');
mywin.focus();
}

function openNewWindowMedia(url,x,y, winName) {
mywin = window.open(url,winName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=30,top=30,width=' + x + ',height=' + y + '');
mywin.focus();
}

function loadPageInParentAndCloseCurrent(url)
{
  window.opener.location = url;
  if (window && !window.closed)
  {
    window.close();
  }
}

function transferSymbol (symbol) {
if (window.opener.formTarget=="InnerForm"){
	if (window.opener.fieldType=="textArea"){
		window.opener.textAreaFormat += symbol + ",";	
		eval("window.opener.document.forms[3]." + window.opener.targetfield + ".value  ='" + window.opener.textAreaFormat +"'");
	}else{
		eval("window.opener.document.forms[3]." + window.opener.targetfield + ".value  ='" + symbol +"'");
	}
}else{
eval("window.opener.document.quickQuote." + window.opener.targetfield + ".value  ='" + symbol +"'");
}
window.opener.targetfield = "";
}

function quoteLookUpTicker(url, fieldName) {
eval("window.document.forms[3]." + fieldName + ".focus()")
formTarget="InnerForm";
fieldType="textArea";
openWindow(url,330,400);
}

function quoteLookUp(url, fieldName) {
eval("window.document.quoteLookUp." + fieldName + ".focus()")
formTarget="InnerForm";
openWindow(url,330,400);
}

function quickQuoteLookUp(url, fieldName) {
eval("window.document.quickQuote." + fieldName + ".focus()")
formTarget="OuterForm";
openWindow(url,330,400);
}

function quoteLookUpQ(url) {
if (targetfield =="") {
alert("Please place your mouse cursor in a quote lookup field and try again.")
} else {
formTarget="InnerForm";
openWindow(url,330,400);
}
}

function startTicker(url) {
if (url){
tickerString="/HttpController?GetPage=CustomizedTicker&symbols=" + escape(url)
newWin = window.open(tickerString,"tickerWin","toolbar=0,location=0,width=680,height=125,left=30,top=30,resizable=0");
}else{
newWin = window.open('',"tickerWin","toolbar=0,location=0,width=680,height=125,left=30,top=30,resizable=0");
document.ticker.submit();
		}
}

function confirmSubmit(msg)
{
var agree=confirm(msg);
if (agree)
return true ;
else
return false ;
}

function confirmSubmitEdit(msg1, fieldName, msg2)
{
var newMsg = msg1 + eval(fieldName + ".value") + " ."  + msg2;
var agree=confirm(newMsg);
if (agree)
return true ;
else
return false ;
}

function confirmSubmitListView(msg1, listName, msg2)
{
var sStockList;
var iList;

iList = eval(listName + ".selectedIndex");
sStockList = eval(listName + ".options[" + iList + "].text");	

var newMsg = msg1 + sStockList + " ."  + msg2;
var agree=confirm(newMsg);	
if (agree)
return true ;
else
return false ;
}



function getElStyle(iD)
{ 
  var obj = null; 
  if(document.getElementById)
  {
    obj = document.getElementById(iD); 
  } 
  else if(document.all)
  { 
    obj = document.all[iD]; 
  } 
  return obj &&
  obj.style; 
} 

function showRequired(cBx)
{ 
  var obj,vis = (cBx.value == 'N')?'visible':'hidden';
  for(var c = reqSpanNames.length;c--;)
  { 
    obj = getElStyle(reqSpanNames[c]); 
    if(obj)obj.visibility = vis; 
  }
} 

function uncheck(check1, check2)
{
  if(check2.checked == true)
  {
    check1.checked=true;
    check2.checked=false;
  }  
}


//Drop down Quick List 
function optionsList()
       {
        
         //number of drop down list options;
         // Each time a new option is added/removed, increase/decrease the number
         var nbOfOptions = 10; 

	 //Links array        
	 // Add here the new link;
         var links = new Array(nbOfOptions);
         links[0] = "profile/investor.html";
         links[1] = "productsAndServices/tradingServices/tse/accountManagement/index.html#buy";
         links[2] = "profile/secProfessional.html";
         links[3] = "invRelations/index.html";
	 links[4] = "profile/tsxListedCompany.html";
	 links[5] = "profile/tsxVentureListedCompany.html";
	 links[6] = "profile/listingInfo.html";
	 links[7] = "profile/media.html";
	 links[8] = "aboutUs/careers/index.html";
	 links[9] = "profile/tsxTechnologies.html";
         
         //Descriptions array
         // Add here the new description;
         var description = new Array(nbOfOptions);
	 description[0] = "Investors";
	 description[1] = "Institutional investors";
	 description[2] = "Securities professionals";
	 description[3] = "TSX Group shareholders";
	 description[4] = "TSX listed companies";
	 description[5] = "TSX Venture listed companies";
	 description[6] = "Companies looking to list";
	 description[7] = "Media/journalists";
	 description[8] = "Employment seekers";
	 description[9] = "TSX Technologies"; 
                  
	 document.write('<select name="Quick Links" onchange="location.href= /en/ + this.options[this.selectedIndex].value" width="100" class="body2">');	       
         document.write('<option>--Choose from this list--</option>');
         
         var i = 0;   
         while (i<nbOfOptions)
	 {
     	     document.write('<option value=' + links[i] + '>' + description[i] + '</option>');
      	     i++; 
      	 }    
           
          document.write('</select>');
       }
