var elem = new Array();
var is = new Is();

function Is() 
{
	agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns6 = (this.ns && (this.major >= 5));
	this.ie = (agent.indexOf("msie") != -1);
	this.ie3 = (this.ie && (this.major < 4));
	this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
	this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
	this.ie55 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
	this.ie6 = (this.ie && (this.major == 4) && (agent.indexOf("msie 6") != -1));
	this.iedom = (this.ie4 || this.ie5dom ||this.ie55 || this.ie6);
}

function showDiv(calque)
{
	hideAll();
	document.getElementById(calque).style.visibility='visible';
	setTimeout("document.getElementById('"+calque+"').style.visibility='hidden'", 6000);	
}

function validate()
{
	var test = new Array();
	test["company"] = 1;
	test["name"] = 1;
	test["address1"] = 1;
	test["address2"] = 0;	
	test["town"] = 1;
	test["telephone"] = 3;
	test["fax"] = 3;
	test["email"] = 2;
	test["country"] = 1;
	test["groupName"] = 1;
	test["groupSize"] = 4;
	test["destinations"] = 1;
	test["nbrNights"] = 4;
	test["day"] = 1;
	test["month"] = 1;
	test["year"] = 1;
	test["request"] = 0;
	test["zipcode"] = 1;
	
	var cptr=1;
	var result=0;
	
	for (compteur=0; compteur<document.groupRequest.length; compteur++)
	{
		var champ = document.groupRequest[compteur].value;
		x = document.groupRequest[compteur].name;
		action = test[x];
		switch (action)
		{
			case 0 : break;
			case 1 : 
				// Champ present
				if (champ=="")
				{
					document.groupRequest[x].style.background="#ffdd00";
					result++;
				} else
				{
					document.groupRequest[x].style.background="#ddffff";
				}
				break;
			case 2 :
				// Adresse Email
				if ((champ.indexOf('@',0)==-1) || (champ.indexOf('.',0)==-1))
				{
					document.groupRequest[x].style.background="#ffdd00";
					result++;
				}else
				{
					document.groupRequest[x].style.background="#ddffff";
				}
				break;
			case 3 :
				// Teste telephone
				if ((champ.search(/^([0-9])+$/) == -1) || (champ.length < 5))
				{
					document.groupRequest[x].style.background="#ffdd00";
					result++;
				}else
				{
					document.groupRequest[x].style.background="#ddffff";
				}
				break;
			case 4 :
				//Test groupSize
				if (champ.search(/^([0-9])+$/) == -1)
				{
					document.groupRequest[x].style.background="#ffdd00";
					result++;
				}else
				{
					document.groupRequest[x].style.background="#ddffff";
				}
				break;
			case 5 :
				//Test zipcode
				if ((champ.search(/^([0-9])+$/) == -1) || (champ.length < 4))
				{
					document.groupRequest[x].style.background="#ffdd00";
					result++;
				}else
				{
					document.groupRequest[x].style.background="#ddffff";
				}
				break;
		}
	}
	if (document.groupRequest["request"].value == "Copy and paste your itinerary if you have a specific tour.")
	{
		document.groupRequest["request"].value = "";
	}
	if (result==0) document.groupRequest.submit();
}

function validate2()
{
	var test = new Array();
	test["TITLE"] = 1;
	test["AUTHOR"] = 1;
	test["NEWSTEXT"] = 1;
	
	var cptr=1;
	var result=0;
	
	for (compteur=0; compteur<document.newsForm.length; compteur++)
	{
		var champ = document.newsForm[compteur].value;
		x = document.newsForm[compteur].name;
		action = test[x];
		switch (action)
		{
			case 0 : break;
			case 1 : 
				// Champ present
				if (champ=="")
				{
					document.newsForm[x].style.background="#ffdd00";
					result++;
				} else
				{
					document.newsForm[x].style.background="#ddffff";
				}
				break;
		}
	}
	alert(document.newsForm.action);
	// if (result==0) 
}


function hideAll()
{
	for (var x=0; x<elem.length; x++)
	{
		elem[x].style.visibility="hidden";
	}
}

function addDiv(id)
{
	var x = elem.length;
	elem[x]=(is.iedom)? document.all[id] : document.getElementById(id);
}

function hiddeDiv(calque)
{
	//document.getElementById(calque).style.visibility='hidden';
	//setTimeout("document.getElementById('"+calque+"').style.visibility='hidden'", 10000);	
}

function setLeft(ncol, calque)
{
	ncol=ncol-1;
//lert(screen.width);
	x = screen.width/2;
	x = x - (760/2);
	if (ncol>0)
	{
		x=x-0;
		// ncol=ncol-1;		
	}
	
	x = x + (100*ncol)+118;
	x = x+x/140;
	//alert (x);
	document.getElementById(calque).style.left=x;
}

var flags = new Array;

function init(group, div)
{
	if (!flags[group]) flags[group] = new Array;
	flags[group][flags[group].length] = div;
	if (flags[group].length == 1)
	{
		document.getElementById(div).style.visibility="visible";
	}
	//alert(flags[group].length);
}

function alternate(group)
{
	setInterval("next('"+group+"')", 3000);
}

function next(group)
{
	for (x=0; x<flags[group].length; x++)
	{
		if (document.getElementById(flags[group][x]).style.visibility == "visible" && flags[group].length > 1)
		{
			document.getElementById(flags[group][x]).style.visibility = "hidden";
			y = x+1;
			if (y >= flags[group].length) y = 0;
			document.getElementById(flags[group][y]).style.visibility = "visible";	
			return;		
		}
	}
}








