var loggedIn = false;

var applicationTabState = 'application';

function doHoverEffect(param){
	/*
var whatElement = document.getElementById(param);
if(whatElement.className == 'ajaxeffect'){
return;
}else{
whatElement.className = 'effect';
}
*/
}

function cancelHoverEffect(param){
	/*
var whatElement = document.getElementById(param);
if(whatElement.className == 'ajaxeffect'){
return;
}else{
whatElement.className = 'noeffect';
}
*/
}

function doAjaxLoadingEffect(param){
var whatElement = document.getElementById(param);
whatElement.className = 'ajaxeffect';
}

function cancelAjaxLoadingEffect(param){
var whatElement = document.getElementById(param);
whatElement.className = 'noajaxeffect';
}


function ajaxGetNavigationContent(param, effectplace){ /* effectplace sets which of the divs to animate */
	collapseAll();
	
/*	doAjaxLoadingEffect('loading' + effectplace);*/
	var urlGet = 'content/' + param + '.html';
	var targetDiv = 'navigation' + effectplace;
	var content = new Ajax.Updater(targetDiv, urlGet, { method: 'get', evalScripts: true });
/*	applyAjaxedNavigationBoxClass(targetDiv);*/

/*	cancelAjaxLoadingEffect('loading' + effectplace);*/
	var targetElement = document.getElementById(targetDiv);
	targetElement.style.display='block';
	targetElement.parentNode.className = 'activeBorder';
	var titleToChange = document.getElementById('title'+effectplace);
	titleToChange.className = 'activeTitle';

/*if(effectplace==2){
	setSelectedTab(applicationTabState);
	}*/
}


function applyAjaxedNavigationBoxClass(param){
	var targetDiv = document.getElementById(param);
	targetDiv.className = 'ajaxedNavigationBox';
}


function ajaxGetBlockToContent(param, effectplace){
if(effectplace<4){ /* hilite only the first 4 */
var titleToChange = document.getElementById('title'+effectplace);
titleToChange.className = 'activeTitle';
}
var titleToChange = document.getElementById('title'+effectplace);
titleToChange.className = 'activeTitle';

var urlGetPath = 'content/' + param + '.html'
var content = new Ajax.Updater('contentStuff', urlGetPath, { method: 'get', evalScripts: true });
findImageByContentName()
}


function findImageByContentName(contentName){
	//code to retrieve image name
	// proposta: pedir a um script.php um número válido e depois: contentName+número+.jpg
}


function collapseAll(){ //COLAPSE TEM QUE APAGAR OS LINKS QUE SÃO h4 dentro de A'a
var ar = new Array()
ar[0] = 'WhatIs'
ar[1] = 'Outlook'
ar[2] = 'Products'
ar[3] = 'Specifications'
ar[4] = 'Design'
ar[5] = 'Ambient'
ar[6] = 'FindDealer'
ar[7] = 'Subscribe'

for(i=0;i<ar.length;i++) {
var classer = document.getElementById('navigation' + i);
classer.style.display='none';
}

for(t=0;t<ar.length;t++) {
var classer = document.getElementById('navigation' + ar[t]);
if(t<4){
	classer.className = 'navigationElement';
	}else{
	classer.className = 'navigationElementShort';
	}

}

for(u=0;u<ar.length;u++) {

		var classer = document.getElementById('title' + u);
		classer.className = 'restoreTitle';
}
}

/* CHECKBOX STUFF */


