/*
	TalkShoe Confidential Information
	Copyright (c) 2005 - 2009 
*/

function embedSWFAdsRight(condition,styleClassID){
	if(condition=="randomized"){
		swfFile = "hotSpotsRight.swf";
	}else{
		swfFile = condition;
	}

	var w = 125;
	var h = 125;
	var swfDir='/resources/talkshoe/images/info/hotspots/';
	
	var swfCode='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '
				  + 'width="'+w+'" height="'+h+'" class="'+styleClassID+'" id="'+styleClassID+'">'
				  + '<param name="allowScriptAccess" value="sameDomain" />'
				  + '<param name="movie" value="'+swfDir+swfFile+'">'
				  + '<param name="quality" value="best" />'
				  + '<param name="wmode" value="transparent" />'
				  + '<param name="bgcolor" value="84BBF3" />'
				  + '<embed src="'+swfDir+swfFile+'" quality="best" wmode="transparent" bgcolor="84BBF3" width="'+w+'" height="'+h+'" '
				  + 'name="'+styleClassID+'" class="'+styleClassID+'" allowScriptAccess="sameDomain" '
				  + 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'
				  + '</embed>'
				  + '</object>';
				  
	document.write(swfCode); 
}

function embedSWFCallToActionBottom(condition,styleClassID){
	if(condition=="randomized"){
		swfFile = "callToActionBottom.swf";
	}else{
		swfFile = condition;
	}

	var w = 622;
	var h = 75;
	var swfDir='/resources/talkshoe/images/info/callToActionBottom/';
	
	var swfCode='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" '
				  + 'width="'+w+'" height="'+h+'" class="'+styleClassID+'" id="'+styleClassID+'">'
				  + '<param name="allowScriptAccess" value="sameDomain" />'
				  + '<param name="movie" value="'+swfDir+swfFile+'">'
				  + '<param name="quality" value="best" />'
				  + '<param name="wmode" value="transparent" />'
				  + '<param name="bgcolor" value="84BBF3" />'
				  + '<embed src="'+swfDir+swfFile+'" quality="best" wmode="transparent" bgcolor="84BBF3" width="'+w+'" height="'+h+'" '
				  + 'name="'+styleClassID+'" class="'+styleClassID+'" allowScriptAccess="sameDomain" '
				  + 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'
				  + '</embed>'
				  + '</object>';
				  
	document.write(swfCode); 
}

////468x60
//Null
var v468x60R1='';
//Null
var v468x60R2='';
//Null
var v468x60R3='';

function PrintAffiliateAd(affiliateAdArray){
var NumOfAdsToRot;
var r;

	if(affiliateAdArray[0]=='468x60'){
		NumOfAdsToRot = 0;
		r = Math.ceil(Math.random() * NumOfAdsToRot);

		if(r=='1'){
			document.writeln(v468x60R1);//Has to be writeln instead of write because of lame 3rd party request.
		}else if(r=='2'){
			document.writeln(v468x60R2);//Has to be writeln instead of write because of lame 3rd party request.
		}else if(r=='3'){
			document.writeln(v468x60R3);
		}else{
			PrintAds468x60Footer('google');
		}
	}
}

