﻿// JScript File

var PopVisible = false;
var LightBoxHoldertop = '30%';
var LightBoxHolderleft = '40%';
var DisplayErrorTime = 2;
var CurrentPage = window.location.pathname.toLowerCase();
var VersionPlayer = '1.0';
var VersionPlayerV2 = '1.1.9218';

function SelectAllFiles(cb,RepeaterID)
    {
        var cbStatus = document.getElementById(cb).checked;
        var tbl  = document.getElementById(RepeaterID);
        var checkbox = tbl.getElementsByTagName('input');
        switch(cb)
        {
            case "cbSelectAll":
                document.getElementById('cbSelectAll2').checked = cbStatus;
                break;
            case "cbSelectAll2":
                document.getElementById('cbSelectAll').checked = cbStatus;
                break;
        }
        for (var iCount=0; iCount<checkbox.length;iCount++) 
        {
            var ElementId  = '';
            if(iCount < 10)
            {
                ElementId  = 'ctl00_ContentPlaceHolder1_rFiles_ctl0'+ iCount + '_cbSelect';
            }
            else
            {
                ElementId  = 'ctl00_ContentPlaceHolder1_rFiles_ctl'+ iCount + '_cbSelect';
            }
            var cbli = document.getElementById(ElementId);
            if(cbli != null)
            {
                cbli.checked = cbStatus;
            }
        }
    }
function CheckPostBack()    
{
    return false;
}
var coords = [0,0];
function scrollElement(ElementID,Direction,Pixels,MaxScroll)
{
        var Element = document.getElementById(ElementID);
        
        switch (Direction.toLowerCase())
            {
            case 'up':
                coords[1] = coords[1] + Pixels;
	            Element.style.top = coords[1] + 'px';
                break;
            case 'right':
                if(coords[0] < 0)
                {
                    coords[0] =  coords[0] + Pixels;
	                Element.style.left = coords[0] + 'px';
	            }
	            else
	            {
	            }
                break;
            case 'down':
                coords[1] = coords[1] - Pixels;
	            Element.style.top = coords[1] + 'px';
                break;
            case 'left':
                if(coords[0] > MaxScroll * -1)
                {
                    coords[0] =  coords[0] - Pixels;
	                Element.style.left = coords[0] + 'px';
	            }
	            else
	            {
	            }
                break;
             }
             if(FindMeAtContentHolder != null)
             {
                CheckScrollButtons();
             }
}
function findPos(obj) 
{
	var curleft = curtop = 0;
	if(obj != null)
	{
	    if (obj.offsetParent) 
	    {
		    curleft = obj.offsetLeft
		    curtop = obj.offsetTop
		    while (obj = obj.offsetParent) 
		    {
			    curleft += obj.offsetLeft
			    curtop += obj.offsetTop
		    }
	    }
	}
	return [curleft,curtop];
}

function findRelitivePos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
	}
	return [curleft,curtop];
}
var UserCommentPop;
function CommentShowFan(obj)
{
    var UserInfoPopupHolderDiv = document.getElementById('UserInfoPopupHolderDiv');
    var CommentsScrollBar = document.getElementById('CommentsScrollBar');
    FanPopObjPreFix = obj.id.substring(0,obj.id.indexOf('imgFan'));
    var CommentHolder = document.getElementById(FanPopObjPreFix+'CommentHolder');
    UserCommentPop = document.getElementById(FanPopObjPreFix+'UserCommentPop');
    var CommentsScrollBarPos = [0,0];
    var FanPopCoords = [0,0];
        
    if(is.ie) 
    {
        if(is.ie6)
        {
            UserInfoPopupHolderDiv.className = 'UserInfoPopupHolderie6';
        }
        FanPopCoords = findPos(CommentHolder);
        var GetFanYPos = findPos(CommentHolder);
        
        objPop = UserInfoPopupHolderDiv;
        FanPopCoords[0] = FanPopCoords[0] + 35;
        FanPopCoords[1] = GetFanYPos[1] - 233;
    }
    else
    {
        CommentsScrollBarPos = findPos(CommentsScrollBar);
        FanPopCoords = findRelitivePos(CommentHolder);
        objPop = UserInfoPopupHolderDiv;
        FanPopCoords[0] = FanPopCoords[0] + 50;
        FanPopCoords[1] = FanPopCoords[1] + 73;// + CommentsScrollBarPos[1] - 335;
    }
    objPop = UserInfoPopupHolderDiv;
    PosX = FanPopCoords[0];
    PosY = FanPopCoords[1] - CommentsScrollBar.scrollTop;
    PopulateFanPop(obj);
    timedCount();
}
function populateFindMeAt(FindMe)
{
    var arrayFindMe = FindMe.split('~');
    FindMeSiteLogos.innerHTML = '';
    if(arrayFindMe.length > 1)
    {
        FindMeAtDivHolder.style.display = '';
        for(iFindMyLink = 0; iFindMyLink< arrayFindMe.length-1; iFindMyLink++)
        {
            var FindMeAt = arrayFindMe[iFindMyLink].split("|");
            FindMeSiteLogos.innerHTML += '<div class="FindMeLogoSmall">\n<a href="'+FindMeAt[0]+'" target="_blank"><img src="'+FindMeAt[1]+'" /></a>\n</div>';
            if(iFindMyLink < arrayFindMe.length - 1)
                {
                    FindMeSiteLogos.innerHTML += '<div class="FindMeSeperatorSmall"><img src="http://assets.play.it/images/Pop_findMe_seperator.gif" /></div>';
                }
        }
    }
    else
    {
        FindMeAtDivHolder.style.display = 'none';
    }
}
var FanPopCoords = [0,0];
function ShowCollaborator(obj)
{
    var UserInfoPopupHolderDiv = document.getElementById('UserInfoPopupHolderDiv');
    var FanHolder = document.getElementById('FanHolder');
    if(obj != null)
    {
        FanPopObjPreFix = obj.id.substring(0,obj.id.indexOf('FanLink'));
        var FanImageLink = document.getElementById(FanPopObjPreFix+'FanInfoHolder');
        var FanImg = document.getElementById(FanPopObjPreFix+'imgFan');
        
        var CommentsScrollBar = document.getElementById('CommentScrollHolder');

        var FanHolderPos = findPos(FanHolder);
        var FanPopCoords = findPos(FanImageLink);
        
        if(is.ie) 
        {
            if(is.ie6)
            {
                UserInfoPopupHolderDiv.className = 'UserInfoPopupHolderie6';
            }
            FanPopCoords[0] = FanPopCoords[0] - 5 + FanImageLink.offsetWidth;
            FanPopCoords[1] = FanPopCoords[1] - 250;
        }
        else
        {
            FanPopCoords[0] = FanPopCoords[0] + 5 + FanImageLink.offsetWidth;
            FanPopCoords[1] = FanPopCoords[1] + 55;
        }
        
        objPop = UserInfoPopupHolderDiv;
        PosX = FanPopCoords[0];
        PosY = FanPopCoords[1];
        if(CommentsScrollBar != null)
        {
            PosY = PosY - CommentsScrollBar.scrollTop;
        }
        
        PopulateFanPop(FanImg);
        timedCount();
    }
}
function ShowFan(obj)
{

    var UserInfoPopupHolderDiv = document.getElementById('UserInfoPopupHolderDiv');
    var FanHolder = document.getElementById('FanHolder');
    if(obj != null)
    {
        FanPopObjPreFix = obj.id.substring(0,obj.id.indexOf('imgFan'));
        var FanImageLink = document.getElementById(FanPopObjPreFix+'FanInfoHolder');

        var FanHolderPos = findPos(FanHolder);
        var FanPopCoords = findPos(FanImageLink);
        
            
        if(is.ie) 
        {
            if(is.ie6)
            {
                UserInfoPopupHolderDiv.className = 'UserInfoPopupHolderie6';
            }
            FanPopCoords[0] = FanPopCoords[0] + 90;
            FanPopCoords[1] = FanPopCoords[1] - 210;
        }
        else
        {
            FanPopCoords[0] = FanPopCoords[0] + 100;
            FanPopCoords[1] = FanPopCoords[1] + 94;
        }
        
        objPop = UserInfoPopupHolderDiv;
        PosX = FanPopCoords[0];
        PosY = FanPopCoords[1];
        
        PopulateFanPop(obj);
        timedCount();
    }
}

var t;
var objPop;
var PosX = 0;
var PosY = 0;
var FanPopObjPreFix = '';
var BGDisabled = false;
var page_width = 0;
var page_height = 0;
var wrapperWidth = document.getElementById("wrapper").offsetWidth + 30;
var hasPromos;
var doStationSearch;
var p;
var s;
var st;
var gn;

function timedCount(Sender,newPosX,newPosY)
{
    if(!PopVisible)
    {
        t=setTimeout("DisplayFanInfoOffSet()",2000);  
    }
    else
    {
        DisplayFanInfoOffSet();
    }
}

function stopTimer()
{
    clearTimeout(t);
}
function StartCloseTimer()
{
    if(PopVisible)
    {
        t=setTimeout("HideUserInfo()",3000);  
    }
}
var oFanName = '';
var NewFan = false;
var MemberPopMessagePrefix = '';
if(CurrentPage == "/stationfans.aspx")
{
    MemberPopMessagePrefix = 'Member since: ';
}
function PopulateFanPop(obj)
{
    if(obj != "")
        FanPopObjPreFix = obj.id.substring(0,obj.id.indexOf('imgFan'));
    var FindMe = document.getElementById(FanPopObjPreFix+'lblFindMeAt').innerHTML;
    var FanHolder = document.getElementById('FanHolder');
    var FanImageLink = document.getElementById(FanPopObjPreFix+'FanInfoHolder');
    var FanNameLable = document.getElementById(FanPopObjPreFix+'ltbFanPageLink')
    var oFanLink = document.getElementById(FanPopObjPreFix+'FanLink');
    var FanName;
    var FanNameTitle;
    if(obj.className != "HiddenData")
    {
        FanName = FanNameLable.innerHTML;
        FanNameTitle = FanNameLable.title;
    }
    else
    {
        FanName = oFanLink.innerHTML;
        FanNameTitle = oFanLink.title;
    }
    
    var FanLink = oFanLink.href;
    var iProducedStations = document.getElementById(FanPopObjPreFix+'lblProducedStations').innerHTML

    if(oFanName == '')
    {
        oFanName = FanName;
        NewFan = false;
    }
    else
    {
        oFanName = FanName;
        NewFan = true;
    }
    
    ListenerImage.src = obj.src.replace("medium","large").replace("small","large").replace("SMALL","large");
    if(iProducedStations != '0')
    {
        lblProducedStations.style.display = '';
        if(iProducedStations == '1')
        {
            lblProducedStations.innerHTML =  '<a href="/search.aspx?t=ls&s=' + FanNameTitle + '">Produced '+ iProducedStations + ' Station</a>';
        }
        else
        {
            lblProducedStations.innerHTML =  '<a href="/search.aspx?t=ls&s=' + FanNameTitle + '">Produced '+ iProducedStations + ' Stations</a>';
        }
    }
    else
    {
        lblProducedStations.style.display = 'none';
    }
    
    ListenerLink.href = FanLink;
    ListenerLink.title = FanNameTitle;
    ListenerScreenName.innerHTML = FanName;
    ListenerImage.title = FanNameTitle;
    ListenerImage.alt = FanName;
    lblJoinDate.innerHTML = MemberPopMessagePrefix + document.getElementById(FanPopObjPreFix+'lblSignUpDate').innerHTML;
    ListenerImageLink.href = FanLink;
    //TruncateText(ListenerScreenName,100);
    populateFindMeAt(FindMe);
}

function ShowStationFan(obj, xShift, yShift)
{
    var xDiff = 45;
    if(xShift == null)
    {
        xShift=105;
        xDiff=0;
    }
    if(yShift == null) yShift=-210;
    FanPopObjPreFix = obj.id.substring(0,obj.id.indexOf('imgFan'));
    var FanImageLink = document.getElementById(FanPopObjPreFix+'FanInfoHolder');
    var UserInfoPopupHolderDiv = document.getElementById('UserInfoPopupHolderDiv');
    var LeftPointer = document.getElementById('LeftPointer');
    
    var FanPopCoords = findPos(FanImageLink);
    
    //LeftPointer.style.top = '155px';
    
    if(is.ie) 
    {
        if(is.ie6)
        {
            UserInfoPopupHolderDiv.className = 'UserInfoPopupHolderie6';
        }
        objPop = UserInfoPopupHolderDiv;
        PosX = FanPopCoords[0] + xShift;// + 105;
        PosY = FanPopCoords[1] + yShift;// - 125;
    }
    else
    {
        objPop = UserInfoPopupHolderDiv;
        PosX = FanPopCoords[0] + xShift + xDiff;// + 105;
        PosY = FanPopCoords[1] + yShift + 305;// - 125;
    }

    PopulateFanPop(obj);
    timedCount();
}

