﻿//Functions written by Frank Furnes - Be Found AS
/*
  ShowTooltip
  Shows a tooltip , but must have a divtag to show
*/
function ShowTooltip(evt,txt,whichLayer)
{
  document.getElementById(whichLayer).innerHTML=txt; 
  x = evt.clientX;
  y = evt.clientY;
  var style2 = document.getElementById(whichLayer).style;
  style2.left = x+10 + "px";
  style2.top = y  +  "px";
  style2.display = style2.display? "":"block";
}

function HideTooltip(whichLayer)
{
var style2 = document.getElementById(whichLayer).style;
style2.display = "none";
}

function showMessageBox(ev) {
    ev.preventDefault();    
    var modalPopupBehavior = $find('programmaticModalPopupBehavior2');
    modalPopupBehavior.show();
}

function hideMessageBox(ev) {
    ev.preventDefault();        
    var modalPopupBehavior = $find('programmaticModalPopupBehavior2');
    modalPopupBehavior.hide();
}

//Shows the popup (Tooltip) on verdirapport
  function showPopup(parentID2, positioningMode, content, evt)
        {
            /*  The parentID is what element on the page my popup
                is going to be postioned on...and the position is
                determined from positioningMode the in variable passed in.
                
                Positioning Ints
                    Center: 1
                    BottomLeft: 2
                    BottomRight: 3
                    TopLeft: 4
                    TopRight: 5 
            */            
            var parentID = document.getElementById(parentID2).id
            // set the parentElementID to the parentID...the popup is positioned on this
            $find('popupBhvrPopupBehavior').set_parentElement($get(parentID)); 
            
            // set the positioningMode of where to position upon on the parentID
            $find('popupBhvrPopupBehavior').set_positioningMode(positioningMode); 
                    
            // fill the popup with what ever content you want...maybe result from json web service call
            $get('divPopup').innerHTML = content; 
                    
            // this is a work around to cancel the bubbling up done in the body that hides the popup
            evt.cancelBubble = true;
            
            // show the popup...
            $find('popupBhvr').showPopup();
        }
        
        function hidePopup()
        {
            $find('popupBhvrPopupBehavior').hide();
        }    
        
function fontBold(obj)
{
var i = obj.id;

if (document.getElementById)
{
// this is the way the standards work
  var style2 = document.getElementById(i).style;
  if(is.nav)
  {
    style2.fontSize = style2.fontSize? "":"15px";
    style2.backgroundColor= style2.backgroundColor? "":"#F3EBCF;";
  }
  else
  {
    style2.fontSize = style2.fontSize? "":"15";
    style2.backgroundColor= style2.backgroundColor? "":"#F3EBCF";
    
  }
  
}
else if (document.all)
{
// this is the way old msie versions work
  var style2 = document.all[i].style;
  style2.fontSize = style2.fontSize? "":"15px;";
  style2.backgroundColor= style2.backgroundColor? "":"#F3EBCF;";
}
else if (document.layers)
{
// this is the way nn4 works
  var style2 = document.layers[i].style;
  style2.fontSize = style2.fontSize? "":"15px;";
  style2.backgroundColor= style2.backgroundColor? "":"#F3EBCF;";
}

}

function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}

function changeExpanderPic(obj, path){

  if( obj.src == '/icons/folderminus.gif')
    obj.src= '/icons/folderplus.gif'
  else
    obj.src = '/icons/folderminus.gif';

}

function indextoolsLogin()
{
  var idLogin = 'http://ondemand.indextools.com/action/Login?eventSubmit_doLogin=1&bspid=1000&resid=1855621648&';
  var userid = document.getElementById("ctl00_ContentPlaceHolder1_userid").value;
  var pass = document.getElementById("ctl00_ContentPlaceHolder1_password").value;
  if (userid==""){
    alert('Vennligst skriv inn ditt brukernavn');
    return false;
  }
  if (pass==""){
    alert('Vennligst skriv inn ditt passord');
    return false;
  }
    
  idLogin = idLogin + 'userid=' + userid + '&password=' + pass;
  window.open(idLogin,'indexTools','');
}
function usernameFocus(){
  var username = document.getElementById("ctl00_ContentPlaceHolder1_txtbrukernavn");
  username.focus();
}

function changeSize(styleToSelect){
 $get('primarycontent').className = styleToSelect;
}

function onMouseOverClass(styleToSelect, styleName){
  //styleToSelect.className = 'onMouseOverClass';
  styleToSelect.className = styleName;
}
function onMouseOutClass(styleToSelect, styleName){
  //styleToSelect.className = 'onMouseOutClass';
  styleToSelect.className = styleName;
}

function changeImage(imgid,picobj)
{
  var obj = document.getElementById(imgid).src=picobj;
}

function setUsername(obj)
{
  var username = document.getElementById("ctl00_ContentPlaceHolder1_AddUsers1_txtusername");
  var email = document.getElementById("ctl00_ContentPlaceHolder1_AddUsers1_txtEmail");
  var pass = document.getElementById("ctl00_ContentPlaceHolder1_AddUsers1_txtpassword");
  if (obj.checked){
  username.value = email.value;
  pass.focus();
  }
  else{
  username.value = '';
  username.focus();
  }
}
function openExport(){
 var objExport = window.open('/Components/Export.aspx?export=1&fname=Rapport','ExportExcel','width=400,height=200');
}
function openExportExcel(strNum){

var strUrl='/Components/Export.aspx?export=1&';
var strName='';
if(strNum=="1")
{
  //Konverteringsrapport
  strName = 'Konverteringsrapport';
  
}else if(strNum=="2")
{
  //Avkastningsrapport
  strName ='Avkastningsrapport';
}else if(strNum=="3")
{
  //Verdirapport
  strName ='Verdirapport';
}
strUrl = strUrl + 'types=' + strNum + '&fname=' + strName;
var objExport = window.open(strUrl,'ExportExcel','width=400,height=200');
}
function openExportToPdf(){
 var objExport = window.open('/Components/Export.aspx?export=2&fname=Rapport','ExportPdf','width=400,height=200');
}


function openExportPdf(strNum){

var strUrl='/Components/Export.aspx?export=2&';
var strName='';
if(strNum=="1")
{
  //Konverteringsrapport
  strName = 'Konverteringsrapport';
  
}else if(strNum=="2")
{
  //Avkastningsrapport
  strName ='Avkastningsrapport';
}else if(strNum=="3")
{
  //Verdirapport
  strName ='Verdirapport';
}
strUrl = strUrl + 'types=' + strNum + '&fname=' + strName;
var objExport = window.open(strUrl,'ExportPdf','width=400,height=200');
}

function openExportToPdf(){
 var objExport = window.open('/Components/Export.aspx?export=2&fname=Rapport','ExportPdf','width=400,height=200');
}

/*function showGraph()
{
  $find('programmaticDetailsPopup').show();
}
*/