// JavaScript Document

// preload images
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// replace image source, alt text, and title
function setImageSource(img_name, img_src, img_alt) {
	document[img_name].src = img_src;
	document[img_name].alt = img_alt;
	document[img_name].title = img_alt;
}

// set class name by ID
function setClass(thisid, classname) {
	document.getElementById(thisid).setAttribute("class", classname);
	// for IE
	document.getElementById(thisid).className = classname;		
} // *** end of function setClass ***

// replace image source, alt text, and title and change class depending on whether it's been chosen
function hideAndChange(img_name, img_src, img_alt, thumb_num, total_num) {
	setImageSource(img_name, img_src, img_alt);

	var thumb_id = "";
	for (count = 1; count <= total_num; count++)
	{
		thumb_id = "thumb" + count;
		if (count == thumb_num) {
			setClass(thumb_id, 'noFade');
    	//document.getElementById(thumb_id).style.opacity = (1);
			//document.getElementById(thumb_id).style.filter  = "alpha(opacity=100)";
			//document[thumb_id].onMouseOver = "style.filter = alpha(opacity=100)";
			//document[thumb_id].onMouseOut = "style.filter = alpha(opacity=100)";
		} else {
			setClass(thumb_id, 'fade');
    	//document.getElementById(thumb_id).style.opacity = (0.4);
			//document.getElementById(thumb_id).style.filter  = "alpha(opacity=40)";
			//document[thumb_id].onMouseOver = "style.filter = alpha(opacity=100)";
			//document[thumb_id].onMouseOut = "style.filter = alpha(opacity=40)";
		}
	} // *** end of for ***
} // *** end of function hideAndChange ***

/* to write mailto */
function jmail(user)
{
	var user;
	var domain = 'cbtarchitects';
	var suffix = 'com';
	
	document.write('<a href="' + 'mai' + 'lto:' + user + '@' + domain + '.' + suffix + '">' + user + '<span class="showForAll"> more57</span>@' + domain + '.' + suffix + '</a>');
}

// returns a 2-letter code for the browser type (from http://www.webconcerns.co.uk/javascript/dhtml/dhtml_page.asp)
function getBrowser()
{
	if (navigator.userAgent.indexOf("Opera") != -1 && document.getElementById) {
		type = "OP"; 
	}
	if (document.all) {
		type = "IE"
	}
	if (document.layers) {
		type = "NN";
	}
	if (!document.all && document.getElementById) {
		type = "MO";
	}
	return type;
}
