var oCurContent_home = null;
var oCurContent_who = null;
var oGalleryDisplay = new ckGalleryDisplayObj();

function onclick_menu(sArea) {
	if (pageID != "home") document.location.href="/index.asp?mi=" + sArea;
	else {
		var sTitle = "";
		var oEl;
		var bShowWait = false;
		
		if (oCurContent_home) {
			oCurContent_home.style.display="none";
			//resets
			switch (oCurContent_home.id) {
				case "content.who" :
					if (oCurContent_who) oCurContent_who.style.display="none";
					break;
			}
		}

		switch (sArea) {
			case "testimonials" :
				sTitle = "People Who Like Us"
				bShowWait = true;
				getTestimonials();
				break;
			case "who" :
				sTitle = "Meet The Team"
				var oSWF = new ckSWFObj("/meetTheTeam_menu.swf",525,250,"#FFFFFF");				oSWF.addContainerStyle("float","right");				oSWF.setWMode("transparent");
				oSWF.embed("content_who_menu");
				break;
			case "what" :
				sTitle = "What is CK?"
				break;
			case "websites" :
			case "logos" :
				sTitle = "";
				oGalleryDisplay.getImages(sArea=="websites" ? "131" : "132");
				
				sArea = "gallery"
				bShowWait = true;
				break;
			
			
		}
		oCurContent_home = document.getElementById("content_" + sArea);
		
		if (oEl = document.getElementById("pageTitle")) oEl.innerHTML= sTitle;
		if ((oCurContent_home) && (!bShowWait)) oCurContent_home.style.display="block";
		if (bShowWait) oFloatingWindow.showWait("[ . Working . ]");

	}
}

/*---------------------------------------------------------------------------------
Meet The Team
---------------------------------------------------------------------------------*/
function onclick_who(sName) {
	var oEl;

	if (oCurContent_who) oCurContent_who.style.display="none";
	if (oCurContent_who = document.getElementById("content_who_" + sName.toLowerCase())) oCurContent_who.style.display="block";
}


/*---------------------------------------------------------------------------------
Testimonials
---------------------------------------------------------------------------------*/
var aTestimonials = Array();
var curTestimonialIndex=0;
function getTestimonials() {
	var sData = "actionCode=getTestimonials&keepFields=entryID,entryTitle,text1,text3,firstImageURL";
	(new ckAjaxObj()).postFormData("/ckcommon/genericText/ajax/entry_action.asp",sData,ajaxReturnHandler_getTestimonials)
				
}
function ajaxReturnHandler_getTestimonials(oAjax) {
	var oResponse,El;
	if (oResponse = oAjax.responseObj) {
		//alert(objectDebugStr(oResponse,3));
		aTestimonials = (oResponse.payload.aResults);
			
		displayTestimonial(0);
		oFloatingWindow.hide();
	}
}
	
	
function onclick_nextTestimonial() {displayTestimonial(curTestimonialIndex+1); }
function onclick_prevTestimonial() {displayTestimonial(curTestimonialIndex-1); }

function displayTestimonial(index) {
	var oEl;
	
	if ((index >= 0) && (index < aTestimonials.length) && (aTestimonials[index])) {
		var oEntry = aTestimonials[index];
		//alert(objectDebugStr(oEntry));
		var sHTML = oEntry.text3.replace("\\n","<br>") + '<br><br><span class="textHigh">' + oEntry.text1 + '</span>';
		var sHTML = oEntry.text3 + '<br><br><span class="textHigh">' + oEntry.text1 + '</span>';
		if (oEl = document.getElementById("testimonials_title")) oEl.innerHTML = oEntry.entryTitle;
		if (oEl = document.getElementById("testimonials_entry")) oEl.innerHTML = sHTML;
		if (oEl = document.getElementById("testimonials_image")) oEl.src = (oEntry.firstImageURL=="" ? "/_ckcommon/images/spacer.gif" : oEntry.firstImageURL);
			
		curTestimonialIndex = index;
		
		if (oEl = document.getElementById("testimonials_nextButton")) oEl.className=(curTestimonialIndex == (aTestimonials.length-1) ? "controlButton-disabled" : "");
		if (oEl = document.getElementById("testimonials_prevButton")) oEl.className=(curTestimonialIndex > 0 ? "" : "controlButton-disabled");
	}

	if (oCurContent_home) oCurContent_home.style.display="block"; 
}
	
/*---------------------------------------------------------------------------------
Gallery
---------------------------------------------------------------------------------*/
ckGalleryDisplayObj.prototype.displayGroup_addOnHandler = function() {
	var oEl;
	
	//block below not common which is why in addOnHandler...entered in admin as just a text field, not specifically a link
	if (oEl = document.getElementById("gallery_primaryText_link")) { 
		oEl.style.display=(this.oGroup.grpSubname=="" ? "none" : "block");
		if ((this.oGroup.grpSubname != "") && (this.oGroup.grpSubname.slice(0,3)=="www")) {
			this.oGroup.grpSubname = "http://" + this.oGroup.grpSubname;
		}
		if (oEl = document.getElementById("gallery_primaryText_href")) {
			oEl.href=this.oGroup.grpSubname;
			oEl.innerHTML = this.oGroup.grpSubname;
		}
		//by default, clicking on the image will take user to url entered in grpSubname. Individual image links can/will override
		var oTemp;
		for (var index=0; index < this.oGroup.aImages.length; index++) {
			oTemp = this.oGroup.aImages[index];
			if (oTemp.imgLink=="") {
				oTemp.imgLink=this.oGroup.grpSubname;
				oTemp.imgLinkTarget="_blank";
			}
		}
	}
	oFloatingWindow.hide();
	if (oCurContent_home) oCurContent_home.style.display="block";  //make sure gallery is showing
}