function DisplayFanInfo(obj,x,y)
{
    obj.style.position = 'relitive';
    obj.style.display = '';
    obj.style.top = y + 'px';
    obj.style.left = x +'px';
    obj.style.zIndex = 10;
}

function DisplayFanInfoOffSet()
{
    PopVisible = true;
    
//    document.body.onclick = function()
//    {
//        if(PopVisible)
//            {
//                HideUserInfo();
//            }
//    }
    objPop.style.position = 'absolute';
    objPop.style.display = '';
    objPop.style.top = PosY + 'px';
    objPop.style.zIndex = 10;
    objPop.style.left = PosX + 'px';
    
    if(is.ie) 
    {
    }
    else
    {
        objPop.style.left = (PosX - 10) +'px';
        objPop.style.top = (PosY - 305) + 'px';
    }
    stopTimer();
    StartCloseTimer();
    if(NewFan)
    {
        if(ScrollerDiv != null)
        {
            ScrollerDiv.style.left = '0px';
            coords[0] = 0;
        }
    }
    CheckScrollButtons();
}
function DisplayFanInfoCommentOffSet()
{
    PopVisible = true;
    objPop.style.position = 'relitive';
    objPop.style.display = '';
    objPop.style.top = PosY + 'px';
    objPop.style.zIndex = 10;
    objPop.style.left = PosX + 'px';
    
    stopTimer();
    StartCloseTimer();
}

var is = new Is();
function Is() 
{
    agent  = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns    = ((agent.indexOf('mozilla') != -1) && 
      ((agent.indexOf('spoofer')  ==   -1) && (agent.indexOf('compatible') == -1)));
    this.firefox = (this.ns && (agent.indexOf('firefox') != -1));
    this.ns4   = (this.ns && (this.major == 4));
    this.ns6   = (this.ns && (this.major >= 5));
    this.ie    = (agent.indexOf("msie") != -1);
    this.ie3   = (this.ie && (this.major  < 4));
    this.ie4   = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
    this.ie5   = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") != -1));
    this.ie55  = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
    this.ie6   = (this.ie && (agent.indexOf("msie 6.0")!=-1) );
    this.ie7   = (this.ie && (agent.indexOf("msie 7.0")!=-1) );
    this.opera = (agent.indexOf("opera") != -1);
    this.safari = (agent.indexOf("safari") != -1);
    this.Win16   = (navigator.platform == "Win16");
    this.Mac   = (navigator.platform == "Mac" || navigator.platform == "MacIntel");
    this.Win32   = (navigator.platform == "Win32");
    this.Win64   = (navigator.platform == "Win64");
    this.OtherOS = (this.Win16 == false && this.Mac == false && this.Win32 == false && this.Win64 == false);
}
var ShowPostCommentVisible;
var ShowReplyToCommentVisible = false;
var SendToFriendVisible = false;
var SendInviteToFriendVisible = false;
var StationSearchVisible = false;
var CollaboratorLightBoxVisible = false;
var AbandonStationVisible = false;
var CollaboratorRightsLightBoxVisible = false;
var ResizeEventExists = false;
var ChangePasswordVisible = false;
var WhatisThisLightVisible = false;
var TransferOwnershipFormVisible;
var VerifyAbandonVisible;
var isTargetPage;

function DisableBG() 
{
    if(PopVisible != null && PopVisible)
    {
        HideUserInfo();
    }
    EndOFPagecoords = findPos(document.getElementById('EndOFPage'));
    if(is.opera) 
    {
        page_width=document.body.clientWidth;
        page_height=document.body.clientHeight;        
    }
    else if(is.firefox || is.ns6 || is.safari) 
    {
        page_width=innerWidth;
        page_height=innerHeight;
    } 
    else if(is.ie) 
    {
        page_width=document.body.clientWidth;
        page_height=document.body.clientHeight;
        if(is.ie6)
        {
            var formtag  = document.getElementById("aspnetForm");
            var Controls = formtag.getElementsByTagName('Select');
            for(var iControlCount = 0; iControlCount < Controls.length; iControlCount++)
            {
                if(Controls[iControlCount].id != "ctl00_ContentPlaceHolder1_ddSearchType")
                    Controls[iControlCount].style.display = 'none';
            }
        }
    }
    else
    {
    }
    if(EndOFPagecoords[1] < page_height)
    {
        EndOFPagecoords[1] = page_height;
    }
    if(page_width < wrapperWidth)
    {
        if(is.ie)
        {
            LightBoxHolderleft = page_width * .25;
        }
        page_width = wrapperWidth;
    }
    layerSetup();
    
    var UploadImageButton = document.getElementById('UploadImageButtonHolder');
    if(UploadImageButton != null)
    {
        UploadImageButton.style.display = 'none';
    }
    BGDisabled = true;
}
if(is.ie) 
{
    document.body.onresize = function ()
    {
        if(BGDisabled)
        {
            if(page_width < wrapperWidth)
            {
                LightBoxHolderleft = page_width * .25;
                page_width = wrapperWidth;
            }
            else
            {
                LightBoxHolderleft = '40%';
            }
            if(ShowPostCommentVisible != null && ShowPostCommentVisible)
            {
                ShowPostComment();
            }
            if(ShowReplyToCommentVisible != null && ShowReplyToCommentVisible)
            {
                ShowReplyToComment();
            }
            if(SendToFriendVisible)
            {
                ShowSendToFriend();
            }
            if(SendInviteToFriendVisible)
            {
                ShowInviteAFriend();
            }
            if(StationSearchVisible)
            {
                ShowStationSearch();
            }
            if(CollaboratorLightBoxVisible)
            {
                ShowCollaboratorLightBox();
            }
            if(CollaboratorRightsLightBoxVisible)
            {
                ShowEditCollaboratorRights();
            }
            if(ChangePasswordVisible)
            {
                ShowChangePasswordLightBox();
            } 
            if(WhatisThisLightVisible)
            {
                ShowWhatisThisLightBox();
            } 
            if(TransferOwnershipFormVisible)
            {
                ShowTransferOwnership();
            }
            if(VerifyAbandonVisible)
            {
                showVerifyAbandon();
            }
        }
    }
    if(isTargetPage)
    {
        document.body.onbeforeunload = function (evt) 
        {
           if(hasFlash)
            main.gcpsCommand("unlock", "", "");
        }
    }
}
else
{
    window.onresize = function ()
    {
        if(BGDisabled)
        {
            if(page_width < wrapperWidth)
            {
                LightBoxHolderleft = page_width * .25;
                page_width = wrapperWidth;
            }
            else
            {
                LightBoxHolderleft = '40%';
            }
            if(ShowPostCommentVisible != null && ShowPostCommentVisible)
            {
                ShowPostComment();
            }
            if(ShowReplyToCommentVisible != null && ShowReplyToCommentVisible)
            {
                ShowReplyToComment();
            }
            if(SendToFriendVisible)
            {
                ShowSendToFriend();
            }
            if(SendInviteToFriendVisible)
            {
                ShowInviteAFriend();
            }
            if(StationSearchVisible)
            {
                ShowStationSearch();
            }
            if(CollaboratorLightBoxVisible)
            {
                ShowCollaboratorLightBox();
            }
            if(CollaboratorRightsLightBoxVisible)
            {
                ShowEditCollaboratorRights();
            }
            if(ChangePasswordVisible)
            {
                ShowChangePasswordLightBox();
            }    
            if(WhatisThisLightVisible)
            {
                ShowWhatisThisLightBox();
            }
            if(VerifyAbandonVisible)
            {
                showVerifyAbandon();
            }    
        }
    }
    if(isTargetPage)
    {
        window.onbeforeunload = function (evt) {
           main.gcpsCommand("unlock", "", "");}
    }
}

function layerObject(id,position) 
{
    if (is.ie || is.ns6 || is.firefox || is.opera || is.safari)
    {
        var obj = document.getElementById(id).style;
        obj.position = position;
        obj.left = 0;
        obj.top = 0;
        obj.height = EndOFPagecoords[1] + 'px';
        obj.display = '';
        obj.width = page_width + 'px';
        obj.zIndex = 2;
    }
    else
    {
    }
}
function layerSetup() 
{
    if(is.firefox)
    {
        var FireFoxDisableLayer = document.getElementById('divDisableFireFox');
        if(FireFoxDisableLayer != null)
        {
            layerObject('divDisableFireFox','absolute');
            return;
        }
    }
    layerObject('divDisableMasterPage','absolute');
}


function PlayStation(StationID,sd)
{
    window.open('http://playerv2.play.it/playerv2/PlayitPlayer.php?version=' +VersionPlayerV2 +'&station='+StationID,"Player");
}
function LaunchMix(e)
{
    oEvent = (window.event) ? window.event : e;
    switch(oEvent.keyCode) {
        case 13: //enter
            PlayMix();
            oEvent.returnValue=false; 
            oEvent.cancel = true;
            break;
        default:
            return false;
            break;
    }
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };

function PlayMix()
{
    CreateAMix = document.getElementById('txbCreateAMix').value.trim();
    if(CreateAMix != "" && !isDefaultMixText(CreateAMix))
    {
        CreateAMix = escape(CreateAMix);
        window.open("http://player.radio.com/player/PlayitPlayer.php?version=1.1&mix=1&mid="+CreateAMix,"Player");
    }
    return false;
}
function PlayHistoryMix(Mix)
{
    MixValue = document.getElementById(Mix).title;
    Mix = escape(MixValue.substring(0,MixValue.length - 6));
    window.open("http://player.radio.com/player/PlayitPlayer.php?version=1.1&mix=1&mid="+Mix,"Player");
}

function Search()
{
    var SearchType = document.getElementById('ddSearchType').value;	
    var SearchTerm = document.getElementById('txbSearchFor').value;	
    window.location.href = 'search.aspx?t='+ SearchType + "&s=" + SearchTerm;	
}
var EndOFPagecoords = [0,0];
function fixFooter()
{
    EndOFPagecoords = findPos(document.getElementById('EndOFPage'));
    if(is.opera) 
    {
        page_width=document.body.clientWidth;
        page_height=document.body.clientHeight;        
    }
    else if(is.firefox || is.ns6 || is.safari) 
    {
        page_width=innerWidth;
        page_height=innerHeight;
    } 
    else if(is.ie) 
    {
        page_width=document.body.clientWidth;
        page_height=document.body.clientHeight;
    }
    else
    {
    }
    
    if(EndOFPagecoords[1] < page_height && !is.opera)
    {
        //force footer to the bottom of the page
        var PageContentDiv = document.getElementById('PageContent');    
        PageContentDiv.style.height = (page_height - 144) + 'px';
    }
}
fixFooter();

function ClearSendToFriend(obj)
{
    var ObjPreFix = obj.id.substring(0,obj.id.indexOf('ClearForm'));
    var txbEmailTo = document.getElementById('txbEmailTo');
    var txbFrom = document.getElementById(ObjPreFix+'txbFrom');
    var txbMessage = document.getElementById(ObjPreFix+'txbMessage');
    try
    {
        txbEmailTo.value = '';
        txbFrom.value = myEmail.value;
        txbMessage.value = DefaultSendInviteToFriendMessage;
    }
    catch (e)
    {
        txbEmailTo.value = '';
        txbFrom.value = '';
        txbMessage.value = '';
    }
    HideLightBox();
}
function HideLightBox()
{    
    var PostCommentOverLay = document.getElementById('LightBoxHolder');
    if(PostCommentOverLay != null)
    {
        PostCommentOverLay.style.display = 'none';
        SendToFriendVisible = false;
    
        ShowPostCommentVisible = false;
        ShowReplyToCommentVisible = false;
        ActivateBG();
    }
}
function ShowSendToFriend()
{
    DisableBG();

    var LightBoxHolder = document.getElementById('LightBoxHolder');
    var txbEmailTo = document.getElementById('txbEmailTo');
    
    if(is.ie6)
    {
        LightBoxHolder.style.position = 'absolute';
    }
    else
    {
        LightBoxHolder.style.position = 'fixed';    
    }
    LightBoxHolder.style.display = '';
    LightBoxHolder.style.top = LightBoxHoldertop;
    LightBoxHolder.style.left = LightBoxHolderleft;
    LightBoxHolder.style.zIndex = 20009;
    txbEmailTo.focus(); 
    SendToFriendButtonActivate();
    SendToFriendVisible = true;
}
function hidePostComment()
{
    if(ShowPostCommentVisible)
    {
        var PostCommentOverLay = document.getElementById('lbPostComment');
        var txbComment = document.getElementById('txbComment');
        
        if(PostCommentOverLay != null)
        {
            PostCommentOverLay.style.display = 'none';
        }
        
        if(txbComment != null)
        {
            txbComment.value = '';
        }
        
        ShowPostCommentVisible = false;
        ActivateBG();
    }
}

