// JavaScript Document
var OriginalSize ;
var CurrentSize  = undefined;
var CurrentBlock;
var StepSeed = 32;
var Step = StepSeed;
var Busy = false;
var FirstShowStep = 1;
var SpeedSeed = 0;
var Speed = SpeedSeed;
var SpeedStep = 0;

function Collapse(sender)
{
    $(sender).parents('.HeaderBar').next('.MainContent').slideToggle();
    $(sender).toggleClass('show').toggleClass('hide');
}
function LowerCollapse(sender)
{
    $(sender).parents('.LowerHeaderBar').next('.LowerMainContent').slideToggle();
    $(sender).toggleClass('Lowershow').toggleClass('Lowerhide');
}
$(document).ready(function() {
   $('.Container > .MainContent[collapse="true"]').hide('fast');
   $('.LowerContainer > .LowerMainContent[collapse="true"]').hide('fast');
 });

//function Collapse(sender)
//{
//if(!Busy)
//{
//Busy = true;
//var found  = false;
//var counter = 0;
//var temp = sender.parentNode;//.children[2];.find('Content1');
//while(!found && counter < sender.parentNode.parentNode.childNodes.length )
//{
//    temp = temp.nextSibling;
//    if(temp != null && temp.id == 'MainContent')
//    {  
//     CurrentBlock = temp;
//     if(CurrentBlock.getAttribute('State') == 'Expand')
//     {
//        CurrentBlock.setAttribute('OriginalHeight',CurrentBlock.offsetHeight+'px',0);
//        
//     //alert(CurrentBlock.getAttribute('OriginalHeight'));
//     }
//     found = true;
//    }
//    counter ++;
//    
//}

//    //var pointer = sender.id.replace('button','');
//   if(CurrentBlock.getAttribute('State') == 'Expand')
//    {
//        CurrentBlock.setAttribute('State','Collapse',0);
//		HideScrollPanel();
//        Hide();
//        sender.style.backgroundImage = 'url(/images/show_btn.gif)';      
//    }   
//    else if(CurrentBlock.getAttribute('State') == 'Collapse')
//    {                         
//		CurrentBlock.setAttribute('State','Expand',0);		 
//        Show();        
//        sender.style.backgroundImage ='url(/images/hide_btn.gif)';
//		
//    }   
//    else
//    {
//    Busy = false;
//    }
//}
//}

//function Hide()//sender_id
//{    
//      CurrentBlock.style.overflow = 'hidden';
//      OriginalSize = CurrentBlock.attributes['OriginalHeight'];            
//      setTimeout('Shrink()',0);
//}
//function Show()
//{                
//    setTimeout('Enlarge()',0);            
//}
//////////////////////////////////////////////////
//function  Shrink()
//{
//   if(CurrentSize == null)
//   {
//    CurrentSize = CurrentBlock.offsetHeight+'px';
//    //alert(CurrentBlock.offsetHeight)
//   }
//   var new_size = CurrentSize.replace('px','');
//   if( parseInt(new_size)  > 0)
//   {       
//        CurrentBlock.style.height = parseInt(new_size)+'px' ;               
//        if(!parseInt(new_size) >= Step)
//        {
//            Step = parseInt(Step/2);
//        }
//        /*
//        CurrentSize = parseInt(new_size) - Step +'px';
//        setTimeout('Shrink()', Speed);
//        Speed += SpeedStep ;*/
//        CurrentSize = parseInt(new_size) - Step +'px';
//        setTimeout('Shrink()', Speed);
//    } 
//    else
//    {           
//        //Speed = SpeedSeed;
//        CurrentBlock.style.display = 'none';
//        CurrentSize = undefined;
//        Step = StepSeed;
//        Busy = false;
//    }   
//}
/////////////////////////////////////////////////////

//function  Enlarge()
//{//

//    if(CurrentSize == null)//== undefined Intialization
//    {     
//        CurrentSize = '0px';  
//        IsStart = false;      
//    }
//    var new_size = CurrentSize.replace('px','');
//    var original_size = CurrentBlock.getAttribute('OriginalHeight') .replace('px','');
//    
//    if( parseInt(new_size) < parseInt(original_size))
//    {           
//        CurrentBlock.style.height = parseInt(new_size) +'px';
//        while((parseInt(original_size)-parseInt(new_size)) < Step)
//        {
//            Step = parseInt(Step/2);
//           //alert(Step);
//        }
//        CurrentSize = parseInt(new_size) + Step +'px';
//        /*CurrentSize = parseInt(new_size) + Step +'px';*/

//    if(FirstShowStep == 2)
//    {
//     CurrentBlock.style.display = 'block';   
//     FirstShowStep = 3 ;
//    }
//    if(FirstShowStep == 1)
//    {
//     FirstShowStep = 2;
//    }

//    setTimeout('Enlarge()',Speed);
//    //Speed += SpeedStep ;
//    }   
//    else
//    {
//      //CurrentBlock.style.height = 'auto';
//      CurrentBlock.style.height = original_size +'px';
//     // Speed = SpeedSeed;
//      FirstShowStep = 1 ;
//      Step = StepSeed;
//	  ShowScrollPanel();
//	  CurrentSize = null;
//      Busy = false;
//	  
//    } 
//}
//function HideScrollPanel()
//{
//	var AllChildren = CurrentBlock.getElementsByTagName('*');
//	var AllChildrenLength = AllChildren.length;
//	var MyScrollPane;
//	for(var i = 0; i<AllChildrenLength;i++)
//	{
//		if(AllChildren[i].id &&AllChildren[i].id == 'MoreContent')
//		{
//			MyScrollPane = AllChildren[i];
//			MyScrollPane.style.visibility = 'hidden';
//			break;
//		}
//	
//	}
//		
//	//alert(MyScrollPane.className);
//	
//}
//function ShowScrollPanel()
//{
//	var AllChildren = CurrentBlock.getElementsByTagName('*');
//	var AllChildrenLength = AllChildren.length;
//	var MyScrollPane;
//	for(var i = 0; i<AllChildrenLength;i++)
//	{
//		if(AllChildren[i].id &&AllChildren[i].id == 'MoreContent')
//		{
//			MyScrollPane = AllChildren[i];
//			MyScrollPane.style.visibility = 'visible';
//			break;
//		}
//	
//	}
//	
//}