function getCookie(c_name)
{
  if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
  return "";
}

function PageLoad()
{
	var DefaultSourceLang = getCookie('DefaultSourceLang');
	
	if (DefaultSourceLang == '0')
	{
		SetSourceLang(0);
	}
	else if (DefaultSourceLang == '1')
	{
		SetSourceLang(1);
	}
	else if (DefaultSourceLang == '2')
	{
		SetSourceLang(2);
	};
}

function SetSourceLang(ShowBlockType)
{    
    var lists = document.getElementsByTagName("pre");
    for (var i = 0; i < lists.length; i++) 
    {  
    	if (lists[i].className == "SourceVBA")
    	{
    		lists[i].style.display = (ShowBlockType == 0) ? "block" : "none";
    	}
    	else if (lists[i].className == "SourceVBNET")
    	{
    		lists[i].style.display = (ShowBlockType == 1) ? "block" : "none";
    	}
    	else if (lists[i].className == "SourceCSHARP")
    	{
    		lists[i].style.display = (ShowBlockType == 2) ? "block" : "none";
    	};
    };   
    
	lists = document.getElementsByTagName("a");
    for (var i = 0; i < lists.length; i++) 
    {  
    	if (lists[i].id == "SourceVBA")
    	{
    		lists[i].className = (ShowBlockType == 0) ? 'SourceLinkSelected' : 'SourceLink';
    	}
    	else if (lists[i].id == "SourceVBNET")
    	{
    		lists[i].className = (ShowBlockType == 1) ? 'SourceLinkSelected' : 'SourceLink';
    	}
    	else if (lists[i].id == "SourceCSHARP")
    	{
    		lists[i].className = (ShowBlockType == 2) ? 'SourceLinkSelected' : 'SourceLink';
    	};
    };    
    
    document.cookie = 'DefaultSourceLang=' + ShowBlockType.toString() + '; expires=Thu, 6 Aug 2020 20:47:11 UTC;';
}