var TCProfMrkFlag = "ON"; ///Flag to turn on/off talkcast marketing sub header.
function mrktGenTCProfHeight(cookieName,cookieVal,nDivid, nNewH){
	if(cookieName!='none'){
		createCookie(cookieName,cookieVal,180);
	}
	setFlashHeight(nDivid, nNewH);
}
///TalkCast Profile Top Messaging
function mrktGenTCProf(stateId,userField,talkcastId){
	var masterId = document.getElementById(talkcastId).value;

	if(userField == 'none'){
		var userName = 'no';
		var initSize = 'none';
	}else{
		
		var futureYear = new Date().getFullYear()+1;
		var userName = document.getElementById(userField).value;
		var cookieName = userName + 'TCMsgSwf';
		var initSize = readCookie(cookieName);
		//errorPop(cookieName+':'+initSize);
	}

	var swfFile='tcMessaging.swf';
	var swfDir='/resources/talkshoe/images/info/tc/';
	var styleClassID='TCProfMrktSwf';
	e = canResizeFlash();
	
	if(TCProfMrkFlag == "ON"){
		if(((stateId=='notLoggedInLive') ||
		    (stateId=='notLoggedInDead') ||
		    (stateId=='notHostLive') ||
		    (stateId=='notHostDead') ||
		    (stateId=='hostLive') ||
		    (stateId=='hostDead')) &&
		   (initSize!='small')){
		   	var w=794;
			var h=94;
		}else if(initSize=='small'){
		   	var w=794;
			var h=18;
		}
		
		var swfCode='<div id="'+styleClassID+'Div" style="width:'+w+'px; height:'+h+'px;">'
						  + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" '
						  + 'width="100%" height="100%" class="'+styleClassID+'" id="'+styleClassID+'">'
						  + '<param name="allowScriptAccess" value="sameDomain" />'
						  + '<param name="movie" value="'+swfDir+swfFile+'?userName='+userName+'&masterId='+masterId+'&initSize='+initSize+'&stateId='+stateId+'&allowResize='+e+'">'
						  + '<param name="quality" value="best" />'
						  + '<param name="wmode" value="transparent" />'
						  + '<param name="bgcolor" value="#84BBF3" />'
						  + '<param name="scale" value="noscale" />'
						  + '<param name="align" value="l" />'
						  + '<param name="salign" value="lt" />'
						  + '<embed src="'+swfDir+swfFile+'?userName='+userName+'&masterId='+masterId+'&initSize='+initSize+'&stateId='+stateId+'&allowResize='+e+'" quality="best" wmode="transparent" bgcolor="#84BBF3" width="100%" height="100%" '
						  + 'name="'+styleClassID+'" class="'+styleClassID+'" salign="lt" align="l" scale="noscale" allowScriptAccess="sameDomain" '
						  + 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">'
						  + '</embed>'
						  + '</object>'
					+ '</div>';
			document.write(swfCode);
	}
}

function mrktGenTCProfHostChecker(stateId){
	if(TCProfMrkFlag == "ON"){
		document.getElementById('TalkCastMrktSubHdr').className = "TalkCastMrktSubHdrHost";
	}
}

//////////////GOOGLE AD SECTION/////////////////
//SECTION BELOW IS USED FOR SERVING GOOGLE ADS//
////////////////////////////////////////////////
//Global Google vars
var googleJSLoc = '<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>';
var adClient = 'pub-4328611247056337';
var gColBorder = '024477';
var gColBG = 'FFFFFF';
var gColLink = 'FF5200';
var gColUrl = '4286C5';
var gColText = '22191C';

function printGoogAdDefault(w,h,f,t,c){
var pGoogAdVars = '<script type="text/javascript"><!-- \n'
						+'google_ad_client = "'+adClient+'";\n'
						+'google_ad_width = '+w+';\n'
						+'google_ad_height = '+h+';\n'
						+'google_ad_format = "'+f+'";\n'
						+'google_ad_type = "'+t+'";\n'
						+'google_ad_channel ="'+c+'";\n'
						+'google_color_border = "'+gColBorder+'";\n'
						+'google_color_bg = "'+gColBG+'";\n'
						+'google_color_link = "'+gColLink+'";\n'
						+'google_color_url = "'+gColUrl+'";\n'
						+'google_color_text = "'+gColText+'";\n'
						+'//--></script>';
						
	document.writeln(pGoogAdVars);
	document.writeln(googleJSLoc);
}

function printGoogAdColorVar(w,h,f,t,c,cbrdr,cbg,clink,curl,ctext){
var pGoogAdColVars = '<script type="text/javascript"><!-- \n'
						+'google_ad_client = "'+adClient+'";\n'
						+'google_ad_width = '+w+';\n'
						+'google_ad_height = '+h+';\n'
						+'google_ad_format = "'+f+'";\n'
						+'google_ad_type = "'+t+'";\n'
						+'google_ad_channel ="'+c+'";\n'
						+'google_color_border = "'+cbrdr+'";\n'
						+'google_color_bg = "'+cbg+'";\n'
						+'google_color_link = "'+clink+'";\n'
						+'google_color_url = "'+curl+'";\n'
						+'google_color_text = "'+ctext+'";\n'
						+'//--></script>';
						
	document.writeln(pGoogAdColVars);
	document.writeln(googleJSLoc);
}

