// layout3.js 
// Cross-Browser.com & SitePoint.com - Equal Column Height Demo (3 Column)
// geädert 3.7.2005 Baiker
var current_style;
var autoswitch = "on";
var baseLayout ="layout3";


function  ausklappen()
{
	P7_TMALL(0);adjustLayout();
}

function  einklappen()
{
	P7_TMALL(1);adjustLayout();
}


var reserveMenuHeight = 73;  // Logo left column wird nicht gezählt

function  get_current_style()
{
	return current_style;
}

function  get_clientWidth()
{
	return xClientWidth();
}

function  set_current_style(s)
{
	current_style=s;
	return; 
}

function  set_autoswitch(s)
{
	autoswitch=s;
	return; 
}

function  set_baseLayout(s)
{
	baseLayout=s;
	return; 
}



function adjustLayout()
{
    var w = xClientWidth();
   
    if (autoswitch == "off") {
	    if (current_style == "handheld"){
	    	 adjustLayout_sp1();
	    }
	    else if (current_style == "layout3"){
	    	 adjustLayout_sp3();
	    }
	    else if (current_style == "layout3b"){
	    	 adjustLayout_sp3();
	    }
	    else if (current_style == "layout32"){
	    	 adjustLayout_sp2();
	    }
	    else if (current_style == "layout2"){
    	    adjustLayout_sp2();
       }
       return;
	 }
  
  
    if ((current_style == "handheld") && ( w > 325 )){
    	if (baseLayout == "layout2"){
    		setActiveStyleSheet("layout2");
    	}
    	else{	
    	   setActiveStyleSheet("layout32");
    	}
    }
    else if ((current_style == "layout32") && ( w > 675 )){
    	if (baseLayout == "layout3b"){
    	   setActiveStyleSheet("layout3b");
    	}
    	else{
    		setActiveStyleSheet("layout3");
    	}
    }
    else if ((current_style == "layout3") && ( w < 675 )){
    	setActiveStyleSheet("layout32");
    }
    else if ((current_style == "layout3b") && ( w < 675 )){
    	setActiveStyleSheet("layout32");
    } 
    else if ((current_style == "layout32") && ( w < 325 )){
    	setActiveStyleSheet("handheld");
    }
 
    else if ((current_style == "layout2") && ( w < 325 )){
    	setActiveStyleSheet("handheld");
    }
 
    	 
    if (current_style == "handheld"){
    	 adjustLayout_sp1();
    }
    else if (current_style == "layout32"){
    	 adjustLayout_sp2();
    }
    else if (current_style == "layout3"){
    	 adjustLayout_sp3();
    }
    else if (current_style == "layout3b"){
    	 adjustLayout_sp3();
    }    
    else if (current_style == "layout2"){
    	 adjustLayout_sp2();
    }
    else if (current_style == "layout2sp"){
    	 adjustLayout_sp2();
    }
    
}

function adjustLayout_sp3()
{
	  //var clientWidth= xClientWidth();
     //xWidth('header', 2000);
	  // Get content heights
	  var cHeight = xHeight('centerColumnContent');
	  var lHeight = xHeight('leftColumnContent') + reserveMenuHeight;
	  var rHeight = xHeight('rightColumnContent');

	  var clientHeight=0;
	  clientHeight= xClientHeight()-100;   // 170 = ca Rand oben + unten
	  if (clientHeight > lHeight ){
	  	lHeight = clientHeight;
	  }

	  // Find the maximum height
	  var maxHeight = Math.max(cHeight, Math.max(lHeight, rHeight));
	  maxHeight = maxHeight+10;
	  // Assign maximum height to all columns
	  xHeight('leftColumn', maxHeight);
	  xHeight('centerColumn', maxHeight);
	  xHeight('rightColumn', maxHeight);

	
  	
  // Show the footer

  //xShow('footer');

}

function adjustLayout_sp2()
{

	  //var clientWidth= xClientWidth();
	  //xWidth('header', 2000);
	  // Get content heights
	  var cHeight = xHeight('centerColumnContent');
	  var lHeight = xHeight('leftColumnContent');
	  var rHeight = xHeight('rightColumnContent');
	  var clientHeight= xClientHeight()-100;   // 100 = Header oben 	  
	
	  // Find the maximum height
	  var crHeight = cHeight + rHeight;
	  
	  if (crHeight < clientHeight ){
	  	xHeight('leftColumn', clientHeight);
	  	xHeight('centerColumn', cHeight);
	  	xHeight('rightColumn', clientHeight-cHeight);
	  }
	  else{
		  if ( crHeight > lHeight){
		 		xHeight('leftColumn', crHeight);
		 		xHeight('centerColumn', cHeight);
		 		xHeight('rightColumn', rHeight);
		 					
		  }
		  else{
		  	   xHeight('centerColumn', cHeight);
		      xHeight('rightColumn', lHeight - cHeight);		      
		  }
	  } 	  
	  
  // Show the footer
  //xShow('footer');
}


function adjustLayout_sp1()
{
  var cHeight = xHeight('centerColumnContent');
  var lHeight = xHeight('leftColumnContent');
  var rHeight = xHeight('rightColumnContent');
  var clientWidth= xClientWidth();
  
  xHeight('leftColumn', lHeight);
  xHeight('centerColumn', cHeight);
  xHeight('rightColumn', rHeight);
  //xShow('footer');
  
/*  
  if ( iniWidthHeader < 1 ){
		iniWidthHeader = xWidth('header' );	
		iniWidthLeftCol = xWidth('leftColumn' );	
		iniWidthCenterCol = xWidth('centerColumn' );
		iniWidthRightCol = xWidth('rightColumn' );
  }
*/

if ( baseLayout == "handheld" ){
  if (clientWidth > 240){
  xWidth('header', 240);
  xWidth('leftColumn', 240);
  xWidth('centerColumn', 240);
  xWidth('rightColumn', 240);
  }
  else if (clientWidth > 150 ){
  xWidth('header', clientWidth);
  xWidth('leftColumn', clientWidth);
  xWidth('centerColumn', clientWidth);
  xWidth('rightColumn', clientWidth); 	
  }
}

  
}
