var currentSubtitle =0;

function getdate() {
	var date = new Date();
	var month = ["January", "February","March","April","May","June","July","August", "September","October","November","December"];
	var day = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
	return day[date.getDay()] + ", " + month[date.getMonth()] + " " +
	date.getDate() + ", " + date.getFullYear();
}

function init()
{
	// add the indicator images
	var obj = document.getElementById("list_image");
	var myHtml = "";

	for(var i=0; i< contents.length; i++){
		myHtml +="<li id='indicator_image"+ i + "'><img src='img/logo2.jpg' /></li>";
	}

	obj.innerHTML = myHtml;

	//add subTitle
	var obj = document.getElementById("list_title");
	var myHtml = "";

	for(var i=0; i< contents.length; i++){
		var regexp	= /\.php$/;
		if(contents[i].description.match(regexp)){
			myHtml +="<li id='subLink"+ i + "'><a href='"+contents[i].description+"'>"+contents[i].title + "</a></li>";
		}
		else{
			myHtml +="<li id='subLink"+ i + "' onClick='changeContents(" + i +")' onmouseover='changeStyle(this)' onmouseout='resetStyle(this, "+ i +")'>" + contents[i].subTitle + "</li>";
		}
	}

	obj.innerHTML = myHtml;

	//add date
	var objDate = document.getElementById("date");
	objDate.innerHTML = getdate();

	changeContents(0);

	flash_play();
}


function changeStyle(obj)	// mouseover
{
	with(obj.style){
		cursor = "pointer";
		color = "olive";
	}

}

function resetStyle(obj, id)	// onmouseout
{
	if(id != currentSubtitle){
		with(obj.style){
				color = "black";
		}
	}
	
}

function changeContents(index)
{
	var myHtml="";

	currentSubtitle = index; //set the current subtitle, used in mouseout event
	myHtml = contents[index].description;

	// output the contents
	var obj = document.getElementById("col_right");
	obj.innerHTML = myHtml;

	// set the links color
	for(var i = 0; i< contents.length; i++){
		if(i == index)
			document.getElementById("subLink"+i).style.color="olive";
		else
			document.getElementById("subLink"+i).style.color="black";
			
	}

	// set the indicator images' visibility
	for(var i = 0; i< contents.length; i++){
		if(i == index)
			document.getElementById("indicator_image"+i).style.visibility = "visible";
		else
			document.getElementById("indicator_image"+i).style.visibility="hidden";
			
	}

	// set the sub title
	obj = document.getElementById("subTitle");
	obj.innerHTML = contents[index].title;

	// set the height
	obj = document.getElementById("detailsBody");
	obj.style.height = contents[index].height;
	
	return;

}


function content(title, subTitle, desc, height)
{
	this.title= title;
	this.subTitle= subTitle;
	this.description = desc;
	this.height = height;
}

function random(num)
{
var words = new Array(
	"Real estate problems, real world solutions.",
    "Legal support for your corporate needs.",
	"Solicitors for your land development and municipal matters.",
	"Let us guide you through the land development process.",
	"Developing the future with you.",
	"Excellence is a norm not an ideal.",
	"Legal support from the ground up.",
	"Analysis. Teamwork.  Solutions.",
	"A pragmatic approach to your legal challenges.",
	"Legal service that is vital to our clients needs.",
	"Experienced counsel is vital to good business decision making.",
	"Providing sound legal advice for your development and growth strategies."
);
/*	"Developing the future with you",
	"It takes practice to be the best",
	"Legal support for your land development and corporate game",
	"Like the law, it takes practice to be great",
	"A good law firm, is like a diamond in the rough",
	"Hard work makes it skill, not luck",
	"Legal support for whatever corporate mask you wear",
	"Let us guide you through the development process"
);*/
	var temp = words;
	var returnText = "<ul>";
	for(i=num; i>0; i--){
		var arrayLength = temp.length;
		var ran_num = Math.floor(Math.random() * arrayLength);
		tempText = temp.splice(ran_num, 1);
		returnText +="<li>"+tempText+"</li>";
	}

	returnText +="</ul>";
	return returnText;
}

function flash_play(){
	obj = document.getElementById("flashingWords");
	obj.innerHTML = random(1);
	if(navigator.appName == "Microsoft Internet Explorer"){
		with (obj) {
			style.visibility ="hidden";
			filters[0].Apply();
			filters[0].play();
			style.visibility="visible";
		}
	}
	setTimeout("flash_play()", 10000);
}
