﻿
// JScript File
/*var prefix='ctl00_ContentPlaceHolder1_HorizontalSplitter1_ctl01_ctl01_';
var num=71;*/
var prefix='ctl00_ContentPlaceHolder1_';
var num=39;
var TKiTimeoutId=null;
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)

function getMouseXY(e) {
    if (IE) { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;
    }
    else {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX;
        tempY = e.pageY;
    }  
    if (tempX < 0){tempX = 0;}
    if (tempY < 0){tempY = 0;}  
    return true;
}

if(window.location.href.toLowerCase().indexOf('mytracks')!=-1){
    /*prefix='ctl00_ContentPlaceHolder1_';
    num=39;*/
    }

    function Onmouseover(button){
            button.style.color="#fff000";
            var textboxId=button.id.replace('L','T');
            ShowPopup(document.getElementById(textboxId).value);
            
    }
    function Onmouseout(button){
            HidePopup();
            button.style.color="#ffffff";
    }
    function ShowPopup(header){
        document.getElementById('popup').style.visibility='visible';
        document.getElementById('popup').style.left=tempX;
        document.getElementById('popup').style.top=290;
        document.getElementById('popup').innerHTML=header;
        
    }
    function HidePopup(){
        document.getElementById('popup').style.visibility='hidden';
    }

function Selected(id){
        if(document.getElementById(prefix + 'TabControl1_selectedItem').value==id)
            return;
        var labels=document.getElementsByTagName('input');
        var clsName=document.getElementById(id).className;
        var buttonSize=clsName.substring(17,18);
        for(var labelLoop=1;labelLoop<labels.length;labelLoop++){
           if(labels[labelLoop].id.substring(num-1,num)=='L'){
            labels[labelLoop].className ='nonSelectedButton' + buttonSize;
           }
        }
        document.getElementById(prefix + 'TabControl1_selectedItem').value=id;
        //document.getElementById(id).style.backgroundColor='orange';
        //document.getElementById(id).style.color='white';
        document.getElementById(id).className ='selectedButton' + buttonSize;
        //var myid=prefix + 'TabControl1_T' + id.substring(71,72);
        document.getElementById(prefix + 'TabControl1_selectedTextbox').value=prefix +'TabControl1_T' + id.substring(num,id.length );
        __doPostBack(id,'');
    }
function AddStatus(){
    document.getElementById(prefix + 'TabControl1_selectedItem').value=-1;
    document.getElementById(prefix + 'TabControl1_selectedTextbox').value=-1;
}
 
function DoubleClick(lid,tid){
window.clearTimeout(TKiTimeoutId);
   // if(lid!=document.getElementById(prefix + 'TabControl1_selectedItem').value)
  //{//only selected tab can renamed
    //return false;
  //}
  var label=document.getElementById(lid);
  var textbox=document.getElementById(tid);
  /*textbox.value=label.value;*/
  
  label.style.display = 'none';
  textbox.style.display = '';
  
  textbox.focus();
  return false;
}  
function StartSingleClick(e,lid,tid){
    var functionName=String.format("Label_Click('{0}','{1}', '{2}')",e.button,lid,tid);
    TKiTimeoutId = setTimeout(functionName, 200);
    //Label_Click(e.button,lid,tid);
}
function Label_Click(e,lid,tid) {
var mvalue=1
if(GettingBrowser()=='FF')
    mvalue=0;
    
  if(e==mvalue)
  {//change tab
    Selected(lid);
    return;
  }
  

 
  if(lid!=document.getElementById(prefix + 'TabControl1_selectedItem').value)
  {//only selected tab can renamed
    return false;
  }
  var label=document.getElementById(lid);
  var textbox=document.getElementById(tid);
  textbox.value=label.value;
 
  label.style.display = 'none';
  textbox.style.display = '';
  
  textbox.focus();
  return false;
}

// If the enter key is pressed,
//  then blur the TextBox.
function TextBox_Keydown(e,tid,lid) {
var keynum;

if(window.event) // IE
  {
  keynum = e.keyCode;
  }
else if(e.which) // Netscape/Firefox/Opera
  {
  keynum = e.which;
  }

  if (keynum== 13) {
  if(window.event){
 		e.returnValue = false;
 		e.cancelBubble = true;5
 	}else{
 		e.preventDefault();
 		e.stopPropagation();
 	}
    //TextBox_Blur(document.getElementById(prefix + 'TabControl1_selectedTextbox').value,document.getElementById(prefix + 'TabControl1_selectedItem').value);
    TextBox_Blur(tid,lid);
  }
}

function TextBox_Blur(tid,lid) {
    var label=document.getElementById(lid);
    var textbox=document.getElementById(tid);
    var userId=document.getElementById(prefix + 'TabControl1_currentUser');
    document.getElementById(prefix + 'TabControl1_changedTitle').value=textbox.value;
      label.value = textbox.value;
      textbox.style.display = 'none';
      label.style.display = '';
    document.getElementById(prefix + 'TabControl1_dirtyRows').value+=':' + lid;
     //eval("__doPostBack('TabControl1','')");
     document.getElementById(prefix + 'TabControl1_post').click();
}

function DeleteRow(event){
    if(event.keyCode==48)
        alert(1);
}

function DeleteFolder(){
    returnValue=confirm('Do you really want to delete them?');
    return returnValue;
}

function onUpdating(control,divControl){
        return;
        if(divControl=='updateProgressDiv1' && document.getElementById('ctl00_ContentPlaceHolder1_StillUpdating').value!='1')
           return;
        if(divControl=='updateProgressDiv' && document.getElementById('ctl00_ContentPlaceHolder1_StillUpdating').value=='1')
           return;
        // get the update progress div
        var updateProgressDiv = $get(divControl); 

        //  get the gridview element        
        var gridView = $get(control);
        
        // make it visible
        updateProgressDiv.style.display = '';        
        
        // get the bounds of both the gridview and the progress div
        var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
        var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);
        
        var x;
        var y;
        
        //    do the math to figure out where to position the element
        //if($get('rdoCenter').checked){
            //  center of gridview
            //x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
            x = gridViewBounds.x + 20;
            y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(updateProgressDivBounds.height / 2) - 6;        
            alert(y);
            
        //}
       /* else if($get('rdoTopLeft').checked){
            //  top left of gridview
            x = gridViewBounds.x;
            y = gridViewBounds.y;
        }
        else{
            //  top right of gridview
            x = (gridViewBounds.x + gridViewBounds.width - updateProgressDivBounds.width);
            y = gridViewBounds.y;
        }*/

        //    set the progress element to this position
        Sys.UI.DomElement.setLocation (updateProgressDiv, x, y);           
    }

    function onUpdated(control) {
      return;
      setTimeout('donothing',1000);
        if(control=='updateProgressDiv1' && document.getElementById('ctl00_ContentPlaceHolder1_StillUpdating').value=='1')
           return;
            
        // get the update progress div
        var updateProgressDiv2 = $get(control); 
        // make it invisible
        if(updateProgressDiv2==null)
            return;
        updateProgressDiv2.style.display = 'none';
    }
    function donothing(){
    }

function KeyDownOnSaveButton(event){
    if(event.button=='undefined'){
     alert('undefined')
        return false;
    }
     else{
        return true;
        alert(event.button)
        }
}