function hideRelpyToComment()
{
    var ReplyToCommentOverLay = document.getElementById('lbReplyComment');
    var txtReplyComment = document.getElementById('txtReplyComment');
    
    if(ReplyToCommentOverLay != null)
    {
        ReplyToCommentOverLay.style.display = 'none';
    }
    
    if(txtReplyComment != null)
    {
        txtReplyComment.value = '';
    }
    
    ShowReplyToCommentVisible = false;
    ActivateBG();
}
function ShowPostComment()
{
    DisableBG();
    var lbPostComment = document.getElementById('lbPostComment');
    txbComment = document.getElementById('txbComment');
    ShowPostCommentVisible = true;
    if(m != "1")
    {
        var txbComment = document.getElementById('txbComment');
        txbComment.className = "lbPostBoxModerated";
    }
    if(is.ie6)
    {
        lbPostComment.style.position = 'absolute';
    }
    else
    {
        lbPostComment.style.position = 'fixed';    
    }
    lbPostComment.style.display = '';
    lbPostComment.style.top = LightBoxHoldertop;
    lbPostComment.style.left = LightBoxHolderleft;
    lbPostComment.style.zIndex = 10009;
    txbComment.focus();
    StartPostCommentButtonActivate();
}

function ShowReplyToComment()
{
        DisableBG();
        var lbReplyComment = document.getElementById('lbReplyComment');
        txtReplyComment = document.getElementById('txtReplyComment');
        ShowReplyToCommentVisible = true;
        
        if(is.ie6)
        {
            lbReplyComment.style.position = 'absolute';
        }
        else
        {
            lbReplyComment.style.position = 'fixed';    
        }
        
        lbReplyComment.style.display = '';        
        lbReplyComment.style.top = LightBoxHoldertop;
        lbReplyComment.style.left = LightBoxHolderleft;
        lbReplyComment.style.zIndex = 10009;
        txtReplyComment.focus();
        ReplyToCommentButtonActivate();
}
function setReplyToID(CommentId, ListenerID, Status)
{
    var replyToCommentID = document.getElementById("replyToCommentID");
    var replyToListenerID = document.getElementById("replyToListenerID");
    var replyToCommentStatus = document.getElementById("replyToCommentStatus");
    replyToCommentID.value = CommentId;
    replyToListenerID.value = ListenerID;
    replyToCommentStatus.value = Status;
}

function CheckReplyToComment()
{
    var comment = document.getElementById('txtReplyComment');
    if (comment != null && comment.value.length > 0)
    {
        return true;
    }
    return false;
}

function ReplyToCommentButtonActivate()
{
    if (CheckReplyToComment())
    {
        if (ibtReplyToPostComment.addEventListener) {
        ibtReplyToPostComment.addEventListener ("mouseover",PostReplyToCommentButtonOver,false);
        ibtReplyToPostComment.addEventListener ("mouseout",PostReplyToCommentButtonOut,false);
        } else if (ibtReplyToPostComment.attachEvent) {
        ibtReplyToPostComment.attachEvent ("onmouseover",PostReplyToCommentButtonOver);
        ibtReplyToPostComment.attachEvent ("onmouseout",PostReplyToCommentButtonOut);
        } else {
        ibtReplyToPostComment.onmouseover = PostReplyToCommentButtonOver;
        ibtReplyToPostComment.onmouseout = PostReplyToCommentButtonOut;
        } 
        ibtReplyToPostComment.disabled = false;
        ibtReplyToPostComment.src = 'http://assets.play.it/images/button_post.gif';
        return;
    }
    ibtReplyToPostComment.src = 'http://assets.play.it/images/button_post_inactive.gif';
    ibtReplyToPostComment.disabled = true;
    ibtReplyToPostComment.onmouseover = null;
    ibtReplyToPostComment.onmouseout = null;
}
function PostReplyToCommentButtonOver()
{
        ibtReplyToPostComment.src='http://assets.play.it/images/button_post_over.gif';
}
function PostReplyToCommentButtonOut()
{
        ibtReplyToPostComment.src='http://assets.play.it/images/button_post.gif';
}

function MakeSendPassURL(sendPassLinkObj)
{
    var sendPassLink = sendPassLinkObj.href;
    sendPassLink = sendPassLink + "?rType=sendPass&passEmail=" + document.getElementById('txtEmail').value;
    sendPassLinkObj.href = sendPassLink;
    sendPassLink = "";

}
var SelectedStationName = '';
var SelectedStationID = '';
    function SelectStationID(obj)
    {
    }
    function PrePopulatedStationInfo()
    {
        try
        {
            if(PreSelectedStationName == null || PreSelectedStationID == null || PreSelectedStationName == "" || PreSelectedStationID == "")
                return;
            
            SelectedStationName = PreSelectedStationName;
            SelectedStationID = PreSelectedStationID;
            SelectedStationIDLabel.innerHTML = SelectedStationID;
            
            var StationSearchDiv = document.getElementById('StationSearch');
            var StationSelectedDiv = document.getElementById('StationSelected');
            StationSearchDiv.style.display = 'none';
            StationSelectedDiv.style.display = '';
            var date_now = new Date();
            sendRequest("/StationInfoObject.aspx?id="+SelectedStationID+"&ck="+escape(date_now.toTimeString()),PopulateStationObj);    
            
            UpdatePreview(ddSiteList);
        }
        catch(e)
        {
            return;
        }
    }
    
    function PopulateStationObj(StationInfo)
    {
        var SelectedStationNameLable = document.getElementById('SelectedStationName');
        SelectedStationNameLable.innerHTML = StationInfo.responseText;
    }
    
    function SelectStation(obj)
    {
        
        SelectedObjPreFix = obj.id.substring(0,obj.id.indexOf('SelectStationButton'));
        SelectedStationName = document.getElementById(SelectedObjPreFix+'lblStationName').innerHTML;
        SelectedStationID = document.getElementById(SelectedObjPreFix+'lblStationID').innerHTML;
        SelectedStationIDLabel.innerHTML = SelectedStationID;
        
        var StationSearchDiv = document.getElementById('StationSearch');
        var StationSelectedDiv = document.getElementById('StationSelected');
        StationSearchDiv.style.display = 'none';
        StationSelectedDiv.style.display = '';
        var date_now = new Date();
        sendRequest("/StationInfoObject.aspx?id="+SelectedStationID+"&ck="+escape(date_now.toTimeString()),PopulateStationObj);    
        
        UpdatePreview(ddSiteList);
        HideStationSearch();
    }
    function UpdatePreview(obj)
    {
        var CodeInstructions = document.getElementById('CodeInstructions');
        if(SelectedStationID != '')
        {
            switch(obj.value)
            {
                case 'default':
                    CodeInstructions.innerHTML = "Here's your code to copy and paste:";
                    txbPreviewCode.value = '<table width="294" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="top"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" height="411" width="294"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://wilshiremedia.com/adrian/CBSRadio_EmbedShell.swf?R1=##SelectedStationID##" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="salign" value="lt" /><embed type="application/x-shockwave-flash" allowScriptAccess="never" allowNetworking="internal" src="http://wilshiremedia.com/adrian/CBSRadio_EmbedShell.swf?R1=##SelectedStationID##" height="411" width="294" wmode="transparent" quality="high" salign="lt" /></object></td></tr><tr><td align="center" valign="top"><a href="http://www.play.it" target="_blank"><img src="http://wilshiremedia.com/adrian/r20_footerButton.gif" width="294" height="24" border="0" align="top" /></a></td></tr></table>';
                    break;
                case 'myspace':
                    CodeInstructions.innerHTML = "Here's your code to copy and paste:";
                    txbPreviewCode.value = '<table width="294" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="top"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" height="411" width="294"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://wilshiremedia.com/adrian/CBSRadio_EmbedShell.swf?R1=##SelectedStationID##" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="salign" value="lt" /><embed type="application/x-shockwave-flash" allowScriptAccess="never" allowNetworking="internal" src="http://wilshiremedia.com/adrian/CBSRadio_EmbedShell.swf?R1=##SelectedStationID##" height="411" width="294" wmode="transparent" quality="high" salign="lt" /></object></td></tr><tr><td align="center" valign="top"><a href="http://www.play.it" target="_blank"><img src="http://wilshiremedia.com/adrian/r20_footerButton.gif" width="294" height="24" border="0" align="top" /></a></td></tr></table>';
                    break;
                case 'facebook':
                    //CodeInstructions.innerHTML = 'In facebook Search for the Application – "Profile HTML" <br> Add the application to your profile.<br> Paste the code below into the application:';
                    txbPreviewCode.value = 'We are working on a facebook widget, instructions are coming soon.';
                    //txbPreviewCode.value = '<fb:swf swfsrc="http://player.play.it/player/CBSRadio_Player_small.swf?R20Station=##SelectedStationID##&UseRoll=false&UseShare=false&PartnerSource=PLAYIT&UseDCTrack=false&TargetPlayer=PlayitWidget" imgsrc="http://assets.play.it/images/widget_player.jpg" height="411" width="294" ><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://player.play.it/player/CBSRadio_Player_small.swf?R20Station=##SelectedStationID##&UseRoll=false&UseShare=false&PartnerSource=PLAYIT&UseDCTrack=false&TargetPlayer=PlayitWidget" /><param name="quality" value="high" /><param name="salign" value="lt" /><param name="wmode" value="transparent" /></fb:swf><center>Click above to listen to ##SelectedStationName## on Play.it or <a href="http://www.play.it">Click Here to Create!</a></center>';
                    break;
                case 'lastfm':
                    CodeInstructions.innerHTML = "Here's your code to copy and paste:";
                    txbPreviewCode.value = '<table width="294" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="top"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" height="411" width="294"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://wilshiremedia.com/adrian/CBSRadio_EmbedShell.swf?R1=##SelectedStationID##" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="salign" value="lt" /><embed type="application/x-shockwave-flash" allowScriptAccess="never" allowNetworking="internal" src="http://wilshiremedia.com/adrian/CBSRadio_EmbedShell.swf?R1=##SelectedStationID##" height="411" width="294" wmode="transparent" quality="high" salign="lt" /></object></td></tr><tr><td align="center" valign="top"><a href="http://www.play.it" target="_blank"><img src="http://wilshiremedia.com/adrian/r20_footerButton.gif" width="294" height="24" border="0" align="top" /></a></td></tr></table>';
                    break;
                default:
                    CodeInstructions.innerHTML = "Here's your code to copy and paste:";
                    txbPreviewCode.value = '<table width="294" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="top"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" height="411" width="294"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://wilshiremedia.com/adrian/CBSRadio_EmbedShell.swf?R1=##SelectedStationID##" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="salign" value="lt" /><embed type="application/x-shockwave-flash" allowScriptAccess="never" allowNetworking="internal" src="http://wilshiremedia.com/adrian/CBSRadio_EmbedShell.swf?R1=##SelectedStationID##" height="411" width="294" wmode="transparent" quality="high" salign="lt" /></object></td></tr><tr><td align="center" valign="top"><a href="http://www.play.it" target="_blank"><img src="http://wilshiremedia.com/adrian/r20_footerButton.gif" width="294" height="24" border="0" align="top" /></a></td></tr></table>';
                    break;
            }
            PopulateCodePreview();
        }
    }
    function PopulateCodePreview()
    {
        while(txbPreviewCode.value.indexOf("##SelectedStationID##") > -1)
        {
            txbPreviewCode.value = txbPreviewCode.value.replace('##SelectedStationName##',SelectedStationName).replace('##SelectedStationID##',SelectedStationID);
        }
        CheckEmailSendButton();
    }
    function PopulateSearchBox()
    {
        txbSearchFor.value = txbStationName.value;
    }
    function ShowStationSearch()
    {
        DisableBG();
        var LightBoxHolder = document.getElementById('WidgetLightBoxHolder');
        
        StationSearchVisible = true;
        
        if(is.ie6)
        {
            LightBoxHolder.style.position = 'absolute';
        }
        else
        {
            LightBoxHolder.style.position = 'fixed';    
        }
        
        LightBoxHolder.style.display = '';
        LightBoxHolder.style.top = LightBoxHoldertop;
        LightBoxHolder.style.left = LightBoxHolderleft;
        LightBoxHolder.style.zIndex = 10009;
        txbSearchFor.focus();
    }
    var ShowStationSearchOnLoad;
    function HideStationSearch()
    {    
        var PostCommentOverLay = document.getElementById('WidgetLightBoxHolder');
        if(!ShowStationSearchOnLoad)
        {
            if(PostCommentOverLay != null)
            {
                PostCommentOverLay.style.display = 'none';
                StationSearchVisible = false
            }
            ShowPostCommentVisible = false;
            ActivateBG();
        }
        else
        {
            ShowStationSearch();
        }
        ShowStationSearchOnLoad = false;
    }
    
    function ClearAndHideStationSearch()
    {
        /*if(NoWidgetStations == null)
        {
            var StationSearchResultsDiv = document.getElementById('StationSearchResultsDiv');
            StationSearchResultsDiv.innerHTML = '<div class="noDataWidgetHolder"><div class="noDataHead"><img src="http://assets.play.it/images/ndAvatar.gif" /><img src="http://assets.play.it/images/ndPointer.gif" style="padding-left:5px;" /></div><div class="noDataWidgetCloud"><div class="noDataWidget">No results were found, please try again. </div></div></div>';
        }*/
        WidgetSearchTextBox.value = "";
        WidgetSearchType.value = "sn";
        HideStationSearch();
    }
    HideStationSearch();

    function ShowCollaboratorLightBox()
    {
        DisableBG();
        var LightBoxHolder = document.getElementById('InviteCollaboratorLightBoxHolder');
        var txbAddCollaboratorID = document.getElementById('txbAddCollaboratorID');
        
        CollaboratorLightBoxVisible = true;
        
        if(is.ie6)
        {
            LightBoxHolder.style.position = 'absolute';
        }
        else
        {
            LightBoxHolder.style.position = 'fixed';    
        }
        
        LightBoxHolder.style.display = '';
        LightBoxHolder.style.top = LightBoxHoldertop;
        LightBoxHolder.style.left = LightBoxHolderleft;
        LightBoxHolder.style.zIndex = 10009;
        txbAddCollaboratorID.focus();
        
        if(StationPropertyCollaboratorErrorTitle != null)
        {
            FixedErrorMessage = true;
            ShowError(txbAddCollaboratorID,StationPropertyCollaboratorErrorTitle,StationPropertyCollaboratorErrorMessage);
        }
    }
    
    function ShowStationErrorPO()
    {
            FixedErrorMessage = true;
        ShowError(oErrorBox,StationErrorTitle,StationErrorMessage.replace("&apos;","'"));
    }
    
    function HideCollaboratorLightBox()
    {
        InviteCollaboratorLightBox = document.getElementById('InviteCollaboratorLightBoxHolder');
        if(InviteCollaboratorLightBox != null)
        {
            CollaboratorLightBoxVisible = false;
            InviteCollaboratorLightBox.style.display = 'none';
            ActivateBG();
            HidePO();
            if(CurrentAction == 'add')
                CurrentAction = '';
        }
        EnableFormSubmit();
    }

   
    function ShowAbandonStationLightBox()
    {
        var cbAbandon = document.getElementById('cbAbandon');
        if(cbAbandon.checked == true)
        {
            DisableBG();
            var LightBoxHolder = document.getElementById('AbandonStationLightBoxHolder');
            AbandonStationVisible = true;
            
            if(is.ie6)
            {
                LightBoxHolder.style.position = 'absolute';
            }
            else
            {
                LightBoxHolder.style.position = 'fixed';    
            }
        
            LightBoxHolder.style.display = '';
            LightBoxHolder.style.top = LightBoxHoldertop;
            LightBoxHolder.style.left = LightBoxHolderleft;
            LightBoxHolder.style.zIndex = 10009;    
        }
    }
    
    function HideAbandonStationLightBox()
    {
        AbandonStationLightBox = document.getElementById('AbandonStationLightBoxHolder');
        if(AbandonStationLightBox != null)
        {
            AbandonStationVisible = false;
            AbandonStationLightBox.style.display = 'none';
            ActivateBG();
        }
    }

