
// this is what gets run when the page loads
$(document).ready(function(){

	if(PC.isEditMode){ return; }	// we want it to be fast

    // handle barker list types without overlays
    PC.makeBlockAnchors(".barkerList dl:not(.disabled)", "mouseover");	// pass in jquery selector and hover css class
    
    // handle barker list types with overlays
    //PC.makeBlockAnchorsWithOverlays(".barkerBlockPromo dl:not(.disabled)", "mouseover");	// pass in jquery selector and hover css class
    //PC.makeBlockAnchorsWithOverlays(".barkerBlockLP dl:not(.disabled)", "mouseover");	// pass in jquery selector and hover css class

    
	// inject the logo with flash that shows the air date.  the PC.currentDateKey will be passed to the flash
	// only do it if there is a currentDateKey
	var headerIdentityDiv2 = document.getElementById("headerIdentityDiv2");
	var html = "";
	html += '<div><a href="http://www.bet.com/specials/betawards08" style="display:block;height:85px;width:185px;"></a></div>';
	html += '<div style="position: relative; left: 211px; bottom: 42px; width: 115px; height: 36px;">';
	html += '<a target="_blank" href="http://www.msn.com">';
	html += '<img src="/webapplications/betroot/includes/theme/beta2008/img/msn_SponsorLogo2.jpg" />';
	html += '</a></div>';
	//if(PC.currentDateKey){
		/*In the future if you have more than one element being placed into the headerIdentityDiv dynamically make sure they are not dependent upon one another.*/
		/*var file = "http://www.bet.com/webapplications/betroot/includes/theme/beta2008/img/beta08_date_06_24.swf";
		html += "<div style=\"width: 355px; height: 67px; position: relative; left: 313px; top: 35px; z-index: 1;\">";
		html += PC.getFlashHtml(355, 67, file, 9, "", FlashWMode.Transparent, "", true, true);
		html += "</div>";	*/
				
	//}



	headerIdentityDiv2.innerHTML = html;
	
	// on the comments hr element, we need to add a div to get the faded line
	$("div.commentsDiv hr").replaceWith("<div class=\"hrDiv\"></div>");
	
	
	/*var xsbList = document.getElementById("extraSmallBarkerListDiv2");*/
	var header = "";
	header+='<div class="msnTitle">';
	header+='<a target="_blank" href="http://www.msn.com">More on MSN ></a>';
	header+='</div>';
	
	$(".extraSmallBarkerList").before(header);
	
	var urlGrabber ="";
	urlGrabber+='<div class="grabber">';
    urlGrabber+='<span>URL:</span>';
    urlGrabber+='<input class="actionUrlBox" name="urlText" type="text" readonly="readonly" id="widgetText" onclick="javascript:this.form.widgetText.focus();this.form.widgetText.select();" />';
    urlGrabber+='</div>'; 
       
    $(".videoDetails").after(urlGrabber);
      
	var locationUrl = window.location.toString();
	var qs = locationUrl.indexOf('?', 0);
	qs = qs >= 0 ? qs : locationUrl.length;
	jQuery('.actionUrlBox').val(locationUrl.substring(0, qs));
	
	// newsletter signup
	//$('#leftNavAndSponsorDiv2').append('<b>Hello World</b>');

	var outerDiv = $('#leftNavAndSponsorDiv2').get(0);
	
	if(outerDiv != null){

		var html = '<div class="newsletterSignupDiv"><input type="text" class="emailTextbox" /><input type="button" class="submitButton" value="Go" /></div><div class="newsletterSignupMessageDiv"><span>Thank you</span></div>'
		$(outerDiv).append(html);
		
		var button = $(outerDiv).find('.submitButton').get(0);
		var emailTextbox = $(outerDiv).find('.emailTextbox').get(0);
		
		var controller = {
				nullValueText: 'ENTER E-MAIL',
				isActive: false,
				getIsNull: function(){
					var actualValue = this.textbox.value;
					if(Util && Util.trim){ actualValue = Util.trim(actualValue); }
					return actualValue == '' || actualValue == this.nullValueText;
				},
				getValue: function(){
					if(this.getIsNull()){
						return null;
					}else{
						return this.textbox.value;
					}
				},
				update: function(){
					if(this.isActive){
						if(this.getIsNull()){
							this.textbox.value = '';
						}
						$(this.textbox).removeClass('emptyTextbox');
					}else{
						if(this.getIsNull()){
							this.textbox.value = this.nullValueText;
							$(this.textbox).addClass('emptyTextbox');
						}		
					}
				},
				onclick: function(){
					this.isActive = true;
					this.update();
				},
				onblur: function(){
					this.isActive = false;
					this.update();
				},
				attach: function(textbox){
					textbox._controller = this;
					this.textbox = textbox;
					if(this.textbox.value == ''){
						this.textbox.value = this.nullValueText;
					}
					var me = this;
					textbox.onclick = function(){ me.onclick(); };
					textbox.onblur = function(){ me.onblur(); };	
					this.update();
				}
			};
			controller.attach(emailTextbox);
			emailTextbox.blur();
		
		if(button != null && emailTextbox != null){
			button.onclick = function(){
				var emailAddress = emailTextbox.value;
				
				var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				if(!emailAddress.match(emailRegEx)){
					alert('Please enter valid email address.');
					//emailTextbox.focus();
					emailTextbox.select();
					return false;
				}
				
				var subscriptionID = 2068066151;
				var url = '/webapplications/betroot/services/generic/web/subscriptions.aspx?SubsciberEmail=' + emailAddress + '&SubscriptionID=' + subscriptionID;
				$.getJSON(url, null, function(data){				
					$(outerDiv).find('.newsletterSignupDiv').css('display', 'none');
					$(outerDiv).find('.newsletterSignupMessageDiv').css('display', 'block');		
				});
			}
		}
		
		
		
	}
	
	//Adding the footer buttons
	//The footer buttons must not be on the online ballot page.
	if(location.pathname.toLowerCase().indexOf('betawards-onlineballot')==-1)
	{
		var buttonsDiv = '';
		buttonsDiv += '<div class="webToolButtonsDiv">';
		buttonsDiv += '<a class="button1" id="pressRoom" href="http://bet.mediaroom.com/">';
		buttonsDiv += '<img src="/webapplications/betroot/includes/theme/beta2008/img/pressroom_button.jpg" />';
		buttonsDiv += '</a><a class="button2" id="webTools" href=" http://www.bet.com/specials/betawards08/webtools">';
		buttonsDiv += '<img src="/webapplications/betroot/includes/theme/beta2008/img/webtools_button.jpg" />';
		buttonsDiv += '</a></div>';
		
		$("#footerLinksDiv").after(buttonsDiv);
		//End Footer Buttons/
	}
});


// set the currentDateKey based on a DateMap
// setup a DateMap to map the current date to a mappedValue.  this will be passed into the flash items.
var dateMap = new DateMap();
dateMap.addMapBegin("0");	// no start date means it is already started
dateMap.addMapBegin("1", 2008, 4, 11, 0, 0, 0);
dateMap.addMapBegin("2", 2008, 4, 12, 0, 0, 0);
// below is how to add an item with an endDate
var item = dateMap.addMapBegin("1000", 2008, 4, 13, 0, 0, 0);
item.setEndDate(2008, 4, 14, 0, 0, 0);   // add the endDate

// set the currentDateKey of the PageController.  this will be passed in to the flash.
PC.currentDateKey = dateMap.getValue(PC.originServeDate);









