﻿// JScript File

function hideIntro()
{
    document.getElementById('slider1').style.display = 'none';
    document.getElementById('hideLink').style.display = 'none';
    document.getElementById('showLink').style.display = 'block';
    eraseCookie('showIntro');
    createCookie('showIntro', 'false', 2);
}

function showIntro() {
    document.getElementById('slider1').style.display = 'block';
    document.getElementById('hideLink').style.display = 'block';
    document.getElementById('showLink').style.display = 'none';
    eraseCookie('showIntro');
    createCookie('showIntro', 'true', 2);
}

//function addFund(id) {
//    var win = popupCenter.GetWindowByName('editHeadline');
//    popupCenter.SetWindowContentUrl(win,'waiting.htm');
//    //popupCenter.SetWindowSize(win,'360px','250px');
//    popupCenter.ShowWindow(win);
//    //popupCenter.UpdateWindowPosition(win);
//    popupCenter.SetWindowContentUrl(win, 'addToPortfolio.aspx?fundId=' + id);
//}

function addFund(id) {
    var win = popupCenter.GetWindowByName('editHeadline');
    popupCenter.SetWindowContentUrl(win, 'waiting.htm');
    //    popupCenter.SetWindowSize(win,740,450);
    popupCenter.ShowWindow(win);
    //    popupCenter.ShowWindowAtElement(win,element);
    //popupMain.ShowWindowAtPos(win,310,130);
    popupCenter.SetWindowContentUrl(win, 'addToPortfolio.aspx?fundId=' + id);
    //    popupCenter.SetWindowSize(win,740,450);
}      

function ShowHelpWindow(element) {
    var win = popupMain.GetWindowByName('help_HotETFs');
//    popupMain.SetWindowSize(win,190,120);
//    popupMain.ShowWindowAtElementByID(win,'imgHelpHotETFs');
    popupMain.ShowWindow(win);
    popupMain.SetWindowSize(win,190,170);
    document.getElementById('ctl00_popBeta_CIF2').style.height = '170px';
}

function ShowHeadlineWindow(element, popup, id) 
{
    var win = popupCenter.GetWindowByName('editHeadline');
    popupCenter.SetWindowContentUrl(win,'waiting.htm');
//    popupCenter.SetWindowSize(win,740,450);
    popupCenter.ShowWindow(win);
//    popupCenter.ShowWindowAtElement(win,element);
    //popupMain.ShowWindowAtPos(win,310,130);
    popupCenter.SetWindowContentUrl(win,'editHeadline.aspx?headlineId=' + id);
//    popupCenter.SetWindowSize(win,740,450);
}

function ShowSubscribeWindow(element) {
    var win = popupCenter.GetWindowByName('editHeadline');
    popupCenter.SetWindowContentUrl(win, 'waiting.htm');
    //    popupCenter.SetWindowSize(win,740,450);
    popupCenter.ShowWindow(win);
    //    popupCenter.ShowWindowAtElement(win,element);
    //popupMain.ShowWindowAtPos(win,310,130);
    popupCenter.SetWindowContentUrl(win, 'subscribe.aspx');
    //    popupCenter.SetWindowSize(win,740,450);
}

function ShowLoginWindow(element) 
{
    var win = popupCenter.GetWindowByName('editHeadline');
    popupCenter.SetWindowContentUrl(win,'waiting.htm');
//    popupCenter.SetWindowSize(win,740,450);
     popupCenter.ShowWindow(win);
//   popupCenter.ShowWindowAtElement(win,element);
    popupCenter.SetWindowContentUrl(win,'loginSmall.aspx');
//   popupCenter.SetWindowSize(win, 710, 410);
//   document.getElementById('ctl00_ASPxPopupControl1_CIF0').height = '410px';

}

function ShowWindow(width, height) {
    var screenerWindow = popupMain.GetWindowByName('screener');
    popupMain.ShowWindow(screenerWindow);
    popupMain.SetWindowSize(screenerWindow, width, height);
    popupMain.UpdatePosition();
}

function logout() 
{
    etfWebService.logout(onLogoutComplete,onLogoutError);
}

function onLogoutComplete() 
{
    window.document.location.reload();
}

function onLogoutError() 
{

}

function CloseLoginWindow() 
{
    var win = popupCenter.GetWindowByName('editHeadline');
    popupCenter.HideWindow(win);
    window.document.location.reload();
}

function emailIt(element, id) 
{
    var win = popupCenter.GetWindowByName('editHeadline');
    popupCenter.SetWindowContentUrl(win,'waiting.htm');
//    popupCenter.SetWindowSize(win,660,410);
    popupCenter.ShowWindow(win);
//    popupCenter.ShowWindowAtPos(win,310,130);
    popupCenter.SetWindowContentUrl(win,'emailIt.aspx?hId=' + id);
//    popupCenter.SetWindowSize(win,660,410);

}

function refreshNews(param) 
{
    alert(param);
    dvNews.PerformCallback(param);
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	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 c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function openNewWindow(href) {
    window.open(href,"news","");
}
function openNewWindow2(href) {
    window.open(href,"factSheet","toolbar=0,statusbar=1,location=0,resizable=1,scrollbars=1");
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
         curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

mouseOverRow = 0;
mouseOverCol = 0;

function checkForEnter(submitButtonName) 
{
    if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
    {
        document.getElementById(submitButtonName).click();
        return false;
    } 
    else return true;
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
 
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
 
var preloadFlag = false;
function preloadImages() {
    if (document.images) {
        testimgmap_01_ImageMap_01_over = newImage("img/testimgmap_01-ImageMap_01_o.gif");
        testimgmap_01_ImageMap_04_over = newImage("img/testimgmap_01-ImageMap_04_o.gif");
        testimgmap_01_ImageMap_03_over = newImage("img/testimgmap_01-ImageMap_03_o.gif");
        testimgmap_01_ImageMap_02_over = newImage("img/testimgmap_01-ImageMap_02_o.gif");
        preloadFlag = true;
    }
}