function toggleBox(thisOne){
var checkBoxObject = document.getElementById(thisOne);
var fakeCheckBox = document.getElementById(thisOne + 'fake');
var boxTextLabel = document.getElementById(thisOne + 'Text');

if(fakeCheckBox.className == 'checkBoxUnabled'){
	return;
}

if((checkBoxObject.checked==false)){
checkBoxObject.checked=true;
	if(checkBoxObject.id=="checkbox03" || checkBoxObject.id=="checkbox04" || checkBoxObject.id=="checkbox09" || checkBoxObject.id=="checkbox11" || checkBoxObject.id=="checkbox14" || checkBoxObject.id=="checkbox18" || checkBoxObject.id=="checkbox21")
	{
			fakeCheckBox.className = 'checkBoxCheckedB';
	}
	else
	{
		if(checkBoxObject.id=="checkbox01" || checkBoxObject.id=="checkbox05" || checkBoxObject.id=="checkbox08" || checkBoxObject.id=="checkbox12" || checkBoxObject.id=="checkbox15" || checkBoxObject.id=="checkbox17" || checkBoxObject.id=="checkbox19")
		{
				fakeCheckBox.className = 'checkBoxCheckedC';
		}
		else
		{
			fakeCheckBox.className = 'checkBoxChecked';	
		}
	}
	boxTextLabel.className = 'checkedBoxLabel';
	
	/*****/
	if(checkBoxObject.id=="checkbox01")
	{
		toggleBox_rec('checkbox02');
		toggleBox_rec('checkbox03');
	}
	if(checkBoxObject.id=="checkbox02")
	{
		toggleBox_rec('checkbox01');
		toggleBox_rec('checkbox03');
	}
	if(checkBoxObject.id=="checkbox03")
	{
		toggleBox_rec('checkbox01');
		toggleBox_rec('checkbox02');
	}
	/*****/
	/*****/
	if(checkBoxObject.id=="checkbox04")
	{
		toggleBox_rec('checkbox05');
		toggleBox_rec('checkbox06');
	}
	if(checkBoxObject.id=="checkbox05")
	{
		toggleBox_rec('checkbox04');
		toggleBox_rec('checkbox06');
	}
	if(checkBoxObject.id=="checkbox06")
	{
		toggleBox_rec('checkbox04');
		toggleBox_rec('checkbox05');
	}
	/*****/
	/*****/
	if(checkBoxObject.id=="checkbox07")
	{
		toggleBox_rec('checkbox08');
		toggleBox_rec('checkbox09');
	}
	if(checkBoxObject.id=="checkbox08")
	{
		toggleBox_rec('checkbox07');
		toggleBox_rec('checkbox09');
	}
	if(checkBoxObject.id=="checkbox09")
	{
		toggleBox_rec('checkbox07');
		toggleBox_rec('checkbox08');
	}
	/*****/
	/*****/
	if(checkBoxObject.id=="checkbox10")
	{
		toggleBox_rec('checkbox11');
		toggleBox_rec('checkbox12');
	}
	if(checkBoxObject.id=="checkbox11")
	{
		toggleBox_rec('checkbox10');
		toggleBox_rec('checkbox12');
	}
	if(checkBoxObject.id=="checkbox12")
	{
		toggleBox_rec('checkbox10');
		toggleBox_rec('checkbox11');
	}
	/*****/
	/*****/
	if(checkBoxObject.id=="checkbox13")
	{
		toggleBox_rec('checkbox14');
		toggleBox_rec('checkbox15');
	}
	if(checkBoxObject.id=="checkbox14")
	{
		toggleBox_rec('checkbox13');
		toggleBox_rec('checkbox15');
	}
	if(checkBoxObject.id=="checkbox15")
	{
		toggleBox_rec('checkbox13');
		toggleBox_rec('checkbox14');
	}
	/*****/
/*****/
	if(checkBoxObject.id=="checkbox16")
	{
		toggleBox_rec('checkbox17');
		toggleBox_rec('checkbox18');
	}
	if(checkBoxObject.id=="checkbox17")
	{
		toggleBox_rec('checkbox16');
		toggleBox_rec('checkbox18');
	}
	if(checkBoxObject.id=="checkbox18")
	{
		toggleBox_rec('checkbox16');
		toggleBox_rec('checkbox17');
	}
	/*****/
	if(checkBoxObject.id=="checkbox19")
	{
		toggleBox_rec('checkbox20');
		toggleBox_rec('checkbox21');
	}
	if(checkBoxObject.id=="checkbox20")
	{
		toggleBox_rec('checkbox19');
		toggleBox_rec('checkbox21');
	}
	if(checkBoxObject.id=="checkbox21")
	{
		toggleBox_rec('checkbox19');
		toggleBox_rec('checkbox20');
	}
	/*****/

}else{
checkBoxObject.checked=false;
fakeCheckBox.className= 'checkBoxUnchecked';
boxTextLabel.className = 'uncheckedBoxLabel';
}
}

function toggleBox_rec(thisOne){
var checkBoxObject = document.getElementById(thisOne);
var fakeCheckBox = document.getElementById(thisOne + 'fake');
var boxTextLabel = document.getElementById(thisOne + 'Text');

checkBoxObject.checked=false;
fakeCheckBox.className= 'checkBoxUnchecked';
boxTextLabel.className = 'uncheckedBoxLabel';
}

function ajaxGetBlock(param, targetDivUpdate){
var urlGetPath = param; /* searchBox div path */
var content = new Ajax.Updater(targetDivUpdate, urlGetPath, { method: 'get', evalScripts: true });
}


function showMenu(thisMenu){
	hideAllMenus();
	//if(loggedIn){
		var menuBlock = document.getElementById(thisMenu);
		menuBlock.style.display='block';
	//}
}

function hideMenu(thisMenu){
	var menuBlock = document.getElementById(thisMenu);
	menuBlock.style.display='none';
}

function hideAllMenus(){
	ar = new Array()
ar[0] = 'retailAndTradeMenu'
ar[1] = 'architectsAndDesignersMenu'
ar[2] = 'mediaAndPressRoomMenu'

for(t=0;t<ar.length;t++) {hideMenu(ar[t]);}
}


function toggleLogin(){
	var classer = document.getElementById('contentMenu');
	var loginClasser = document.getElementById('loginSection');
	var loggedinClasser = document.getElementById('loggedInSection');
	
	if(!loggedIn){
		loggedIn = true;
		classer.className = 'contentMenuEnabled';
		loginClasser.style.display = 'none';
		loggedinClasser.style.display = 'block';
	}else{
		loggedIn = false;
		classer.className = 'contentMenuDisabled';
		loginClasser.style.display = 'block';
		loggedinClasser.style.display = 'none';
		
	}
}

function powerOnSelfTest(){ /* check loggin status and startUp */
	var classer = document.getElementById('contentMenu');
	var loginClasser = document.getElementById('loginSection');
	var loggedinClasser = document.getElementById('loggedInSection');
	
	if(loggedIn){
		classer.className = 'contentMenuEnabled';
		loginClasser.style.display = 'none';
		loggedinClasser.style.display = 'block';
	}else{
		classer.className = 'contentMenuDisabled';
		loginClasser.style.display = 'block';
		loggedinClasser.style.display = 'none';
	}
		
}

function setSelectedTab(param){
clearAllTabs();
applicationTabState = param;
var classer = document.getElementById(param).className = 'selectedTab';
}

function clearAllTabs(){
ar = new Array()
ar[0] = 'application'
ar[1] = 'collections'
ar[2] = 'technical'

for(t=0;t<ar.length;t++) {
	document.getElementById(ar[t]).className = 'unselectedTab';
	}
}
