var mFunctionShowTabName = "";
/*******************************************************************************************/
function hideTabsSection(TabCollectionID, TabSelected){
  try{
    var objTabsPanel = document.getElementsByName(TabCollectionID);

    if (isNaN(objTabsPanel.length)){
	     objTabsPanel.style.display="none";
    }
    else{
	    for (var i=0; i<objTabsPanel.length;i++){
		    if (i != TabSelected) objTabsPanel[i].style.display="none";
	    }
    }
  }catch(ex){}
}
/*******************************************************************************************/
function restarTabItem(TabCollectionID){

  var objTabItems = document.getElementsByName(TabCollectionID);

	var mBrowser = detectBrowser()
    
  var mTextTab = "";

  for (var i=0; i<objTabItems.length;i++){
    switch (mBrowser){
			case "IE":
				mTextTab = objTabItems[i].outerText;
				break;
			case "FF":
				mTextTab = objTabItems[i].textContent;
				break;
			case "SF":
				mTextTab = objTabItems[i].outerText;
				break;            
		}
    
    objTabItems[i].innerHTML = "<table cellpadding=0 cellspacing=0 style='width:" + objTabItems[i].style.width + "'><tr>" +
		"<td class=leftI><table cellpadding='0' cellspacing='0'><tr><td></td></tr></table></td>" +
		"<td class=centerI style='width:" + (objTabItems[i].style.width.toString().replace('px', '') - 14) + "px;'><table class=centerITbl cellpadding='0' cellspacing='0' style='width:" + (objTabItems[i].style.width.toString().replace('px', '') - 14) + "px;'><tr><td onclick='" + mFunctionShowTabName + "' style='width:" + (objTabItems[i].style.width.toString().replace('px', '') - 14) + "px'>" + mTextTab + "</td></tr></table></td>" +
		"<td class=rightI><table cellpadding='0' cellspacing='0'><tr><td></td></tr></table></td>" +
		"</tr></table>";
  }
}
/*******************************************************************************************/
function showTabOption(TabOptionObject){
	
	var mBrowser = detectBrowser()
    
  var mTextTab = "";

	switch (mBrowser){
		case "IE":
			mTextTab = TabOptionObject.outerText;
			break;
		case "FF":
			mTextTab = TabOptionObject.textContent;
			break;
		case "SF":
			mTextTab = TabOptionObject.outerText;
			break;            
	}

	TabOptionObject.innerHTML = "<table cellpadding=0 cellspacing=0 style='width:" + TabOptionObject.style.width + "'><tr>" +
  "<td class=left style='width:7px'></td>" +
  "<td class=center style='width:" + (TabOptionObject.style.width.toString().replace('px', '') - 14) + "px;'><table class=center cellpadding='0' cellspacing='0' style='cursor:pointer;width:" + (TabOptionObject.style.width.toString().replace('px', '') - 14) + "px;'><tr><td onclick='" + mFunctionShowTabName + "' style='width:" + (TabOptionObject.style.width.toString().replace('px', '') - 14) + "px'>" + mTextTab + "</td></tr></table></td>" +
  "<td class=right style='width:7px'></td>" +
  "</tr></table>";

}
/*******************************************************************************************/
function showTab(Objeto, TabPanelIndex, HideVP, IsSubTab, SubTabIndex, SubTabIndexToShow){

  /**************************************************/
  //Manejo de los tab principales
  /**************************************************/
  //hideTabsSection("dTabPanel",TabPanelIndex);
  //if (TabPanelIndex >= 0) document.all("dTabPanel")[TabPanelIndex].style.display="block";
  
  var mBrowser = detectBrowser()

	switch (mBrowser){
		case "IE":
			if(Objeto.id != "tdTabItem"){
				while(Objeto.id != "tdTabItem"){
					Objeto = Objeto.parentElement;
				}
			}
			break;
		case "FF":
			if(Objeto.id != "tdTabItem"){
				while(Objeto.id != "tdTabItem"){
					Objeto = Objeto.parentNode;
				}
			}
			break;
		case "SF":
			if(Objeto.id != "tdTabItem"){
				while(Objeto.id != "tdTabItem"){
					Objeto = Objeto.parentNode;
				}
			}
			break;            
	}
  
  
	try{
		if(Objeto.className.toString().indexOf("showTab", 0) > -1){
			mFunctionShowTabName = Objeto.className;
		}
	}catch(e){}

	/*if(Objeto.tagFunction){
		mFunctionShowTabName = Objeto.tagFunction;
	}*/

  restarTabItem(Objeto.id);

  showTabOption(Objeto);
  /**************************************************/

  /**************************************************/
  //Manejo de los sub tabs
  /**************************************************/

  if (typeof(SubTabIndexToShow) != "undefined"){

    if (typeof(IsSubTab) == "undefined") IsSubTab = false;

    var SubTabID = "tdTabItem" + SubTabIndex;

    if (!IsSubTab && SubTabIndexToShow >= 0){

      hideTabsSection("SubTab",SubTabIndex);

      try{
        document.all("SubTab")[SubTabIndex].style.display="block";
      }catch(ex){
        document.all("SubTab").style.display="block";
      }

      restarTabItem(SubTabID);

      if (document.all("tdTabItem" + SubTabIndex)[SubTabIndexToShow] == null){
        showTabOption(document.all("tdTabItem" + SubTabIndex));
        document.all("tdTabItem" + SubTabIndex).onclick()
      }else{
        showTabOption(document.all("tdTabItem" + SubTabIndex)[SubTabIndexToShow]);
        document.all("tdTabItem" + SubTabIndex)[SubTabIndexToShow].onclick()
      }
    }
    else{
      if(!IsSubTab) hideTabsSection("SubTab",SubTabIndex);
    }
  }
  else{
    if (!IsSubTab) hideTabsSection("SubTab",-1);
  }
  /**************************************************/

  try{
    if (HideVP) hideValidatorPanel();
  }catch(ex){}
}

