//window.onload = resizeDiv;
//window.onresize = reloadDoc; //resizeDiv;

function resizeDiv() {

	theWindow = document.body;
	theSite = document.getElementById("swSite");
	thePage = document.getElementById("swPage");
	theTable = document.getElementById("swContentTable");
	theCell = document.getElementById("swScroll");
	theDiv =  document.getElementById("swScrollDiv");
	
	with (theWindow) {
		//alert("theWindow" + clientHeight + "," + offsetHeight + "," + scrollHeight);
	}

	if (!browser.mac || browser.Firefox) {
		if (theWindow.clientHeight >= 800) {
			switch(theWindow.id) {
				case "reference":
					//alert("reference");
					theSite.style.height = theWindow.clientHeight - 60; // - topmargin & bottommargin
					thePage.style.height = theWindow.clientHeight - 210; // - top
					theTable.style.height = theWindow.clientHeight - 210; // - top
					theCell.style.height = theWindow.clientHeight - 210 - 500; // - top - picture
					theDiv.style.height = theWindow.clientHeight - 205 - 500 - 20 - 30; // - top - picture - margin - context menu
				break;
				case "furniture":
					//alert("furniture");
					theSite.style.height = theWindow.clientHeight - 60; // - topmargin & bottommargin
					thePage.style.height = theWindow.clientHeight - 210; // - top
					theTable.style.height = theWindow.clientHeight - 210; // - top
					theCell.style.height = theWindow.clientHeight - 210 - 500; // - top - picture
					theDiv.style.height = theWindow.clientHeight - 175 - 500 - 20 - 30; // - top - picture - margin - context menu
				break;				
				case "designer":
					//alert("designer");
					theSite.style.height = theWindow.clientHeight - 60; // - topmargin & bottommargin
					thePage.style.height = theWindow.clientHeight - 210; // - top
					theTable.style.height = theWindow.clientHeight - 210; // - top
					theCell.style.height = theWindow.clientHeight - 210 - 500; // - top - picture
					theDiv.style.height = theWindow.clientHeight - 205 - 500 - 20; // - top - picture - margin
				break;
				case "inspiration":
				case "designers":
				case "furnitures":
					//alert("furnitures");
					theSite.style.height = theWindow.clientHeight - 60; // - topmargin & bottommargin
					theCell.style.height = theWindow.clientHeight - 210; // - top 
					theDiv.style.height = theWindow.clientHeight - 190 - 20; // - top - margin
				break;
				case "references":
				case "photos":
					//alert("photos");
					theSite.style.height = theWindow.clientHeight - 60; // - topmargin
					thePage.style.height = theWindow.clientHeight - 210; // - top
					theTable.style.height = theWindow.clientHeight - 210; // - top
					theCell.style.height = theWindow.clientHeight - 210; // - top
					theDiv.style.height = theWindow.clientHeight - 190 - 20; // - top - margin
				break;
				case "photo":
				case "data":
					//alert("data");
					theSite.style.height = theWindow.clientHeight - 60; // - topmargin & bottommargin
					thePage.style.height = theWindow.clientHeight - 210; // - top
					theTable.style.height = theWindow.clientHeight - 210; // - top
					theCell.style.height = theWindow.clientHeight - 210 - 500; // - top - photo
					theDiv.style.height = theWindow.clientHeight - 205 - 500 - 20 - 30; // - top - photo - margin - context menu
				break;
				case "search":
					//alert("search");
					theSite.style.height = theWindow.clientHeight - 60; // - topmargin & bottommargin
					thePage.style.height = theWindow.clientHeight - 210; // - top
					theTable.style.height = theWindow.clientHeight - 210; // - top
					theCell.style.height = theWindow.clientHeight - 210; // - top
					theDiv.style.height = theWindow.clientHeight - 190 - 20; // - top - margin
				break;				
			}
		}
		else {
			switch(theWindow.id) {
				case "designer":
					theDiv.style.height = 130; // minimum height
				break;
				case "furniture":
				case "furnitures":
			  	case "inspiration":
				case "designers":
					theDiv.style.height = 500; // minimum height
				break;
				case "references":
				case "photos":
					theDiv.style.height = 500; // minimum height
				break;
				case "search":
					theDiv.style.height = 500; // minimum height
				break;				
			}
		}
	}
	else {
		theDiv.style.height = "auto";
	}

if(!browser.ie5) {
	document.getElementById("FFcssOverride").disabled = true;
}

}

function reloadDoc() {
	//document.location.reload(true);
	//window.location.reload(true);
	if(browser.ie) {
		resizeDiv();
	} else {
		window.location.href=window.location.href;
	}
}

function ClearForm() {
	document.getElementById("mob").selectedIndex = 0;
	document.getElementById("des").selectedIndex = 0;
	document.getElementById("ref").selectedIndex = 0;
	document.getElementById("text").value = "";
}


// ******************************************
// Browsercheck Object
// ******************************************

browser = new function(){ // v1.0
  this.ver		= navigator.appVersion;
  this.agent	= navigator.userAgent;
  this.dom		= document.getElementById?1:0;
  this.Firefox	= this.agent.indexOf("Firefox")>-1;
  this.opera5	= this.agent.indexOf("Opera 5")>-1;
  this.opera6	= (this.agent.indexOf("Opera 6")>-1 || this.agent.indexOf("Opera/6")>-1)?1:0;
  this.opera7	= (this.agent.indexOf("Opera 7")>-1 || this.agent.indexOf("Opera/7")>-1)?1:0;
  this.opera	= this.opera5||this.opera6||this.opera7;
  this.ie5		= (this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera)?1:0; 
  this.ie6		= (this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera)?1:0;
  this.ie4		= (document.all && !this.dom && !this.opera)?1:0;
  this.ie		= this.ie4||this.ie5||this.ie6;
  this.mac		= this.agent.indexOf("Mac")>-1;
  this.ns6		= (this.dom && parseInt(this.ver) >= 5)?1:0; 
  this.ns4		= (document.layers && !this.dom)?1:0;
  this.ns		= (this.ns4||this.ns6) && !this.opera;
  this.id		= this.opera7 ? "opera7" : this.opera6 ? "opera6" : this.ie6 ? "ie6" : this.ie5 ? "ie5" : this.ie4 ? "ie4" : this.ns4 ? "ns4" : this.ns6 ? "ns6" : this.opera5 ? "opera5" : 0;
  this.browser	= (this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5||this.opera7);
  return this
}

$(document).ready(function(){
	// Make news scroller is visible on prontpage
	// Delayed visibility due to IE's slow rendering makes all content in scroller visible
	$("DIV.news").show();	
});
		
// Move Collection Book to other menu position
$(document).ready(function(){
	var collectionBooks = $(".swTopMenu .swMenuItem a")
	 .filter(function (index) {
                  return $(this).attr("href").indexOf("mp=108299") > 0;
     }).parent();
	 var separator = collectionBooks.prev();
	 //alert(collectionBooks.html());
	 
	var insertPoint = $(".swTopMenu .swMenuItem a")
	 .filter(function (index) {
                  return $(this).attr("href").indexOf("m=furniture") > 0;
     }).parent().find(".swMenuSection");
	 
	 var url = collectionBooks.find("a").attr("href");
	 collectionBooks.find("a").attr("href", url + "&m=furniture&mp2=108299&sp=108358");
	 collectionBooks.find(".swMenuSection").hide();
	 
	 separator.remove();
	 collectionBooks.remove();
	 
	 insertPoint.append(separator);
	 insertPoint.append(collectionBooks);
	
	
});