var StationPropertyCollaboratorErrorTitle;
var StationPropertyTranseferErrorTitle;


    function ShowTransferOwnership()
    {
        var TransferOwnershipForm = document.getElementById('TransferOwnershipForm');
        var txtBoxFindES = document.getElementById('txtBoxFindES');
        DisableFormSubmit();
        if(TransferOwnershipForm != null)
        {
            DisableBG();
            TransferOwnershipFormVisible = true;
            
            if(is.ie6)
            {
                TransferOwnershipForm.style.position = 'absolute';
            }
            else
            {
                TransferOwnershipForm.style.position = 'fixed';    
            }
        
            TransferOwnershipForm.style.display = '';
            TransferOwnershipForm.style.top = LightBoxHoldertop;
            TransferOwnershipForm.style.left = LightBoxHolderleft;
            TransferOwnershipForm.style.zIndex = 10009;    
            txtBoxFindES.focus();
            CheckTransferButton();
            
            if(StationPropertyTranseferErrorTitle != null)
            {
                FixedErrorMessage = true;
                ShowError(txtBoxFindES,StationPropertyTranseferErrorTitle,StationPropertyErrorMessage);
            }
        }
        
        
        
    }
    function HideTransferOwnership()
    {
        var TransferOwnershipForm = document.getElementById('TransferOwnershipForm');
        if(TransferOwnershipForm != null)
        {
            TransferOwnershipFormVisible = false;
            TransferOwnershipForm.style.display = 'none';
            ActivateBG();
            HidePO();
            if(CurrentAction == 'transfer')
                CurrentAction = '';
        }
        EnableFormSubmit();
    }
    function ShowAbandonStation()
    {
        var cbAbandon = document.getElementById('cbAbandon');
        var AbandonStationForm = document.getElementById('AbandonStationBoxHolder');
        if(cbAbandon.checked == true)
        {
            AbandonStationForm.style.display = '';
            HideTransferOwnership();
        }
        else
        {
            AbandonStationForm.style.display = 'none';
        }
    }
    function HideAbandonStation()
    {
        var cbTransfer = document.getElementById('cbAbandon');
        cbTransfer.checked = false;
        ShowAbandonStation();
    }

var SelectedUserID = '';
var SelectedCurrentPermissions = '';
var SelectedUserName = '';

    function ShowEditCollaboratorRights()
    {
        ShowEditCollaboratorRightsLightBox(SelectedUserID,SelectedCurrentPermissions,SelectedUserName);
    }
    
    function ShowEditCollaboratorRightsLightBox(UserID,CurrentPermissions,UserName)
    {
        SelectedUserID = UserID;
        SelectedCurrentPermissions = CurrentPermissions;
        SelectedUserName = UserName;
        DisableFormSubmit();
        DisableBG();
        var LightBoxHolder = document.getElementById('CollaboratorRightsLightBox');
        var lblCollaboratorScreenName = document.getElementById('lblCollaboratorScreenName');
        var hChangeRightsID = document.getElementById('hChangeRightsID');
        var rblEditRights = document.getElementById('rblEditRights');
        lblCollaboratorScreenName.innerHTML = UserName;
        hChangeRightsID.value = UserName;
        var RadioButtons = rblEditRights.getElementsByTagName('INPUT');
        for (var ButtonID=0; ButtonID<RadioButtons.length;ButtonID++) 
        {
            if(RadioButtons[ButtonID].value.toUpperCase() == CurrentPermissions.toUpperCase())
            {
                RadioButtons[ButtonID].checked = true;
            }
        }
 
        CollaboratorRightsLightBoxVisible = true;
        
        if(is.ie6)
        {
            LightBoxHolder.style.position = 'absolute';
        }
        else
        {
            LightBoxHolder.style.position = 'fixed';    
        }
        
        LightBoxHolder.style.display = '';
        LightBoxHolder.style.top = LightBoxHoldertop;
        LightBoxHolder.style.left = LightBoxHolderleft;
        LightBoxHolder.style.zIndex = 10009;    
    }
    
    function HideEditCollaboratorRightsLightBox()
    {
        EditCollaboratorRightsLightBox = document.getElementById('CollaboratorRightsLightBox');
        if(EditCollaboratorRightsLightBox != null)
        {
            CollaboratorRightsLightBoxVisible = false;
            EditCollaboratorRightsLightBox.style.display = 'none';
            ActivateBG();
        }
        EnableFormSubmit();
    }


var DenyID = document.getElementById("DenyID");
var DenyType = document.getElementById("DenyType");
var DenyStationID = document.getElementById("DenyStationID");
var AbandonMessage = document.getElementById("AbandonMessage");
    function showAbandonCollaboration(iDenyStationID,CollaboratorID)
    {
        DenyID.value = CollaboratorID;
        DenyType.value = "DeclineCollaboration";
        DenyStationID.value = iDenyStationID;
        showVerifyAbandon();
    }
    
    function showVerifyAbandon()
    {
        DisableBG();
        var LightBoxHolder = document.getElementById('VerifyAbandon');
        VerifyAbandonVisible = true;
        
        if(is.ie6)
        {
            LightBoxHolder.style.position = 'absolute';
        }
        else
        {
            LightBoxHolder.style.position = 'fixed';    
        }
        
        LightBoxHolder.style.display = '';
        LightBoxHolder.style.top = LightBoxHoldertop;
        LightBoxHolder.style.left = LightBoxHolderleft;
        LightBoxHolder.style.zIndex = 10009;
    }
    
    function HideVerifyAbandon()
    {
        ChangePasswordLightBox = document.getElementById('VerifyAbandon');
        if(ChangePasswordLightBox != null)
        { 
            VerifyAbandonVisible = false;
            ChangePasswordLightBox.style.display = 'none';
            DenyID.value = '';
            DenyType.value = '';
            DenyStationID.value = '';
            ActivateBG();
        }
    }
    
    function ShowChangePasswordLightBox()
    {
        DisableBG();
        var LightBoxHolder = document.getElementById('lbChangePassword');
        var oldPassword = document.getElementById('oldPassword');
        
        ChangePasswordVisible = true;
        
        if(is.ie6)
        {
            LightBoxHolder.style.position = 'absolute';
        }
        else
        {
            LightBoxHolder.style.position = 'fixed';    
        }
        
        LightBoxHolder.style.display = '';
        LightBoxHolder.style.top = LightBoxHoldertop;
        LightBoxHolder.style.left = LightBoxHolderleft;
        LightBoxHolder.style.zIndex = 10009;
        oldPassword.focus();
    }
    
    function HideChangePasswordLightBox()
    {
        ChangePasswordLightBox = document.getElementById('lbChangePassword');
        if(ChangePasswordLightBox != null)
        { 
            ChangePasswordVisible = false;
            ChangePasswordLightBox.style.display = 'none';
            ActivateBG();
        }
    }