//**************************************************
function navigatePage(page, category){
  switch(page){
		case 1:
			if(category != undefined){window.location = "videoList.aspx?category=" + category;}else{window.location = "videoList.aspx?category=guitar";}
			break;
		case 2:
			break;
	}  
}
//**************************************************
function statusMouse(status, control){
	switch(status){
		case 1:
			control.style.cursor = "pointer"
			break;
		case 2:
			control.style.cursor = "default"
			break;
	}
}
//**************************************************
function setupCheckElement(element){
    var mCollection = document.getElementsByName(element)
    
    for (i=0;i<mCollection.length;i++){
        mCollection[i].className = "noBorder"
    }
}
//**************************************************
function setupForm(elementId){
    
    return
    
    var element = document.getElementById(elementId)
    
    element.style.display = "none"
    
    var height = element.parentNode.clientHeight
    var width = element.parentNode.clientWidth
    element.style.overflow = "scroll"
    element.style.display = "block"
    element.style.height = (height - 10) + 'px'
    element.style.width = width + 'px'
    
}
//**************************************************
function changeSelectedValue(elementName, value){
    var elementCollection = document.getElementsByTagName("input")
   
    if (elementCollection.length){
        
        for (i=0;i<elementCollection.length;i++){
            var mElement = elementCollection[i]  
            
            if (mElement.type == "checkbox"){
                var mCurName = new String(mElement.id)
                                
                if (mCurName.indexOf(elementName) !== -1){
                    mElement.checked = value;
                    mElement.onclick();
                }
            }
        }    
    }else{
        elementCollection.checked = value
    
    }
}
/***************************/
function stopEvent(e){
    if (e == null){
        return
    }
    var mBrowser = detectBrowser()
    
    switch (mBrowser){
        case "IE":
            e.returnValue = false
            break;
        case "FF":
            e.preventDefault()
            break;
        case "SF":
            e.stopPropagation()
            break;            
    }
    
}
//**************************************************
function detectBrowser(){
    var mReturnValue = null
    var mAgent = new String(navigator.userAgent.toLowerCase())
    
    if (mAgent.indexOf("msie") !== -1){
        mReturnValue = "IE"
    }else if(mAgent.indexOf("firefox") !== -1){
        mReturnValue = "FF"
    }else if(mAgent.indexOf("safari") !== -1){
        mReturnValue = "SF"
    }
        
    return mReturnValue

}
//**************************************************
function frameParentClose(){
    var frame = parent.document.getElementById("frame")
    frame.style.display = "none"
}
//**************************************************
function frameClose(){
    var frame = document.getElementById("frame")
    frame.style.display = "none"
}
var timerReadyStateID = null
//**************************************************
function frameReadyState(){
   
    
    var frame = document.getElementById("frame")
    var frameDummy = document.getElementById("frameDummy")
    
    var frameTitle = frame.contentWindow.document.title
    
    if (frameTitle !== ""){
    
        frameDummy.contentWindow.location.href = "about:blank"
        window.clearInterval(timerReadyStateID)
    }
        
    
}
//**************************************************
function frameOpen(url, width, height){
    var frame = document.getElementById("frame")
    

    width = width + 10
    height = height + 10
    
    timerReadyStateID = window.setInterval("frameReadyState()", 10);

    window.setTimeout("frameReadyState()", 100);    
    frame.contentWindow.location.href = url
    
    
    frame.style.position = "absolute"
    frame.style.width = width
    frame.style.height = height

    frame.style.left = ((document.body.clientWidth - width) / 2)
    frame.style.top = ((document.body.clientHeight - height) / 2)
    frame.style.display = ""
}
//**************************************************
function getControlValue(controlName){    
    var mValue = new String()
    mValue = document.getElementById(controlName).value
    return mValue
}
//**************************************************
function getControlInnerText(controlName){    
    var mValue = new String()
    if (detectBrowser()=="FF"){
		mValue = document.getElementById(controlName).textContent
    }else{
		mValue = document.getElementById(controlName).innerText
    }
    return mValue
}
//**************************************************
function DoCallBack(functionName, functionArguments, endFunction, context){


    __theFormPostData = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&"    
    
    WebForm_DoCallback('__Page', functionName + '|' + functionArguments, endFunction, context, null, false)        
}
/***************************/
function DoCallBack2(functionName, mData, endFunction, context){
    __theFormPostData = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&"    
    
    WebForm_DoCallback('__Page', functionName + mData, endFunction, context, null, false)        
}
/***************************/
function setupHtmlGrid(elementName, html){
    var elementMainTable = document.getElementById(elementName + "_main_table")
    elementMainTable.parentNode.innerHTML = html        
}
/***************************/
function setupHtmlCombo(elementName, html){
    document.getElementById(elementName).name = "__"
            
    document.getElementById(elementName).parentNode.innerHTML = html

}
/***************************/
function setupGrid(elementId){
    
    
    var element = document.getElementById(elementId)
    var mainTable = document.getElementById(elementId + "_main_table")            
    var result = document.getElementById(elementId + "_result")
    var height = mainTable.parentNode.parentNode.parentNode.clientHeight
    
    mainTable.style.display = ""
    result.style.display = ""
    return
    
    
    var parentHeight = new String(mainTable.parentNode.parentNode.style.height)
    var hasFooter = false
    try{
        
        if (document.getElementById(elementId + "_footer") !== null){
            hasFooter = true
        }else{
            hasFooter = false
        }
        
    }
    catch(ex){
        hasFooter = false
    }
    
    
    var mFixHeight = hasFooter ? 57 : 35
    
    
    if (parentHeight.indexOf("%") == -1){
        mainTable.style.height = height + "px"
        result.style.height = height + "px"   

    }else{
        mainTable.style.height = (height - mFixHeight) + "px"
        result.style.height = (height - mFixHeight) + "px"
    }
    
    
    mainTable.style.display = ""
    result.style.display = ""
    
}
/***************************/
function setFullScreen(){

    try{
        window.moveTo(0,0)
        window.resizeTo(screen.width,screen.height-30)

    }catch(ex){

    }

}
/***************************/
function setSelectedValue(elementName, data){
    var elementCollection = document.getElementsByName(elementName)
    var mArray = data.split(":")
    
    if (elementCollection.length){
        
        for (i=0;i<elementCollection.length;i++){
            var mElement = elementCollection[i]  
            
            for (a=0;a < mArray.length;a++){
                if (mElement.value == mArray[a]){
                    mElement.checked = true
                }                
            
            }
        }    
    }else{
        for (a=0;a < mArray.length;a++){

            for (a=0;a < mArray.length;a++){
                if (elementCollection.value == mArray[a]){
                    elementCollection.checked = true
                }                
            
            }
        }
    
    }

}
/***************************/
function getSelectedValue(elementName){
    
    var elementCollection = document.getElementsByName(elementName)
    var mArray = new Array()
    
    if (elementCollection.length){
        
        for (i=0;i<elementCollection.length;i++){
            var mElement = elementCollection[i]            
            if (mElement.checked){
                mArray.push(mElement.value)
            }                
        }    
    }else{
        if (elementCollection.checked){
            mArray.push(elementCollection.value)
        }
    
    }
    
    var mReturnValue = mArray.join(":")
    
    return mReturnValue
}

