/***************************************************************************\
/***************************************************************************\
/**									                                      **\
/**   CC_VCH_Like.js: VCH Like this model Promo.                          **\
/**									                                      **\
/** 	Note: Module expects certain id's to be on in the document        **\
/**			  for it to function properly.							      **\
/**									                                      **\
/**	   Author: Frank Pérez						                          **\
/**	   Date: June 4, 2010				  	                              **\
/**									                                      **\
/***************************************************************************\
/***************************************************************************/

	try
{
	//DECLARE OUR NAMESPACE
	var CCP_LIKE;

	//TEST TO MAKE SURE THAT IT IS NOT ALREADY TAKEN AND CREATE IF NOT TAKEN
	if(!CCP_LIKE) CCP_LIKE = {};

	else if(typeof CCP_LIKE != "object")
	{
		throw new Error("ERROR");
	}

}
catch(e){alert(e);}

CCP_LIKE.hostInfo = new Array();
CCP_LIKE.current = 0;
CCP_LIKE.alt = 'See :screenname:! LIVE on Cam!';

CCP_LIKE.ini = function (numOfThumbs,backgroungMontage,siWidth,siHeight)
{

	//ID REFERENCES NEEDED
	//CCP_LIKE.tagline = document.getElementById('cc_tagline');
	CCP_LIKE.hostcontainer = document.getElementById('cc_hostcontainer');
	CCP_LIKE.promoBody = document.getElementById('cc_promoBody');
	CCP_LIKE.hostImgEl = document.getElementById('cc_hostImgEl');
	CCP_LIKE.hostname = document.getElementById('cc_hostname');
	CCP_LIKE.hostquote = document.getElementById('cc_hostquote');
	CCP_LIKE.yesbutt = document.getElementById('cc_yesbutt');
	CCP_LIKE.nobutt = document.getElementById('cc_nobutt');
	CCP_LIKE.yesbuttlink = document.getElementById('cc_yesbuttlink');

	CCP_LIKE.bckGrdMtg = backgroungMontage;
	CCP_LIKE.numOfThumbs = numOfThumbs;
	CCP_LIKE.siWidth = siWidth;
	CCP_LIKE.siHeight = siHeight;

	CCP_LIKE.changeHost();
};

CCP_LIKE.changeHost = function()
{
	if(CCP_LIKE.current < CCP_LIKE.numOfThumbs )
	{
		//SET HOST INFO
		CCP_LIKE.hostImgEl.alt = CCP_LIKE.hostImgEl.title = CCP_LIKE.hostname.title = CCP_LIKE.hostquote.title = CCP_LIKE.hostcontainer.alt = CCP_LIKE.hostcontainer.title = CCP_LIKE.yesbutt.alt = CCP_LIKE.yesbutt.title = CCP_LIKE._getNewTitle();
		CCP_LIKE.hostImgEl.onerror = function () { swapUnavailableProfileImage(CCP_LIKE.hostImgEl, {width:CCP_LIKE.siWidth,height:CCP_LIKE.siHeight, gender:CCP_LIKE.hostInfo[CCP_LIKE.current].gender}) };
		CCP_LIKE.hostImgEl.src = CCP_LIKE.hostInfo[CCP_LIKE.current].ImgSrc;
		CCP_LIKE.hostname.childNodes[0].nodeValue = CCP_LIKE.hostInfo[CCP_LIKE.current].screenname;
		CCP_LIKE.hostquote.childNodes[0].nodeValue = CCP_LIKE.hostInfo[CCP_LIKE.current].desc;
		CCP_LIKE.yesbuttlink.href = CCP_LIKE.hostcontainer.href = CCP_LIKE.linkHref + CCP_LIKE.hostInfo[CCP_LIKE.current].screenname;

		//THUMBNAIL OPACITY
		var thumb = document.getElementById('cc_thumb_'+(CCP_LIKE.current+1));
		thumb.className = '';

		if(CCP_LIKE.current != 0)
		{
			var prevthumb = document.getElementById('cc_thumb_'+CCP_LIKE.prevThumb);
				prevthumb.className = 'opaque';
		}

		CCP_LIKE.prevThumb = CCP_LIKE.current+1;
		CCP_LIKE.current++;
	}
	else
	{
		var newImgLink = document.createElement('a');
		newImgLink.href = CCP_LIKE.liveHostLink;
		newImgLink.target = '_blank';
		var newImg = document.createElement("img");
		newImg.src = CCP_LIKE.bckGrdMtg;
		newImg.border = '0';
		newImgLink.appendChild(newImg);
		CCP_LIKE.promoBody.innerHTML = '';
		CCP_LIKE.promoBody.appendChild(newImgLink);
	}

};

CCP_LIKE._getNewTitle = function()
{
	return CCP_LIKE.alt.replace(':screenname:',CCP_LIKE.hostInfo[CCP_LIKE.current].screenname);
};
