
var exists;
var allStretch;

function submitForm(form) {
	var search = form.action;
	for (var i=0; i < form.elements.length; i++) {
		if (form.elements[i].type != "submit" && form.elements[i].type != "radio") {
			search += "&" + form.elements[i].name + "=" + form.elements[i].value;
		}
	}
    document.location = search;
}

function initCW(){
	var divs = document.getElementsByClassName("stretcher");
	allStretch = new fx.MultiFadeSize(divs, {duration: 400});

	items = document.getElementsByClassName("display");

	for (i = 0; i < items.length; i++){
		var h2 = items[i];
//		h2.style.background = 'url("/themes/default/images/fleche.gif") no-repeat 5px 6px;';
		h2.style.cursor = "pointer";
		div = h2;
		while (div.tagName != "DIV")
		div = div.nextSibling;
		h2.title = h2.className.replace("display ", "");

		if (window.location.href.indexOf(h2.title) < 0) {
			allStretch.hide(div, 'height');
			if (exists != true) exists = false;
		}
		else exists = true;

		h2.onclick = function(){
//			for (i = 0; i < items.length; i++) {
//				items[i].style.background = '';
//			}
//			this.style.background = 'url("/themes/default/images/fleche.gif") no-repeat 5px 6px;';

			div = this;
			while (div.tagName != "DIV")
			div = div.nextSibling;
			allStretch.showThisHideOpen(div, 100, 'height');
		}
	}

	divs[divs.length-1].fs.toggle('height');
//	items[items.length-1].style.background = 'url("/themes/default/images/fleche.gif") no-repeat 5px 6px;';
//	if (exists == false) $('maincontent').getElementsByTagName('div')[0].fs.toggle('height');
}

function hideContainer(elmDisplay) {
	div = elmDisplay;
	while (div.tagName != "DIV")
	div = div.nextSibling;
	allStretch.showThisHideOpen(div, 100, 'height');
}

window.initCCW = {
	start : function ()
	{

	var divs = document.getElementsByClassName("stretcher");
	allStretch = new fx.MultiFadeSize(divs, {duration: 400});

	items = document.getElementsByClassName("display");

	for (i = 0; i < items.length; i++){
		var h2 = items[i];
//		h2.style.background = 'url("/themes/default/images/fleche.gif") no-repeat 5px 6px;';
		h2.style.cursor = "pointer";
		div = h2;
		while (div.tagName != "DIV")
		div = div.nextSibling;
		h2.title = h2.className.replace("display ", "");

		if (window.location.href.indexOf(h2.title) < 0) {
			allStretch.hide(div, 'height');
			if (exists != true) exists = false;
		}
		else exists = true;

		h2.onclick = function() {
			hideContainer(this);
//			for (i = 0; i < items.length; i++) {
//				items[i].style.background = 'url("/themes/default/images/fleche.gif") no-repeat 5px 6px;';
//			}
//			this.style.background = 'url("/themes/default/images/flechedown.gif") no-repeat 5px 6px;';
		}
	}

	divs[divs.length-1].fs.toggle('height');
//	items[items.length-1].style.background = 'url("/themes/default/images/flechedown.gif") no-repeat 5px 6px;';
//	if (exists == false) $('maincontent').getElementsByTagName('div')[0].fs.toggle('height');
}}