/***************************/
function result_onscroll(elementName){

	try{
		document.getElementById(elementName + "_resultHeader").style.left = -document.getElementById(elementName + "_result").scrollLeft
						
	}catch(e){
		alert(e)
	}
	
}
var mFormData = null
//**************************************************
function DoFormCallBack(functionName, dummy, endFunction){
    
    mFormData = new String()
    InitFormCallback()
    
    __theFormPostData = "__FORMCALLBACK=1&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&" + mFormData
    
    WebForm_DoCallback('__Page', functionName, endFunction, null, null, false)        
}
//**************************************************
function InitFormCallback() {
    var count = theForm.elements.length;
    var element;
    for (var i = 0; i < count; i++) {
        element = theForm.elements[i];
        var tagName = element.tagName.toLowerCase();
        if (tagName == "input") {
            var type = element.type;
            
            if ((type == "text" || type == "hidden" || type == "password" || ((type == "checkbox" || type == "radio") && element.checked)) && (element.id != "__EVENTVALIDATION" && element.id != "__VIEWSTATE" && element.id != "__EVENTTARGET" && element.id != "__EVENTARGUMENT")) {
                
                InitCallbackAddField(element.name, element.value);
            }
        }
        else if (tagName == "select") {
            var selectCount = element.options.length;
            for (var j = 0; j < selectCount; j++) {
                var selectChild = element.options[j];
                if (selectChild.selected == true) {
                    InitCallbackAddField(element.name, element.value);
                }
            }
        }
        else if (tagName == "textarea") {
            InitCallbackAddField(element.name, element.value);
        }
    }
}
//**************************************************
function InitCallbackAddField(name, value) {
    mFormData += name + "=" + WebForm_EncodeCallback(value) + "&";
}
//**************************************************************************
function expand(sectionName, linkName){
    var element = document.getElementById(sectionName)
    var linkElement = document.getElementById(linkName)
    var newImageSrc = ""
    
    if (element.style.display == "none"){
        element.style.display = ""
        newImageSrc = "/library/images/icons/collapse.gif"
    }else{
        element.style.display = "none"    
        newImageSrc = "/library/images/icons/expand.gif"
    }
    
    var imageElement = linkElement.childNodes(0)
    imageElement.src = newImageSrc
    
}
//**************************************************************************
function buildSection2(wind, secText){
	var vSecHTML = new String("");
	vSecHTML += "<table style='width:100%;height:24px'  border='0' cellpadding='0' cellspacing='0'>"
	vSecHTML += "<tr>"
	vSecHTML += "<td class='lSection'><span style='width:4px'></span></td>"
	vSecHTML += "<td class='cSection' style='width:100%'>" + secText + "</td>"
	vSecHTML += "<td class='rSection'><span style='width:4px'></span></td>"
	vSecHTML += "</tr>"
	vSecHTML += "</table>"
	
	wind.document.write(vSecHTML);
}
function buildSection(secText){
	var vSecHTML = new String("");
	vSecHTML += "<table style='width:100%;height:24px'  border='0' cellpadding='0' cellspacing='0'>"
	vSecHTML += "<tr>"
	vSecHTML += "<td class='lSection' ></td>"
	vSecHTML += "<td class='cSection' style='width:100%;padding-left:4px;' align='left'>" + secText + "</td>"
	vSecHTML += "<td class='rSection' style='padding-left:4px;'></td>"
	vSecHTML += "</tr>"
	vSecHTML += "</table>"
	
	document.write(vSecHTML);
}
//**************************************************************************
function uc(msg){
	alert(msg);
}
//**************************************************************************
function unot(){}
//**************************************************************************
function openWindow2(url, windowHeight, windowWidth){        
    var windowLeft = (screen.availWidth / 2) - (windowWidth / 2);
    var windowTop = ((screen.availHeight / 2) - (windowHeight / 2)) - 20;
    var windowName = url.replace(/\W/g, "_")
    var newWindow = window.open(url, windowName, "height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);
}
//**************************************************************************
function msjNotLogged(){
	alert("Please Log In to use this option")
}
//**************************************************************************
function getKeyCode(e){
	// handle i.e. (window.event) and firefox (e)
	var eventInstance = window.event ? event : e;
	// handle i.e. (charCode) and firefox (keyCode)
	var unicode = eventInstance.charCode ? eventInstance.charCode : eventInstance.keyCode;
	
	if (detectBrowser()=="SF" && unicode==3){unicode=13}
	//var key = String.fromCharCode(unicode);
	return unicode
}
/*******************************************************************************************/
var _CurrentWindow;
var _DialogArguments;
var _DialogReturn;

function openWindow(url, windowHeight, windowWidth, resize, Name, Mode, MySendArgs, endFunction){		
	windowLeft = (screen.availWidth / 2) - (windowWidth / 2);
	windowTop  = ((screen.availHeight / 2) - (windowHeight / 2)) - 20;	
	
	var mUrl = new String(window.location.pathname + url);
	var mResize = "";

	if (typeof(Mode) == "undefined" || Mode == 1){
		if (resize == null){
			mResize = "resizable=false";
		}else{
			mResize = "resizable=" + (resize ? "yes":"no");
		}
		if (Name == null) {
			var newWindow = window.open(url, "", mResize + ", height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);
			return newWindow;
		}else{
			var newWindow = window.open(url, Name, mResize + ", height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);
			return newWindow;
		}
	}
	else{
		_DialogArguments = MySendArgs
		_CurrentWindow = showPopWin(url, windowWidth, windowHeight + 60, endFunction)

	}
}
/*******************************************************************************************/
function openWindowHide(url, windowHeight, windowWidth, resize, Name, Mode, MySendArgs, endFunction){		
	windowLeft = screen.availWidth;
	windowTop  = screen.availHeight;	
	
	var mUrl = new String(window.location.pathname + url);
	var mResize = "";

	if (typeof(Mode) == "undefined" || Mode == 1){
		if (resize == null){
			mResize = "resizable=false";
		}else{
			mResize = "resizable=" + (resize ? "yes":"no");
		}
		if (Name == null) {
			var newWindow = window.open(url, "", mResize + ", height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);
			return newWindow;
		}else{
			var newWindow = window.open(url, Name, mResize + ", height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);
			return newWindow;
		}
	}
	else{
		_DialogArguments = MySendArgs
		_CurrentWindow = showPopWin(url, windowWidth, windowHeight + 60, endFunction)

	}
}
/*******************************************************************************************/
function getURLRoot(){
    var currentUrl = new String(document.location.pathname);
	var mUrlSegments = currentUrl.split("/");
	var supportUrl = document.location.protocol + "//" + document.location.host;
	return supportUrl;
}
function openWindow3(url, windowHeight, windowWidth, resize, Name, Mode, MySendArgs, endFunction){           
      windowLeft = (screen.availWidth / 2) - (windowWidth / 2);

      windowTop  = ((screen.availHeight / 2) - (windowHeight / 2)) - 20;      
      var mUrl = new String(window.location.pathname + url);

      var mResize = "";
      if (typeof(Mode) == "undefined" || Mode == 1){

            if (resize == null){

                  mResize = "resizable=false";

            }else{

                  mResize = "resizable=" + (resize ? "yes":"no");

            }

            if (Name == null) {

                  var newWindow = window.open(url, "", mResize + ", height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);

                  return newWindow;

            }else{

                  var newWindow = window.open(url, Name, mResize + ", height=" + windowHeight + ",width=" + windowWidth + ",status=yes, left=" + windowLeft + ", top=" + windowTop);

                  return newWindow;

            }

      }

      else{

            _DialogArguments = MySendArgs

            _CurrentWindow = showPopWin(url, windowWidth, windowHeight + 60, endFunction)

 

      }

}
/*********************************************************/
function refreshCaptcha(){
    var thisDate = new Date()
    document.getElementById("imgCaptcha").src = "/library/captcha/captchaCode.aspx?force=1&rnd=" + thisDate.valueOf().toString();
}
/*********************************************************/