
var NCCLayout = {
	
	elements: {
		leftSide:null,
		rightSide:null,
		angles : null,
		sideHorizontalTiles:null,
		main:null,
		outside : null,
		footer : null
	},
	
	
	init: function(){
			var _this = this;
			this.elements.leftSide = $("leftside");
			this.elements.rightSide = $("rightside");
			this.elements.angles = $$(".angle-shift");
			this.elements.sideHorizontalTiles = $$(".side-horizontal-tile");
			this.elements.main = $("main");
			this.elements.outside = $("outside");
			
			this.elements.footer = $$(".footer")[0];
			this.layout();
			
			window.addEvent("resize" , function(){
												_this.layout();
												});
			
	},
	
	layout: function(){
			var size = window.getSize();
			
			var sideWR = Math.round(Math.max(((Math.min(size.x , this.elements.outside.getSize().x) - this.elements.main.getSize().x)/2) , 0));
			var sideWL = sideWR;
			if(((sideWR*2) + this.elements.main.getSize().x) >(Math.min(size.x , this.elements.outside.getSize().x))){
				sideWR -= ((sideWR*2) + this.elements.main.getSize().x) - (Math.min(size.x , this.elements.outside.getSize().x));
			}
			
			
			list = $$("#right-content-column .contact-form input[type=text] , #right-content-column .contact-form textarea");
			
			list.each(
					  function(ele){
						 
						 if(parseInt(ele.getStyle("width")) < ele.getSize().x){
							 
							 x = parseInt(ele.getStyle("width"));
							 if(typeof(ele.startingW) == "undefined" || ele.startingW == null ){
							 	ele.startingW = x;
								 ele.setStyle("width" , (x-=ele.getSize().x-x) + "px");
							 }
							 
						  }
						  
					  }
					  );
			
			
			this.elements.main.setStyles({
									height:"auto"
									});
			this.elements.main.setStyles({
									height:Math.max(this.elements.main.getSize().y , size.y) +"px"
									});
			
			this.elements.leftSide.setStyles({
									width:sideWL,
									height:Math.max(this.elements.main.getSize().y , size.y) +"px"
									});
			this.elements.rightSide.setStyles({
									width:sideWR,
									height:Math.max(this.elements.main.getSize().y , size.y) +"px"
									});
			this.elements.angles.setStyles({
									width:sideWL,
									height:Math.max(this.elements.main.getSize().y , size.y) +"px"
									});
			this.elements.sideHorizontalTiles.setStyles({
									width:sideWL,
									height:Math.max(this.elements.main.getSize().y , size.y) +"px"
									});
			
			var footerH = 0;
			this.elements.footer.getElements(".column .content").each(function(ele){
				footerH = Math.max(footerH , ele.getSize().y);
			});
			
			this.elements.footer.getElements(".column .content").setStyle("height" , footerH);
	}
	
	
	
	
};


function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

window.addEvent("domready" , function(){
							NCCLayout.init();		  
									  });


window.addEvent("load" , function(){
							NCCLayout.layout();
									});
