var detect = navigator.userAgent.toLowerCase();
var browser;

function checkIt(string)
{
	place = detect.indexOf(string)+1; //If the string doesn't exist, place will return 0
	return place;
}

if (checkIt('safari'))
	browser = 'safari';
else if (checkIt('firefox'))
	browser = 'firefox';
else if (checkIt('msie'))
	browser = 'ie';
else
	browser = 'other';

function start() {
	preloadImages();
	if (browser == 'ie')
		blendPicture();
	else
		changePicture();
}

function preloadImages() {
	var img0 = new Image(400,300);
	img0.src = "images/homePic0.jpg";	
	
	var img1 = new Image(400,300);   
   	img1.src = "images/homePic1.jpg";

	var img2 = new Image(400,300);   
	img2.src = "images/homePic2.jpg";

	var img3 = new Image(400,300);   
	img3.src = "images/homePic3.jpg";

	var img4 = new Image(400,300);   
	img4.src = "images/homePic4.jpg";
	
	var img5 = new Image(400,300);   
	img5.src = "images/homePic5.jpg";

}

var oldnum = 0;

function blendPicture() {
	var picnum = (oldnum + 1) % 6;
	
	document.getElementById('blend').filters.blendTrans.Apply();
	document.getElementById('blend').src = "images/homePic" + picnum + ".jpg";
	document.getElementById('blend').filters.blendTrans.Play();
	oldnum = picnum;
	blendpic = setTimeout("blendPicture();", 6000);
}

function changePicture() {
	var millisec = 2000;
	var speed = Math.round(millisec/100);
	var timer = 0;
	var picnum = (oldnum + 1) % 6;
	
	document.getElementById('pic').style.background = "url(images/homePic" + oldnum + ".jpg)";
	changeOpacity('blend', 0);
	document.getElementById('blend').src = "images/homePic" + picnum + ".jpg";
	for (i=0; i<=99; i++) {
		j=i/100;
		setTimeout("changeOpacity('blend',"+j+")", (timer * speed));
		timer++;
	}
	oldnum = picnum;
	setTimeout("changePicture()", 6000);
}

function changeOpacity (id, opac) {
	if (browser == 'ie') {
		opacity = opac * 100;
		document.getElementById(id).style.filter = "alpha(opacity=" + opacity + ")"; 
	}
	else {
		document.getElementById(id).style.opacity = opac;
	}
}

function changeTextFamily() {
	document.getElementById('quoteText').innerHTML = "If you are having family problems, the only thing you want is the problem solved. Allow us to help restore peace to your home so that you can move on.";
}

function changeTextEstate() {
	document.getElementById('quoteText').innerHTML = "We can help provide extra assurance that if anything were to happen, your loved ones would be protected and your affairs would be secure.";
}

function changeTextCriminal() {
	document.getElementById('quoteText').innerHTML = "As soon as you are ticketed or arrested, you need legal representation to ensure that your rights are not violated.";
}

function changeTextDebt() {
	document.getElementById('quoteText').innerHTML = "If debt is crushing your dreams and leaving you feeling trapted, we can help provide relief so that you can breath.";
}

function changeTextBack() {
	document.getElementById('quoteText').innerHTML = "We are committed to bringing high standards of quality to every aspect of the attorney-client relationship and to every matter with which we are entrusted.";
}