HideChangePasswordLightBox();
function UseDeaultImage()
{
    var txbStationName = document.getElementById('txbStationName');
    userImage = document.getElementById('userImage');
    userImage.src = "http://assets.play.it/StationBanners/playitbanner_default_medium.jpg";
    TitleOverLay.style.display = '';
    TitleOverLay.innerHTML = txbStationName.value;
    HiddenImg = document.getElementById('HiddenImg');
    HiddenImg.value = "UseDefault";
}
function UseDeaultListenerImage()
{
    userImage = document.getElementById('userImage');
    userImage.src = "http://assets.play.it/images/fanx_large.gif";
    HiddenImg = document.getElementById('HiddenImg');
    HiddenImg.value = "UseDefault";
}
var StationNameTruncateTimer;
var StationTagLineTruncateTimer;
var StationNameTooLong = false;
var StationTagLineTooLong = false;
var InvalidStationName = false;
function TrucateStationTitle()
{
    var txbStationName = document.getElementById('txbStationName');
    while(lblStationName.offsetHeight > 14 || lblStationName.offsetWidth > 380)
    {
        txbStationName.value = txbStationName.value.substring(0, txbStationName.value.length - 1);
        lblStationName.innerHTML = txbStationName.value;
    }
    UpdateStationTitle();
}
function UpdateStationTitle()
{
    userImage = document.getElementById('userImage');
    if(CurrentPage == "/stationproperties.aspx")
    {
        var txbStationName = document.getElementById('txbStationName');
        var StationURLPreview = document.getElementById('StationURL');
        if(StationURLPreview != null)
        {
            //var UpdatedStationNameMessage = document.getElementById('UpdatedStationNameMessage');
            if(txbStationName.value == OrginalStationName)
            {
                StationURLPreview.innerHTML = "<a href='http://" + window.location.host + "/stations/" + escape(txbStationName.value) +"' class='formBar' target='_blank'>http://" + window.location.host + "/stations/" + txbStationName.value.replace("<","&lt;").replace(">","&gt;") +"</a>";
                //UpdatedStationNameMessage.style.visibility = 'hidden';
            }
            else
            {
                StationURLPreview.innerHTML = "http://" + window.location.host + "/stations/" + txbStationName.value.replace("<","&lt;").replace(">","&gt;");
                //UpdatedStationNameMessage.style.visibility = 'visible';
            }
		}
        lblStationName.innerHTML = txbStationName.value.replace("<","&lt;").replace(">","&gt;");
    
        if(userImage != null)
        {
            if(userImage.src.indexOf("playitbanner_default_medium.jpg") > 0)
            {
                if(txbStationName != null)
                {
                    TitleOverLay.innerHTML = txbStationName.value.replace("<","&lt;").replace(">","&gt;");
                }
            }
            else
            {
                var txbStationName = document.getElementById('txbStationName');
                if(txbStationName != null)
                {
                    TitleOverLay.style.display = 'none';
                }
                userImage.style.width = "432px"; 
                userImage.style.height = "57px";
            }
        }
        clearTimeout(StationNameTruncateTimer);
        if(lblStationName.offsetHeight > 14 || lblStationName.offsetWidth > 380)
        {
            if(!InvalidStationName)
            {
                ShowError(txbStationName,'Too Long','You have exceeded the character limit for this field.');
                StationNameTruncateTimer = setTimeout("TrucateStationTitle()",DisplayErrorTime * 1000);
                StationNameTooLong = true;
            }
        }
        else
        {
            if(StationNameTooLong)
            {
                HidePO();
                StationNameTooLong = false;
            }
        }
        UpdateCollaborator(sid);
        EnableSaveButton();
    }
}
function TrucateStationSlogan()
{
    var txbStationSlogan = document.getElementById('txbStationSlogan');
    var StationMoto = document.getElementById('StationMoto');
    lblStationSlogan.innerHTML = txbStationSlogan.value.replace("<","&lt;").replace(">","&gt;");
    while(lblStationSlogan.offsetHeight > 14 || lblStationSlogan.offsetWidth > 380)
    {
        txbStationSlogan.value = txbStationSlogan.value.substring(0, txbStationSlogan.value.length - 1);
        lblStationSlogan.innerHTML = txbStationSlogan.value;
    }
    UpdateSloganPreview();
}
function UpdateSloganPreview()
{
    var txbStationSlogan = document.getElementById('txbStationSlogan');
    var StationMoto = document.getElementById('StationMoto');
    lblStationSlogan.innerHTML = txbStationSlogan.value.replace("<","&lt;").replace(">","&gt;");
    clearTimeout(StationTagLineTruncateTimer);
    if(lblStationSlogan.offsetHeight > 14 || lblStationSlogan.offsetWidth > 380)
    {
        ShowError(txbStationSlogan,'Too Long','You have exceeded the character limit for this field.');
        StationTagLineTruncateTimer = setTimeout("TrucateStationSlogan()",DisplayErrorTime * 1000);
        StationTagLineTooLong = true;
    }
    else
    {
        if(StationTagLineTooLong)
        {
            HidePO();
            StationTagLineTooLong = false;
        }
    }
    EnableSaveButton();
//    var UpdatedTagLineMessage = document.getElementById('UpdatedTagLineMessage');
//    if(OrginalTagLine != txbStationSlogan.value)
//    {
//        UpdatedTagLineMessage.style.visibility = 'visible';
//    }
//    else
//    {
//        UpdatedTagLineMessage.style.visibility = 'hidden';
//    }
}
var DisplayTime;
var DisplayTruncateTimer;
function runTimer()
{
    DisplayTruncateTimer = setTimeout("UpdateDisplayTime()",1000);
    DisplayTime--;
}
function UpdateDisplayTime()
{
    var TuncateTimerDisplay = document.getElementById('TuncateTimerDisplay');
    if(TuncateTimerDisplay != null)
        TuncateTimerDisplay.innerHTML = DisplayTime;
    if(DisplayTime > 1)
    {
        runTimer();
    }
}
function ActivateSection()
{
    var currentSection;
    for(var iSectionCount = 0; iSectionCount < Sections.length; iSectionCount++)
    {
        if(Sections[iSectionCount] != ActiveSection)
        {
           currentSection = document.getElementById(Sections[iSectionCount]);
           if(currentSection.className.indexOf("Inactive") == -1)
                currentSection.className = currentSection.className + "Inactive";
        }
        else
        {
           currentSection = document.getElementById(Sections[iSectionCount]);
           currentSection.className = currentSection.className.replace("Inactive","");
        }
    }
}

function CheckSignUpPage()
{
    var txtEmail = document.getElementById("txtEmail");
    
    if(txtEmail != null)
    {
        if(txtEmail.value != '') 
        {
            var fake_email = document.getElementById("fake_email");
            if(fake_email != null)
            {
                fake_email.style.display = 'none';
            }
        }
    }
       
    var txtScreenName = document.getElementById("txtScreenName");
    if(txtScreenName != null)
    {
        if(txtScreenName.value != '') 
        {
            var fake_screenName = document.getElementById("fake_screenName");
            fake_screenName.style.display = 'none';
        }
    }
}
CheckSignUpPage();

