
var displayedText = "Home";
var file = "";

function GetExtraText(id, type){
	
	if(type == "MainLink")
		file = id + ".txt";
	else
		file = displayedText + id + ".txt";

	xmlHttp = GetXMLHTTP();
	
	if(xmlHttp != null){
		xmlHttp.onreadystatechange=stateChanged;
		
		url = "Content/" + file;
	
		url += "?1" + new Date().getTime();
	    xmlHttp.open("GET", url, true);
	    xmlHttp.send(null);
	}
	else{
		alert("Your browser does not support AJAX!"); 
	}
}

function stateChanged(){ 
	if(xmlHttp.readyState==4){
		if(xmlHttp.status == 200){
			
			myString = new String(xmlHttp.responseText);

			if(file != "LaserHairRemovalPricing.txt" && file != "ContactUs.txt" && file != "ChemicalPeelsPricing.txt" && file != "PhotoRejuvinationPricing.txt"){				
				myRegExp = new RegExp(String.fromCharCode(10), "g");
				myString = myString.replace(myRegExp, "<br>");
			}
			document.getElementById("TextArea").innerHTML = myString;
			document.getElementById("infoScroller").scrollTop = "0px";
		}
    }
}

/*
** showOptionsTable - if we want to show the OptionsTable (pricing, preparation, Post treatment, FAQs)
** isMainLink - Only set to true if the link clicked is on the main page. Used to track the current selection
*/				
function ShowWindow(id, showOptionsTable, isMainLink){
	var info = document.getElementById("hiddenDiv");
	document.getElementById("infoScroller").scrollTop = "0px";
	
	if(showOptionsTable)
		document.getElementById("OptionsTable").style.visibility = "visible";
	else
		document.getElementById("OptionsTable").style.visibility = "hidden";
	
	if(isMainLink && id != Home)
		displayedText = id;
		
	if(id != "Home"){
		HideCurrentText(displayedText);
		GetExtraText(id, "MainLink");
		OpenPanel(info);
		ShowCurrentText(id);
	}
	else{
		document.getElementById("hiddenDiv").style.display = "none";
		HideCurrentText(displayedText);
	}
}

function ShowCurrentText(obj){
	document.getElementById("TextArea").style.display = "block";
}

function HideCurrentText(obj){
	document.getElementById("TextArea").style.display = "none";
	document.getElementById("TextArea").innerHTML = "";
}

function OpenPanel(panelObj){
	if(panelObj.style.display != "block"){
		//HiddenDiv Window
		//Height = 420px | Width = 430px
		panelObj.style.height = "1px";
		panelObj.style.display = "block";
		panelObj.style.height = "420px";
	}
}

function ExpandThisTo(objId, size){
	if(document.getElementById(objId.id).offsetHeight < size - 10){
		document.getElementById(objId.id).style.height = document.getElementById(objId.id).offsetHeight + 10;
		tmp = setTimeout("ExpandThisTo("+ objId.id +"," + size + ")", 15 );
	}
	else{
		objId.style.height = size;

		if(objId.id == "HiddenDiv"){
			document.getElementById("LinksWindowText").style.display = "block";
		}
	}
}
function LinkOver(item, level){
	if(level == "head"){
		if(document.getElementById(item).className != "HeadSelected")
			document.getElementById(item).className = "HeadOver";
	}
	else{
		if(document.getElementById(item).className != "ItemSelected")
			document.getElementById(item).className = "ItemOver";
	}
}

function LinkOut(itemOut, level){
	if(level == "head"){
		if(document.getElementById(itemOut).className != "HeadSelected")
			document.getElementById(itemOut).className = "Head";
	}
	else{
		if(document.getElementById(itemOut).className != "ItemSelected")
			document.getElementById(itemOut).className = "Item";
	}
}

function DermaLinkOver(item){
	document.getElementById(item).className = "DermaLinksOver";
}

function DermaLinkOut(item){
	document.getElementById(item).className = "DermaLinks";
}


function UpdateSelection(Id, level){
	//See what Id.className contains, base the decisions on that.
	if( document.getElementById(displayedText).className.indexOf("Head") != -1)
		document.getElementById(displayedText).className = "Head";
	else 
		document.getElementById(displayedText).className = "Item";
		
	if(Id != "Home"){
		if(level == "head"){
			document.getElementById(Id).className = "HeadSelected";
		}
		else{
			document.getElementById(Id).className = "ItemSelected";
		}
	}
}		

function StartTitleTrans(){
	
	document.body.style.visibility = "visible";
	
	obj = document.getElementById("TitleTop");
	slowhigh(obj);
}

//TEXT FUNCTIONS
function SmallerText(obj){
	if(currentTextSize > 10){
		currentTextSize--;
		HideCurrentText();
		document.getElementById("InfoViewerText").style.fontSize = currentTextSize + "px";
		ShowCurrentText();
	}
}

function LargerText(obj){
	if(currentTextSize < 18){
		currentTextSize++;
		HideCurrentText();
		document.getElementById("InfoViewerText").style.fontSize = currentTextSize + "px";
		ShowCurrentText();
	}
}

function ResetTextSize(){
	document.getElementById("InfoViewerText").style.fontSize = "14px";
	currentTextSize = 14;
}

/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var baseopacity=0

function slowhigh(which2){
	imgobj = which2;
	browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
	instantset(baseopacity)
	highlighting=setInterval("gradualfade(imgobj)",40)
}

function slowlow(which2){
	cleartimer()
	instantset(baseopacity)
}

function instantset(degree){
	if (browserdetect=="mozilla")
		imgobj.style.MozOpacity=degree/100
	else if (browserdetect=="ie")
		imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
	if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
	if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
		cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
	else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
		cur2.filters.alpha.opacity+=3
	else if (window.highlighting)
		clearInterval(highlighting)
}

/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function ChangeColor(newColor){
	if( newColor == "Pink"){
		document.getElementById("hiddenDiv").style.backgroundImage = "url('Images/TextBG3.jpg')";
	}
	if( newColor == "Skin" ){
		document.getElementById("hiddenDiv").style.backgroundImage = "url('Images/TextBG5.jpg')";
	}
	if( newColor == "Brown"){
		document.getElementById("hiddenDiv").style.backgroundImage = "url('Images/TextBG4.jpg')";
	}
}