function printGoogAdNoColor(w,h,f,t,c){
var pGoogAdsNoColVars = '<script type="text/javascript"><!-- \n'
						+'google_ad_client = "'+adClient+'";\n'
						+'google_ad_width = '+w+';\n'
						+'google_ad_height = '+h+';\n'
						+'google_ad_format = "'+f+'";\n'
						+'google_ad_type = "'+t+'";\n'
						+'google_ad_channel ="'+c+'";\n'
						+'//--></script>';
						
	document.writeln(pGoogAdsNoColVars);
	document.writeln(googleJSLoc);
}

function PrintAdsRight(whichAd){
var pAdsRTextToImageRatio = 4;
var pArTtIr = Math.ceil(Math.random() * pAdsRTextToImageRatio);
var gAdRWidth = '120';
var gAdRHeight = '600';
var gAdRFormat = '120x600_as';
var gAdRChannel = '1';

	if (pArTtIr < pAdsRTextToImageRatio){
		var gAdRType = 'text';
	}else{
		var gAdRType = 'image';
	}

	
	if(whichAd == 'google'){
		printGoogAdDefault(gAdRWidth,gAdRHeight,gAdRFormat,gAdRType,gAdRChannel);
	}else{
		document.write('other');
	}
}

function PrintAdsRightSm(whichAd){
var pAdsRSmTextToImageRatio = 4;
var pArSTtIr = Math.ceil(Math.random() * pAdsRSmTextToImageRatio);
var gAdRSmWidth = '120';
var gAdRSmHeight = '240';
var gAdRSmFormat = '120x240_as';
var gAdRSmChannel = '2';

	if (pArSTtIr < pAdsRSmTextToImageRatio){
		var gAdRSmType = 'text';
	}else{
		var gAdRSmType = 'image';
	}
							
	if(whichAd == 'google'){
		printGoogAdDefault(gAdRSmWidth,gAdRSmHeight,gAdRSmFormat,gAdRSmType,gAdRSmChannel);
	}else{
		document.write('other');
	}
}

function PrintAdsVideoBigBlock(whichAd){
var gAdVBBWidth = '336';
var gAdVBBHeight = '280';
var gAdVBBFormat = '336x280_as';
var gAdVBBType = 'image';
var gAdVBBChannel = '3';
	
	if(whichAd == 'google'){
		printGoogAdNoColor(gAdVBBWidth,gAdVBBHeight,gAdVBBFormat,gAdVBBType,gAdVBBChannel);
	}else{
		document.write('other');
	}
}

function PrintAdsVideoMedBlock(whichAd){
var gAdVMBWidth = '300';
var gAdVMBHeight = '250';
var gAdVMBFormat = '300x250_as';
var gAdVMBType = 'image';
var gAdVMBChannel = '4';
	
	if(whichAd == 'google'){
		printGoogAdNoColor(gAdVMBWidth,gAdVMBHeight,gAdVMBFormat,gAdVMBType,gAdVMBChannel);
	}else{
		document.write('other');
	}
}

function PrintAdsVideoSmBlock(whichAd){
var gAdVSBWidth = '250';
var gAdVSBHeight = '250';
var gAdVSBFormat = '250x250_as';
var gAdVSBType = 'image';
var gAdVSBChannel = '5';
	
	if(whichAd == 'google'){
		printGoogAdNoColor(gAdVSBWidth,gAdVSBHeight,gAdVSBFormat,gAdVSBType,gAdVSBChannel);
	}else{
		document.write('other');
	}
}

function PrintAds468x60Footer(whichAd){
var pFAdsRSmTextToImageRatio = 2;
var pFArSTtIr = Math.ceil(Math.random() * pFAdsRSmTextToImageRatio);
var pFArSTtIrMix = Math.ceil(Math.random() * pFAdsRSmTextToImageRatio);
var gAd468FWidth = '468';
var gAd468FHeight = '60';
var gAd468FFormat = '468x60_as';
var gAd468FChannel = '6';

if (pFArSTtIr < pFAdsRSmTextToImageRatio){
		var gAd468FType = 'text';
	}else{
		var gAd468FType = 'image';
	}
	
	if(whichAd == 'google'){
		printGoogAdDefault(gAd468FWidth,gAd468FHeight,gAd468FFormat,gAd468FType,gAd468FChannel);
	}else{
		if(pFArSTtIrMix == '1'){
			printGoogAdDefault(gAd468FWidth,gAd468FHeight,gAd468FFormat,gAd468FType,gAd468FChannel);
		}else{
			document.writeln(v468x60R1);
		}
	}
}