function CheckPasswordStrength(obj)
{
    var password = obj.value;
    
}
function FixUpAction()
{
   var loc = window.location.href;
   var sx = loc.search(/\/stations\//);
   var lx = loc.search(/\/listeners\//);
   var newaction = '';
   var faction = document.aspnetForm.action;
   var sfx = faction.search(/\/stations\//);
   if (is.firefox)
   {
      if (sfx >= 0)
      {
         newaction = faction.substring(0,sx+1) + faction.substring(sx+10);
         document.aspnetForm.action = newaction;
         return;
      }
   }
   if (is.ie7 || is.ie6 || is.safari)
   {
      if (sfx >= 0)
      {
         newaction = faction.substring(0,sx+1) + faction.substring(sx+10);
         document.aspnetForm.action = newaction;
         return;
      }
      if (sx >= 0)
      {
         newaction = loc.substring(0,sx+1) + faction;
         document.aspnetForm.action = newaction;
         return;
      }
      if (lx >= 0)
      {
         newaction = loc.substring(0,lx+1) + faction;
         document.aspnetForm.action = newaction;
      }
   }
}

	function ShowWhatisThisLightBox()
    {
        DisableBG();
        HidePO();
        var WhatisThisContent = document.getElementById('lbWhatIsThis');
        var WhatisThisLightBox = document.getElementById('dynHookup');
        WhatisThisLightBox.innerHTML = WhatisThisContent.innerHTML;
        WhatisThisLightVisible = true;
        
        if(is.ie6)
        {
            WhatisThisLightBox.style.position = 'absolute';
        }
        else
        {
            WhatisThisLightBox.style.position = 'fixed';    
        }
        
        WhatisThisLightBox.style.display = '';
        WhatisThisLightBox.style.top = LightBoxHoldertop;
        WhatisThisLightBox.style.left = LightBoxHolderleft;
        WhatisThisLightBox.style.zIndex = 10009;
    }
    
    function HideWhatisThisLightBox()
    {
        WhatisThisLightBox = document.getElementById('dynHookup');
        if(WhatisThisLightBox != null)
        { 
            WhatisThisLightBox.innerHTML = '';
            WhatisThisLightVisible = false;
            WhatisThisLightBox.style.display = 'none';
            ActivateBG();
        }
    }


function isEmailAddr(EMailAddr)
{
   var EmailAddressRX = /^(.+)@(.+)\.(.+)$/;  // Check for pattern string.string

   var matches = EMailAddr.match(EmailAddressRX);
   if (matches == null) // IT'S BAD TO THE BONE.
      return false;
   // MORE CHECKING MAY BE REQUIRED -
   return true;
}

function isScreenNameValid(n) {
    //var ForbiddenRX = /[=;/#?:\[\]\{\}]/;
    //var matches = n.match(/[~=;/#?:\{\}\[\]]/);
    //if (matches == null)
    //    return true;
    var ForbiddenRX = "/<>";
    var i = 0;
    for (i = 0; i < ForbiddenRX.length; i++) {
        if (n.indexOf(ForbiddenRX.charAt(i)) > 0) {
            return false;
        }
    }
    return true;
}

function HideErrorLightBox()
{
    var divErrorMessage = document.getElementById('divErrorMessage');
    divErrorMessage.style.display = 'none';
    ActivateBG();
}
function ActivateBG()
{
    var GrayBG = document.getElementById('divDisableMasterPage');
    if(is.firefox)
    {
        var FireFoxDisableLayer = document.getElementById('divDisableFireFox');
        if(FireFoxDisableLayer != null)
        {
            GrayBG = FireFoxDisableLayer;
        }
    }
    if(GrayBG != null)
    {
        GrayBG.style.zIndex = 0;
        GrayBG.style.display = 'none';
        BGDisabled = false;
        if(is.ie6)
        {
            var formtag  = document.getElementById("aspnetForm");
            var Controls = formtag.getElementsByTagName('Select');
            for(var iControlCount = 0; iControlCount < Controls.length; iControlCount++)
            {
                Controls[iControlCount].style.display = '';
            }
        }
    }
    var UploadImageButton = document.getElementById('UploadImageButtonHolder');
    if(UploadImageButton != null)
    {
        UploadImageButton.style.display = '';
    }
}

var ShowCollaboratorError;
var ShowStationError;
if(ShowCollaboratorError != null)
{
    if(ShowCollaboratorError)
    {
        ShowCollaboratorLightBox();
    }
}
var ShowStationError;
if(ShowStationError != null)
{
    if(ShowStationError)
    {
        ShowStationErrorPO();
    }
}
var StationGenreHolder;
var StationPresetGenreHolder;
var LargeStationGenreHolder;
var ListenerGenreHolder;
var genreCloudMaxHeight = 60;
var browser = navigator.appName;
if(is.Mac || is.safari)
{
    genreCloudMaxHeight = 55;
}
if(StationGenreHolder != null && StationGenreHolder != "")
{
    var GenreCloudContent = document.getElementById("GenreTest");
    var StartHeight = GenreCloudContent.offsetHeight;
    GenreCloudContent.style.width = '74px';
    var temp = "";
    szaStationGenreHolder = StationGenreHolder.split(',');
    
    for(var iGenreCloud = 0; iGenreCloud < szaStationGenreHolder.length; iGenreCloud++)
    {
        if(szaStationGenreHolder[iGenreCloud] != "")
        {
            var divGenreCloud = document.getElementById(szaStationGenreHolder[iGenreCloud]);
            var CurrentGenre = eval(szaStationGenreHolder[iGenreCloud]);
            var NewGenreList = "";
            GenreCloudContent.innerHTML = "";
                
            for(var iGenreCount = 0; iGenreCount < CurrentGenre.length; iGenreCount++)
            {             
                szaGenreInfo = CurrentGenre[iGenreCount].split('~');
                    
                if(szaGenreInfo[1] == "Mix")
                {
                    NewGenreList = '<div class="genreBarMix">Mix</div>';
                }
                else
                { 

                    var szCurrentGenre = "<a href='search.aspx?gid=" + szaGenreInfo[0] + "' title='" + szaGenreInfo[1].replace("&apos;","'").replace("/"," / ") + "' class='genreBar" + Math.floor(Number(szaGenreInfo[2])/12) + "'><span>" + szaGenreInfo[1].replace("&apos;","'").replace("/"," / ") + "</span></a> ";
                    GenreCloudContent.innerHTML += szCurrentGenre;
                    StartHeight = GenreCloudContent.offsetHeight;

                    if(StartHeight < genreCloudMaxHeight)
                    {
                        NewGenreList += szCurrentGenre;
                    }
                }
            }
            divGenreCloud.innerHTML = NewGenreList;
        }
    }
    GenreCloudContent.innerHTML = "";
}


if(StationPresetGenreHolder != null && StationPresetGenreHolder != "")
{
    var GenreCloudContent = document.getElementById("GenreTest");
    var StartHeight = GenreCloudContent.offsetHeight;
    GenreCloudContent.style.width = '74px';
    var temp = "";
    szaStationGenreHolder = StationPresetGenreHolder.split(',');
    for(var iGenreCloud = 0; iGenreCloud < szaStationGenreHolder.length; iGenreCloud++)
    {
        if(szaStationGenreHolder[iGenreCloud] != "")
        {
            var divGenreCloud = document.getElementById(szaStationGenreHolder[iGenreCloud]);
            if(divGenreCloud != null)
            {
                var CurrentGenre = eval(szaStationGenreHolder[iGenreCloud]);
                var NewGenreList = "";
                GenreCloudContent.innerHTML = "";
                    
                for(var iGenreCount = 0; iGenreCount < CurrentGenre.length; iGenreCount++)
                {
                    szaGenreInfo = CurrentGenre[iGenreCount].split('~');
                    var szCurrentGenre = "<a href='search.aspx?gid=" + szaGenreInfo[0] + "' title='" + szaGenreInfo[1].replace("&apos;","'").replace("/"," / ") + "' class='genreBar" + Math.floor(Number(szaGenreInfo[2])/12) + "'><span>";
                    var szCurrentGenreName = szaGenreInfo[1].replace("/"," / ")
                    while(szCurrentGenreName.indexOf("&apos;") > -1)
                    {
                        szCurrentGenreName = szCurrentGenreName.replace("&apos;","'");
                    }
                    szCurrentGenre += szCurrentGenreName + "</span></a> ";
                    GenreCloudContent.innerHTML += szCurrentGenre;
                    StartHeight = GenreCloudContent.offsetHeight;

                    if(StartHeight < genreCloudMaxHeight)
                    {
                        //alert(StartHeight);
                        NewGenreList += szCurrentGenre;
                    }
                }
                divGenreCloud.innerHTML = NewGenreList;
            }
        }
    }
    GenreCloudContent.innerHTML = "";
}




if(LargeStationGenreHolder != null && LargeStationGenreHolder != "")
{
    var temp = "";
    var LargeGenreCloudMaxHeight = 84;
    var updated = false;
    
    var GenreCloudContent = document.getElementById("LargeGenreTest");
    var StartHeight = GenreCloudContent.offsetHeight;
    GenreCloudContent.style.width = '118px';
    var NewGenreList = "";
    
    for(var iGenreCount = 0; iGenreCount < LargeStationGenreList.length; iGenreCount++)
    {
        
        szaGenreInfo = LargeStationGenreList[iGenreCount].split('~');
        var szCurrentGenre = "<a href='search.aspx?gid=" + szaGenreInfo[0] + "' title='" + szaGenreInfo[1].replace("&apos;","'").replace("/"," / ") + "' class='LargeGenreCloud" + Math.floor(Number(szaGenreInfo[2])/12) + "'><span>";
        var szCurrentGenreName = szaGenreInfo[1].replace("/"," / ")
        while(szCurrentGenreName.indexOf("&apos;") > -1)
        {
            szCurrentGenreName = szCurrentGenreName.replace("&apos;","'");
        }
        szCurrentGenre += szCurrentGenreName + "</span></a> ";
        GenreCloudContent.innerHTML += szCurrentGenre;
        StartHeight = GenreCloudContent.offsetHeight;

        if(StartHeight < LargeGenreCloudMaxHeight)
        {
            //alert(StartHeight);
            NewGenreList += szCurrentGenre;
        }
    }
    LargeStationGenreHolder.innerHTML = NewGenreList;
    GenreCloudContent.innerHTML = "";
    
}

if(ListenerGenreHolder != null && ListenerGenreHolder != "")
{
    var temp = "";
    var LargeGenreCloudMaxHeight = 143;
    var updated = false;
    
    var GenreCloudContent = document.getElementById("GenreTest");
    var StartHeight = GenreCloudContent.offsetHeight;
    GenreCloudContent.className = 'ListenerGenreCloudContent';
    var NewGenreList = "";
    if(ListenerGenreList.length == 0)
    {
        ListenerGenreHolder.className = 'EmptyListenerCloud';
    }
    else
    {
        ListenerGenreHolder.className = 'listenerCloud';
        var ListenerGenreCloudContent = document.getElementById("ListenerGenreCloudContent");
        
        var szCurrentGenreName
        var genreIndexId = 17;
        for(var iGenreCount = 0; iGenreCount < ListenerGenreList.length; iGenreCount++)
        {
            
            szaGenreInfo = ListenerGenreList[iGenreCount].split('~');
            var szCurrentGenre = "<a href='search.aspx?gid=" + szaGenreInfo[0] + "' title='" + szaGenreInfo[1].replace("&apos;","'").replace("/"," / ") + "' class='StationCalloutGenreCloud" + genreIndexId + "'><span>";
                        if(is.ie)
                        {
                            szCurrentGenreName = szaGenreInfo[1].replace("/","<span class=\"genreslashie\"> / </span>");
                        }
                        else
                        {
                            szCurrentGenreName = szaGenreInfo[1].replace("/","<span class=\"genreslash\">/ </span>");
                        }
                        while(szCurrentGenreName.indexOf("&apos;") > -1)
                        {
                            szCurrentGenreName = szCurrentGenreName.replace("&apos;","'");
                        }
                        szCurrentGenre += szCurrentGenreName + "</span></a> ";
                        GenreCloudContent.innerHTML += szCurrentGenre;
            StartHeight = GenreCloudContent.offsetHeight;

            if(StartHeight < LargeGenreCloudMaxHeight)
            {
                //alert(StartHeight + " <> " + LargeGenreCloudMaxHeight);
                NewGenreList += szCurrentGenre;
            }
            genreIndexId--;
        }
        ListenerGenreCloudContent.innerHTML = NewGenreList;
        GenreCloudContent.innerHTML = "";
    }
}

    if(TransferOwnershipFormVisible)
    {
        ShowTransferOwnership();
    }
   if(is.ie6 || is.ie55)
   {
        var LeftPointerDiv = document.getElementById('LeftPointer');
        if(LeftPointerDiv != null)
        {
            var PopupTopMiddleDiv = document.getElementById('PopupTopMiddleDiv');
            var PopupUserLeftDiv = document.getElementById('PopupUserLeft');
            var PopupUserRightDiv = document.getElementById('PopupUserRight');
            var PopupBottomMiddleDiv = document.getElementById('PopupBottomMiddle');
            
            LeftPointerDiv.innerHTML = '';
            PopupTopMiddleDiv.innerHTML = '';
            PopupUserLeftDiv.innerHTML = '';
            PopupUserRightDiv.innerHTML = '';
            PopupBottomMiddleDiv.innerHTML = '';
            
            LeftPointerDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://assets.play.it/images/pop_fanL_pointer.png', sizing='scale'); z-index:3";
            PopupTopMiddleDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://assets.play.it/images/pop_warn_top.png', sizing='scale'); z-index:3";
            PopupUserLeftDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://assets.play.it/images/pop_fans_left.png', sizing='scale'); z-index:3";
            PopupUserRightDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://assets.play.it/images/pop_fans_right.png', sizing='scale'); z-index:3";
            PopupBottomMiddleDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://assets.play.it/images/pop_warn_bottom.png', sizing='scale'); z-index:3";
        }
   }
   
   
function sendRequest(url,callback,postData) {
	var req = createXMLHTTPObject();
	if (!req) return;
	var method = (postData) ? "POST" : "GET";
	req.open(method,url,true);
	req.setRequestHeader('User-Agent','XMLHTTP/1.0');
	if (postData)
		req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	req.onreadystatechange = function () {
		if (req.readyState != 4) return;
		if (req.status != 200 && req.status != 304) {
//			alert('HTTP error ' + req.status);
			return;
		}
		callback(req);
	}
	if (req.readyState == 4) return;
	req.send(postData);
}

var XMLHttpFactories = [
	function () {return new XMLHttpRequest()},
	function () {return new ActiveXObject("Msxml2.XMLHTTP")},
	function () {return new ActiveXObject("Msxml3.XMLHTTP")},
	function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];
function createXMLHTTPObject() {
	var xmlhttp = false;
	for (var i=0;i<XMLHttpFactories.length;i++) {
		try {
			xmlhttp = XMLHttpFactories[i]();
		}
		catch (e) {
			continue;
		}
		break;
	}
	return xmlhttp;
}
var myArrays = [];
function FixStationGenres()
{
    
    if(testFixStationGenres())
    {
        /*var genreSimilarCloudMaxHeight = 60;
        var browser = navigator.appName;
        if(is.Mac || browser=='Netscape')
        {
            genreSimilarCloudMaxHeight = 57;
        }*/
        var GenreCloudContent = document.getElementById("GenreTest");
        var StartHeight = GenreCloudContent.offsetHeight;
        GenreCloudContent.style.width = '74px';
        var temp = "";
        szaStationGenreHolder = StationGenreHolder.split(',');
        
        for(var iArray = 0; iArray < myArrays.length; iArray++)
        {
            if(myArrays[iArray].length > 0)
            {
                eval(myArrays[iArray]);
            }
        }
        for(var iGenreCloud = 0; iGenreCloud < szaStationGenreHolder.length; iGenreCloud++)
        {
            if(szaStationGenreHolder[iGenreCloud] != "")
            {
                var divGenreCloud = document.getElementById(szaStationGenreHolder[iGenreCloud]);
                var CurrentGenre = eval("GenreArray"+[iGenreCloud]);
                var NewGenreList = "";
                GenreCloudContent.innerHTML = "";
                    
                for(var iGenreCount = 0; iGenreCount < CurrentGenre.length; iGenreCount++)
                {             
                    szaGenreInfo = CurrentGenre[iGenreCount].split('~');
                        
                    if(szaGenreInfo[1] == "Mix")
                    {
                        NewGenreList = '<div class="genreBarMix">Mix</div>';
                    }
                    else if(szaGenreInfo[1] == "DraftMode")
                    {
                        NewGenreList = '<div class="genreBarDraftMode">This station is in Draft Mode.</div>';
                    }
                    else
                    { 

                        var szCurrentGenre = "<a href='search.aspx?gid=" + szaGenreInfo[0] + "' title='" + szaGenreInfo[1].replace("&apos;","'").replace("/"," / ") + "' class='genreBar" + Math.floor(Number(szaGenreInfo[2])/12) + "'><span>" + szaGenreInfo[1].replace("&apos;","'").replace("/"," / ") + "</span></a> ";
                        GenreCloudContent.innerHTML += szCurrentGenre;
                        StartHeight = GenreCloudContent.offsetHeight;

                        if(StartHeight < genreCloudMaxHeight)
                        {
                            NewGenreList += szCurrentGenre;
                        }
                        else 
                        {
                            break;  //stop iterating thru genres once the GenreCloud reaches max. height
                        }
                    }
                }
                divGenreCloud.innerHTML = NewGenreList;
            }
        }
        GenreCloudContent.innerHTML = "";
    }
}

function testFixStationGenres()
{
    var StationGenreScriptInfoHolder = document.getElementById('lblStationGenreArrays');
    if(StationGenreScriptInfoHolder != null)
    {
        var StationGenreScriptInfo = StationGenreScriptInfoHolder.innerHTML;
        if(StationGenreScriptInfo.indexOf("StationGenreHolder") > -1)
        {
            var start = StationGenreScriptInfo.indexOf("'", StationGenreScriptInfo.indexOf("StationGenreHolder")) + 1;
            var end =StationGenreScriptInfo.indexOf("'",start);
            StationGenreHolder = StationGenreScriptInfo.substring(start,end);
            start = StationGenreScriptInfo.indexOf("<!-- Start -->") + 14;
            end = StationGenreScriptInfo.indexOf("<!-- End -->");
            StationGenreScriptInfo = StationGenreScriptInfo.substring(start,end);
            myArrays = StationGenreScriptInfo.split('|');
            return true;
        }
    }
    return false;
}

var SimilarStationTimer;
var CommentsTimer;
var FansTimer;

UpdateStationTitle();
function DisplaySimilarStationLoadingMessage()
{
    var Loading = document.getElementById('similarStationLoading');
    Loading.style.display = '';	
}
function DisplayCommentLoadingMessage()
{
    var Loading = document.getElementById('Loading');
    Loading.style.display = '';	
}
function DisplayFansLoadingMessage()
{
    var Loading = document.getElementById('fanLoading');
    Loading.style.display = '';	
}

function PopulateSimilarStations(req) {
	var writeroot = document.getElementById("SimilarStations");
	writeroot.innerHTML = req.responseText;
    FixStationGenres();
    clearTimeout(SimilarStationTimer);
    var Loading = document.getElementById('similarStationLoading');
    Loading.style.display = 'none';	
}

function PopulateComments(req) {
	var StationComments = document.getElementById("StationComments");
	StationComments.innerHTML = req.responseText;
    clearTimeout(CommentsTimer);
    var Loading = document.getElementById('Loading');
    Loading.style.display = 'none';	
	hidePostComment();
	
}
function UpdatePresetStatus(req)
{
    var AddRemovePreset = document.getElementById('AddRemovePreset');
    if(AddRemovePreset != null)
    {
    AddRemovePreset.title = req.responseText;
	AddRemovePreset.innerHTML = req.responseText;
	}
}
function PopulateFans(req)
{
	var StationFans = document.getElementById("StationFans");
	StationFans.innerHTML = req.responseText;
	clearTimeout(FansTimer);
    var Loading = document.getElementById('fanLoading');
    Loading.style.display = 'none';	
    FixStationFanNames("FanLableNames");
}

function FixStationFanNames(List, LinkWidth)
{
	var FanNameLables = document.getElementById(List);
	var FanLableArray = FanNameLables.innerHTML.split('|');
	if(LinkWidth == null) LinkWidth = 70; //default width
	for(var iLableCount = 0; iLableCount < FanLableArray.length; iLableCount++)
	{
	    var FanLable = document.getElementById(FanLableArray[iLableCount]);
	    if(FanLable != null)
	        TruncateText(FanLable,LinkWidth);
	}
}

function pageSimilarStation(s,p)
{
    SimilarStationTimer=setTimeout("DisplaySimilarStationLoadingMessage()",1500);  
	
    var date_now = new Date();
    sendRequest("/SimilarStations.aspx?s="+s+"&p="+p+"&ck="+escape(date_now.toTimeString()),PopulateSimilarStations);
}




function pageComments(s,p)
{
    CommentsTimer=setTimeout("DisplayCommentLoadingMessage()",1500);  

    var date_now = new Date();
    sendRequest("/Comments.aspx?s="+s+"&p="+p+"&oid="+oid+"&ck="+escape(date_now.toTimeString()),PopulateComments);
}
function pageFans(s,p)
{
    FansTimer=setTimeout("DisplayFansLoadingMessage()",1500);
	
    var date_now = new Date();
    sendRequest("/ViewFans.aspx?s="+s+"&p="+p+"&d="+ isActive +"&ck="+escape(date_now.toTimeString()),PopulateFans);
}
var SortOrder = "";
function pageStationFans(s,p)
{
    FansTimer=setTimeout("DisplayFansLoadingMessage()",1500);
	
    var date_now = new Date();
    sendRequest("/StationFansContent.aspx?s="+s+"&p="+p+(SortOrder!=""?"&so="+SortOrder:"")+"&ck="+escape(date_now.toTimeString()),PopulateFans);
}
if(CurrentPage == "/stationfans.aspx")
{
    SortOrder = document.getElementById('ddDisplayType').value;
    pageStationFans(CurrentStationID,1);
}
if(CurrentPage.indexOf("/stations/") > -1 || CurrentPage == "/stationinfo.aspx")
{
    CheckPreset(CurrentStationID);
    pageComments(CurrentStationID,1);
    pageSimilarStation(CurrentStationID,1);
    pageFans(CurrentStationID,1);
    FixStationFanNames("DJLink", 100);
    FixStationFanNames("CollLinks", 53);
}
if(CurrentPage.indexOf("/listeners/") > -1 || CurrentPage == "/listener.aspx")
{
    GetBroadCastStations(1);
    GetListenerHistory(1);
    GetListenerFanOf(1);
    if(CurrentPage.indexOf("/listeners/"+playitScreenName) > -1 || window.location.search.toLowerCase() == "?name="+playitScreenName.toLowerCase())
    {
        var myProfileLink = document.getElementById('myProfileLink')
        //alert(myProfileLink)
        if(myProfileLink != null)
        {
            myProfileLink.className = "topNavBar";
            myProfileLink.innerHTML = "Profile";
        }
    }
}
if(CurrentPage == "/mystations.aspx")
{
    GetMyStations(1);
}

if(CurrentPage == "/stationfans.aspx")
{
    FixStationFanNames("FanLableNames");
}
function PopulatePromos(req) {
	var responseobj = req.responseText;
	var PromoXml;
	
    if(responseobj == "")
    {
	    responseobj = "<Promos><PromoLeft><link>javascript:PlayStation(225)</link><imgsrc>http://assets.play.it/userimages/dc/db/df/d2/d5/db/d6/1c293d04-1c3b-426c-b706-e3564cbf25b6.jpg</imgsrc><ToolTip>This is a place holder, There is still a problem with the CMS Service. Searched for ads related to genre id '"+ gid +"'</ToolTip></PromoLeft><PromoRight><link>javascript:PlayStation(2491)</link><imgsrc>http://assets.play.it/userimages/d9/d6/db/de/d3/d9/d6/e8517b97-8f91-49f3-adf2-ec3b696be396.jpg</imgsrc><ToolTip>This is a place holder, There is still a problem with the CMS Service. Searched for ads related to genre id '"+ gid +"'</ToolTip></PromoRight></Promos>";
	}
	
    if (window.ActiveXObject)
    {
        PromoXml=new ActiveXObject("Microsoft.XMLDOM");
        PromoXml.async="false";
        PromoXml.loadXML(responseobj);
    }
    else if (document.implementation.createDocument)
    {
        parser=new DOMParser();
        PromoXml=parser.parseFromString(responseobj,"text/xml");
    }
    else
    {
        //alert('Your browser cannot handle this script');
    }

	if(PromoXml.documentElement != null)
	{
	    var childPromoXml = PromoXml.documentElement.childNodes
    	
	    var altText = "";
        for (var i=0;i<childPromoXml.length;i++)
        { 
            if (childPromoXml[i].nodeType==1)
            { 
            PromoType = childPromoXml[i].nodeName;
           
                    switch(PromoType)
                    {
                        case "PromoTop":
                            var PromoTopLink = document.getElementById("PromoTopLink");
                            var imgPromoTop = document.getElementById("imgPromoTop");
                            if(PromoTopLink != null)
                            {
                                PromoTopLink.href = childPromoXml[i].getElementsByTagName("link")[0].firstChild.nodeValue;
                                imgPromoTop.src = childPromoXml[i].getElementsByTagName("imgsrc")[0].firstChild.nodeValue;
                                try
                                {
                                    altText = childPromoXml[i].getElementsByTagName("ToolTip")[0].firstChild.nodeValue
                                } 
                                catch(e)
                                {
                                    altText = "";
                                }
                                if(altText != "")
                                    imgPromoTop.alt = altText;
                            }
                            break;
                        case "PromoLeft":
                            var PromoLeftLink = document.getElementById("PromoLeftLink");
                            var imgPromoLeft = document.getElementById("imgPromoLeft");
                            PromoLeftLink.href = childPromoXml[i].getElementsByTagName("link")[0].firstChild.nodeValue;
                            imgPromoLeft.src = childPromoXml[i].getElementsByTagName("imgsrc")[0].firstChild.nodeValue;
                            try
                            {
                                altText = childPromoXml[i].getElementsByTagName("ToolTip")[0].firstChild.nodeValue
                            } 
                            catch(e)
                            {
                                altText = "";
                            }
                            if(altText != "")
                                imgPromoLeft.alt = altText;                        
                            break;
                        case "PromoRight":
                            var PromoRightLink = document.getElementById("PromoRightLink");
                            var imgPromoRight = document.getElementById("imgPromoRight");
                            PromoRightLink.href = childPromoXml[i].getElementsByTagName("link")[0].firstChild.nodeValue;
                            imgPromoRight.src = childPromoXml[i].getElementsByTagName("imgsrc")[0].firstChild.nodeValue;
                            try
                            {
                                altText = childPromoXml[i].getElementsByTagName("ToolTip")[0].firstChild.nodeValue
                            } 
                            catch(e)
                            {
                                altText = "";
                            }
                            if(altText != "")
                                imgPromoRight.alt = altText;                        
                            break;
                    }
	        } 
	    }
	}
}
function GetPromos(gid)
{
    var date_now = new Date();
    sendRequest("/getPromos.aspx?gid="+gid+"&ck="+escape(date_now.toTimeString()),PopulatePromos);
}
if(hasPromos)
{
    GetPromos(gid);
}
if(doStationSearch)
{
    SearchStations(p,gid,gn,st,s);
    if(!hasPromos)
    {
        if(gid == "")
        {
            gid = "-1";
        }
        GetPromos(gid);
    }
}
var searchloadingTimer;
function SearchStations(p,gid,gn,st,s)
{
    searchloadingTimer=setTimeout("DisplaySearchLoadingMessage()",1500);  

    var date_now = new Date();
    var searchURL = "/SearchResults.aspx?p="+(p != '' ? p:"1")+(gid!=null ? "&gid="+gid:"")+(gn != null ? "&gn="+gn:"")+(st != null ? "&t="+st:"")+(s != null ? "&s="+s:"")+"&ck="+escape(date_now.toTimeString());
    if(st == undefined)
    {	
        var SearchTerm = document.getElementById('txbSearchFor');	
        SearchTerm.value = "";
        st = "sn";
        for(var iIndex = 0; iIndex < ddSearchType.options.length; iIndex++)
        {
	        if(ddSearchType.options[iIndex].value == st)
	        {
		        ddSearchType.options[iIndex].selected = true; 
		    }
        }
    }
    else
    {
        HighlightGenre();
        RemoveBreadCrumb();
    }
    sendRequest(searchURL,PopulateSearchResults);
}
function DisplaySearchLoadingMessage()
{
    var Loading = document.getElementById('Loading');
    Loading.style.display = '';
}
function PopulateSearchResults(req)
{
    var SearchResultsHolder = document.getElementById('SearchResults');
	SearchResultsHolder.innerHTML = req.responseText;
    FixStationGenres();
    clearTimeout(searchloadingTimer);
    var Loading = document.getElementById('Loading');
    Loading.style.display = 'none';
}
var presetLoadingTimer;
function pagePreSets(p,r)
{
    presetLoadingTimer=setTimeout("DisplayPresetLoadingMessage()",1500);  

    var date_now = new Date();
    var PresetURL = "/myhomepresets.aspx?p="+(p == null ? "0" : p != '' ? p : "0")+(r == null ? "" : "&r=" + r)+"&ck="+escape(date_now.toTimeString());
    sendRequest(PresetURL,PopulatePresets);
}
function DisplayPresetLoadingMessage()
{
    var Loading = document.getElementById('PresetLoading');
    Loading.style.display = '';  
}
var CurrentListenerID
function PopulatePresets(req)
{
    var PresetsHolder = document.getElementById('PresetHolderDiv');
	PresetsHolder.innerHTML = req.responseText;
	var lblStationGenreArrays = document.getElementById('lblStationGenreArrays');
	if(lblStationGenreArrays.innerHTML.substring(0,15) == "CheckPresetsNow")
	{
        var date_now = new Date();
	    var imgLink = 'http://playerusersvc.'+ window.location.host +'/PlayerSiteData/PlayItSiteData2.asmx/GetPresetArray?UserID=' + CurrentListenerID + '&distribution=PLAYIT&firstPreset=0&numPresets=100&getFromDB=true&ck=' + escape(date_now.toTimeString());
	    lblStationGenreArrays.innerHTML = '<img src="' + imgLink + '" height="1" width="1">';
        var CheckPresetTimer=setTimeout("pagePreSets(0,1)",1000); 
	}
	else
	{
        FixStationGenres();
    }
    clearTimeout(presetLoadingTimer);
    var Loading = document.getElementById('PresetLoading');
    Loading.style.display = 'none';
}
function RemovePreset(ID,sender)
{
    var date_now = new Date();
    var PresetHolder = document.getElementById(sender.id.replace('ibt',''));
    PresetHolder.innerHTML = '<img src="http://playerusersvc.'+ window.location.host +'/PlayerSiteData/PlayItSiteData2.asmx/UnSetPreset?UserID=' + CurrentListenerID + '&distribution=PLAYIT&StationID=' + ID + '&ck="' + escape(date_now.toTimeString()) + '" height="1" width="1">';
    var CheckPresetTimer=setTimeout("pagePreSets()",500);
}
var SelectedNavGenre
function HighlightGenre(objName,ActivatedSection)
{
    if(SelectedNavGenre != null && SelectedNavGenre != "")
    {
        if(SelectedNavGenre.id.indexOf("TopLevelGenreLink") > -1)
        {
        }
        else
        {
            SelectedNavGenre.className='browseGenreBar';
        }
    }
    else
    {
        if(SelectedNavGenreHolder != "")
        {
            SelectedNavGenre = document.getElementById(SelectedNavGenreHolder);
            if(SelectedNavGenre != null)
               SelectedNavGenre.className='browseGenreBar';
        }
    }
    if(objName != undefined)
    {
        SelectedNavGenre = objName;
    }
    else
    {
        SelectedNavGenre = "";
    }
    if(SelectedNavGenre != "" && SelectedNavGenre.id.indexOf("TopLevelGenreLink") > -1)
    {
            ActiveSectionButton = SelectedNavGenre.id.replace("TopLevelGenreLink","GenreImage");
    }
    else
    {
        SelectedNavGenre.className='SelectedGenre';
    }
    
    var SelectedTopLevelGenreImage
    if(ActivatedSection != null)
    {
        ActiveSectionButton = ActivatedSection;
    }
    else
    {
        ActiveSectionButton = "";
    }
    if(SelectTopLevelGenreButtonID != "")
    {
        if(SelectTopLevelGenreButtonID != ActiveSectionButton)
        {
            SelectedTopLevelGenreImage = document.getElementById(SelectTopLevelGenreButtonID);
            SelectedTopLevelGenreImage.src = SelectedTopLevelGenreImage.src.replace("browseSelected","browse");
        }
    }
    if(SelectTopLevelGenreButtonID != ActiveSectionButton)
    {
        SelectTopLevelGenreButtonID = ActiveSectionButton;
        SelectedTopLevelGenreImage = document.getElementById(ActiveSectionButton);
        if(SelectedTopLevelGenreImage != null)
        {
            SelectedTopLevelGenreImage.src = SelectedTopLevelGenreImage.src.replace("browse","browseSelected");
        }
    }
}
function SetBreadCrumb(SelectedSearchTerm,TopLevelGenreID,TopLevelGenreName,ParentGenreID,ParentGenreName)
{
    BreadCrumbDiv = document.getElementById(BreadCrumbDivID);
    BreadCrumbCurrentPageDiv = document.getElementById(BreadCrumbCurrentPageDivID);
    BreadCrumbDiv.innerHTML = "<a href='javascript:SearchStations(1);' onclick='GetPromos(-1);HighlightGenre(this);RemoveBreadCrumb();'>Play Stations</a> > ";

    if(TopLevelGenreID != null && TopLevelGenreID != "")
    {
        BreadCrumbDiv.innerHTML += "<a href='javascript:SearchStations(1," + TopLevelGenreID + ");' onclick='GetPromos(" + TopLevelGenreID + ");HighlightGenre(this);SetBreadCrumb(\""+ TopLevelGenreName +"\");'>" + TopLevelGenreName + "</a> > ";
    }
    if(ParentGenreID != null && ParentGenreID != "")
    {
        BreadCrumbDiv.innerHTML += "<a href='javascript:SearchStations(1," + ParentGenreID + ");' onclick='GetPromos(" + ParentGenreID + ");HighlightGenre(this);SetBreadCrumb(\"" + ParentGenreName + "\",\""+ TopLevelGenreID +"\",\""+ TopLevelGenreName +"\");'>" + ParentGenreName + "</a> > ";
    }
    BreadCrumbCurrentPageDiv.innerHTML = SelectedSearchTerm;
}
function RemoveBreadCrumb()
{
    BreadCrumbDiv = document.getElementById(BreadCrumbDivID);
    BreadCrumbCurrentPageDiv = document.getElementById(BreadCrumbCurrentPageDivID);
    BreadCrumbDiv.innerHTML = "";
    BreadCrumbCurrentPageDiv.innerHTML = "Play Stations";
}
if(CurrentPage == "/search.aspx")
{
    if(window.location.search != '')
    {
        var queryString = window.location.search;
        if(queryString.indexOf("t")>-1)
        {
            var SearchTerm = unescape(s)
            while(SearchTerm.indexOf("&apos;") > -1)
            {
                SearchTerm = SearchTerm.replace("&apos;","'");
            }
            while(SearchTerm.indexOf("+") > -1)
            {
                SearchTerm = SearchTerm.replace("+"," ");
            }
            SearchTextBox.value = SearchTerm;
            if(st == "ls")
                st = "dj";
            for(var iIndex = 0; iIndex < ddSearchType.options.length; iIndex++)
            {
		        if(ddSearchType.options[iIndex].value == st)
		        {
			        ddSearchType.options[iIndex].selected = true; 
			    }
            }
            ActivateSearch();
        }
    }
}
if(CurrentPage == "/forgotpassword.aspx")
{
    CheckLoadEmailField();
}
if(CurrentPage == "/myhome.aspx")
{
    pagePreSets(0);
}
var hasFlash = false;
function ShowNoFlashMessage()
{
    var NoFlashMessage = document.getElementById('NoFlashMessage');
    var UploadImageButton = document.getElementById('UploadImageButton');
    if(UploadImageButton == null)
    {
        var UploadImageButton = document.getElementById('player');
        if(UploadImageButton != null)
        {
            hasFlash = UploadImageButton.innerHTML.indexOf('OBJECT') == 1
            if(!hasFlash)
            {
                hasFlash = UploadImageButton.innerHTML.indexOf('embed') > 0;
            }
        }
    }

    if(NoFlashMessage != null && !hasFlash)
    {
        if(!hasFlash)
        {
            hasFlash = NoFlashMessage.innerHTML.indexOf('OBJECT') == 1;
            if(!hasFlash)
                hasFlash = NoFlashMessage.innerHTML.indexOf('embed') == 1;
        }       
        NoFlashMessage.style.display = (hasFlash ? 'none':'');
        if(UploadImageButton != null)
            UploadImageButton.style.display = (hasFlash ? '':'none');
    }
}
ShowNoFlashMessage();
function xVoid()
{
}

function TruncateText(objName,oMaxWidth)
{
    var OrigVal = objName.innerHTML;
    var OrigLen = objName.innerHTML.length;
    while(objName.offsetWidth > oMaxWidth)
    {
        OrigLen--;
        objName.innerHTML = OrigVal.substring(0,OrigLen) + '...';
    }
    objName.title = OrigVal;
}
var WelcomeScreenNameLarge = document.getElementById('WelcomeScreenNameLarge');
var screenNameTest = document.getElementById('ctl00_lblLoggedInUserName');
var ctl00_lblPageTitle = document.getElementById('ctl00_lblPageTitle');
if(ctl00_lblPageTitle != null && CurrentPage != "/index.aspx" && CurrentPage != "/")
{
    TruncateText(ctl00_lblPageTitle,478);
}
if(WelcomeScreenNameLarge != null)
{
    screenNameTest.className = 'ScreenNameLargeTest';
    TruncateText(screenNameTest,350);
    WelcomeScreenNameLarge.innerHTML =  screenNameTest.innerHTML;
}
var BreadCrumbStationName = document.getElementById('BreadCrumbStationName');
if(BreadCrumbStationName != null)
{
    BreadCrumbStationName.className = 'BreadCrumb';
    TruncateText(BreadCrumbStationName,250);
}

if(CurrentPage == "/stationtarget.aspx")
{
    if(is.ie)
    {
        var target = document.getElementById('player')
        target.style.top = "-24px";
    }
}
function FixLinks()
{
    switch (CurrentPage)
    {
        case "/editprofile.aspx":
            var linkMyProfile = document.getElementById('ctl00_linkMyProfile')
            linkMyProfile.className = "topNavBar";
            linkMyProfile.innerHTML = "Settings &nbsp;| &nbsp;";
            break;
        case "/faq.aspx":
            var linkHelp = document.getElementById('linkHelp')
            linkHelp.className = "topNavBar";
            linkHelp.innerHTML = "Help";
            break;
        case "/login.aspx":
            var loginLink = document.getElementById('linkLogIn')
            if(loginLink != null)
            {
                linkLogIn.className = "topNavBar";
                linkLogIn.innerHTML = "Log In &nbsp;| &nbsp;";
            }
            break;
        case "/signup.aspx":
            var linkSignUp = document.getElementById('linkSignUp')
            if(linkSignUp != null)
            {
                linkSignUp.className = "topNavBar";
                linkSignUp.innerHTML = "Sign Up &nbsp;| &nbsp;";
            }
            break;
        case "/terms.aspx":
            var footerTermsLink = document.getElementById('footerTermsLink')
            footerTermsLink.className = "FooterInactiveLink";
            footerTermsLink.innerHTML = "Terms";
            break;
        case "/privacypolicy.aspx":
            var footerPrivacyLink = document.getElementById('footerPrivacyLink')
            footerPrivacyLink.className = "FooterInactiveLink";
            footerPrivacyLink.innerHTML = "Privacy Policy";
            break;
        case "/about.aspx":
            var footerAboutLink = document.getElementById('footerAboutLink')
            footerAboutLink.className = "FooterInactiveLink";
            footerAboutLink.innerHTML = "About";
            break;
        case "/widgetplayer.aspx":
            if(location.search.length > 0)
            {
                PrePopulatedStationInfo();
            }
            break;
    }
    if(CurrentPage.indexOf("/listeners/") > -1 || CurrentPage == "/listener.aspx")
    {
        if(CurrentPage.indexOf("/listeners/"+playitScreenName) > -1 || window.location.search.toLowerCase() == "?name="+playitScreenName.toLowerCase())
        {
            var myProfileLink = document.getElementById('myProfileLink')
            //alert(myProfileLink)
            if(myProfileLink != null)
            {
                myProfileLink.className = "topNavBar";
                myProfileLink.innerHTML = "Profile &nbsp;| &nbsp;";
            }
        }
    }
    var InviteAFriendLink = document.getElementById('InviteAFriendLink');
    if(InviteAFriendLink != null)
    {
        if(playitIsLoggedIn)
        {
            InviteAFriendLink.innerHTML = '<a class="ShortCutLinks" href="javascript:ShowInviteAFriend()" title="Invite a friend to join play.it">Invite a Friend</a>';
        }
        else
        {
            var currentPageURL = CurrentPage;
            while(currentPageURL.indexOf("/")>-1)
            {
                currentPageURL = currentPageURL.replace("/","%2f");
            }
            InviteAFriendLink.innerHTML = '<a class="ShortCutLinks" href="http://play.it/stations/login.aspx?page='+currentPageURL+'" title="Invite a friend to join play.it">Invite a Friend</a>';
        }
    }
}
function ShowInviteAFriend()
{
    DisableBG();

    var LightBoxHolder = document.getElementById('SendInviteToFriend');
    var txbEmailTo = document.getElementById('txbEmailTo');
    if(playitIsLoggedIn)
    {
	    txbInviteEmailFrom.value = playitEmail;
    }
    if(is.ie6)
    {
        LightBoxHolder.style.position = 'absolute';
    }
    else
    {
        LightBoxHolder.style.position = 'fixed';    
    }
    LightBoxHolder.style.display = '';
    LightBoxHolder.style.top = LightBoxHoldertop;
    LightBoxHolder.style.left = LightBoxHolderleft;
    LightBoxHolder.style.zIndex = 20009;
    txbInviteEmailTo.focus(); 
    SendIniteToFriendButtonActivate();
    SendInviteToFriendVisible = true;
}
function HideInviteAFriend()
{    
    var SendInviteToFriend = document.getElementById('SendInviteToFriend');
    if(SendInviteToFriend != null)
    {
        SendInviteToFriend.style.display = 'none';
        SendInviteToFriendVisible = false;
    
        if(ShowPostCommentVisible != null)
            ShowPostCommentVisible = false;
        if(ShowReplyToCommentVisible != null)
            ShowReplyToCommentVisible = false;
        ActivateBG();
    }
}
function ClearInviteFriend()
{
    try
    {
        txbInviteEmailTo.value = '';
        SendInviteToFriendMessage.value = DefaultSendToFriendMessage;
        if(playitIsLoggedIn)
        {
	        txbInviteEmailFrom.value = playitEmail;
        }
    }
    catch (e)
    {
        txbInviteEmailTo.value = '';
        txbInviteEmailFrom.value = '';
        SendInviteToFriendMessage.value = '';
    }
    HideInviteAFriend();
}
function InviteFriend()
{
    var date_now = new Date();
    sendRequest("/sendtofriend.aspx?c="+escape(SendInviteToFriendMessage.value)+"&f="+escape(txbInviteEmailFrom.value)+"&t="+escape(txbInviteEmailTo.value)+"&ck="+escape(date_now.toTimeString()),confirmFriendMessageSent);
}
function confirmFriendMessageSent(req)
{
	var confirmMessage = req.responseText;
    if(confirmMessage == "Success")
    {
        HideInviteAFriend();
        ClearInviteFriend();
    }
}
function SendIniteToFriendButtonActivate()
{
    if (CheckInviteSendToFriend())
    {
        if (ibtSendInvite.addEventListener) {
        ibtSendInvite.addEventListener ("mouseover",sendButtonOver,false);
        ibtSendInvite.addEventListener ("mouseout",sendButtonOut,false);
        } else if (ibtSendInvite.attachEvent) {
        ibtSendInvite.attachEvent ("onmouseover",sendButtonOver);
        ibtSendInvite.attachEvent ("onmouseout",sendButtonOut);
        } else {
        ibtSendInvite.onmouseover = sendButtonOver;
        ibtSendInvite.onmouseout = sendButtonOut;
        } 
        ibtSendInvite.disabled = false;
        ibtSendInvite.src = 'http://assets.play.it/images/button_send.gif';
        return;
    }
    ibtSendInvite.src = 'http://assets.play.it/images/button_send_inactive.gif';
    ibtSendInvite.disabled = true;
    ibtSendInvite.onmouseover = null;
    ibtSendInvite.onmouseout = null;
}
function CheckInviteSendToFriend()
{
    if (txbInviteEmailTo != null && txbInviteEmailTo.value.length > 0 && isEmailAddr(txbInviteEmailTo.value) && txbInviteEmailFrom.value.length > 10 && isEmailAddr(txbInviteEmailFrom.value))
    {
        return true;
    }
    return false;
}
function sendButtonOver()
{
        ibtSendInvite.src='http://assets.play.it/images/button_send_over.gif';
}
function sendButtonOut()
{
        ibtSendInvite.src='http://assets.play.it/images/button_send.gif';
}
//adding these functions because firefox 3 has changed the way it handles events and does not want to behave properly.
//firefox 3 blows - Paul M
var searchBoxActive = false;
function DisableFormSubmit() {
    searchBoxActive = true;
    switch (CurrentPage) {
        case "/stationproperties.aspx":
            EnableSaveButton();
            break;
        case "/widgetplayer.aspx":
            CheckEmailSendButton();
            break;
        case "/myhome.aspx":
            btSubmit.disabled = true;
            break;
    }
}
function EnableFormSubmit() {
        searchBoxActive = false;
    switch (CurrentPage) {
        case "/stationproperties.aspx":
        EnableSaveButton()
            break;
        case "/widgetplayer.aspx":
        CheckEmailSendButton();
            break;
    }
}
