var TagId	= 1;

function toggleId(IdName) {
    theSpan							= document.getElementById(IdName).style;
    theSpan.display					= (theSpan.display	== 'block') ? 'none' : 'block';
}

function hideId(IdName) {
    theSpan							= document.getElementById(IdName).style;
    theSpan.display					= 'none';
}
var reloads							 = 0;
function nowWatching() {

    ajaxReplace('/nowwatching.php');
    reloads							+= 1;
    if (reloads < 20) {
        setTimeout('nowWatching()', 10000) ;
    }
}

function addtag(TheValue, DivId) {
    if (TheValue != '') {
        ValueArray = TheValue.split(',');
        if (ValueArray.length == 0) {
            ValueArray[0]	=  TheValue;
        }
        var part_num=0;
        while (part_num < ValueArray.length) {
            NewText						= '<span id="Tag' + TagId + '"><input type="hidden" name="tags[]" value="' + ValueArray[part_num] + '">' + ValueArray[part_num] + ' [<a href="javascript:;" onclick="removemytag(\'' + TagId + '\')">x</a>]<br /></span>';
            if (document.getElementById) {
                currentTags 			= document.getElementById(DivId);
                currentTags.innerHTML 	= currentTags.innerHTML + NewText;
            }
            part_num 				+= 1;
        }
        TagId						+= 1;
    }
}

function removemytag(TheId) {
    TheTag					= 'Tag' + TheId;
    Current					= document.getElementById(TheTag);
    Current.innerHTML		='';
}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function ajaxAppend(action) {
    http.open('get', action);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function ajaxReplace(action) {
    http.open('get', action);
    http.onreadystatechange = replaceResponse;
    http.send(null);
}

function replaceResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            OriginalSpan 			= document.getElementById(update[0])
            OriginalSpan.innerHTML 	= update[1];
        }
    }
}

function ajaxShout(scriptUri, shoutMessage) {
  if(encodeURIComponent) {
    shoutMessage	=  encodeURIComponent(shoutMessage);
  } else if(escape) {
    shoutMessage	=  escape(shoutMessage);
  }
  scriptUri			+= '?ajax=1&Message=' + shoutMessage;
  ajaxReplace(scriptUri);
  return false;
}
function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            OriginalSpan 			= document.getElementById(update[0])
            OriginalSpan.innerHTML 	= OriginalSpan.innerHTML + update[1];
        }
    }
}

 function detectVersion()
 {
 version = parseInt(navigator.appVersion);
 return version;
 }

 function detectOS()
 {
 if(navigator.userAgent.indexOf('Win') == -1) {
 OS = 'Macintosh';
 } else {
 OS = 'Windows';
 }
 return OS;
 }

 function detectBrowser()
 {
 if(navigator.appName.indexOf('Netscape') == -1) {
 browser = 'IE';
 } else {
 browser = 'Netscape';
 }
 return browser;
 }

 function FullScreen(PageUrl){
 var adjWidth;
 var adjHeight;

 if((detectOS() == 'Macintosh') && (detectBrowser() == 'IE')) {
 adjWidth = 20;
 adjHeight = 35;
 winOptions = 'fullscreen=yes';
 } else if((detectOS() == 'Windows') && (detectBrowser() == 'Netscape')) {
 adjWidth = 30;
 adjHeight = 30;
 } else {
  adjWidth = 0;
  adjHeight = 35;
 }
 var winWidth = screen.availWidth - adjWidth;
 var winHeight = screen.availHeight - adjHeight;
 var winSize = 'width=' + winWidth + ',height=' + winHeight;
 var thewindow = window.open(PageUrl, 'fsPlayer', winSize);
 thewindow.moveTo(0,0);
 }

 function playFullSceen(PageUrl){
 reloads			= 22;
 if((detectOS() == 'Windows') && (detectBrowser() == 'IE')) {
 window.open(PageUrl,'fsPlayer','fullscreen=yes');
 } else {
 onload=FullScreen(PageUrl);
 }
 }


function resizeToFull() {
    window.moveTo(0,0);
    var adjWidth;
    var adjHeight;
    if((detectOS() == 'Macintosh') && (detectBrowser() == 'IE')) {
        adjWidth = 20;
        adjHeight = 35;
        winOptions = 'fullscreen=yes';
    } else if((detectOS() == 'Windows') && (detectBrowser() == 'Netscape')) {
        adjWidth = 30;
        adjHeight = 30;
    } else {
        adjWidth = 0;
        adjHeight = 35;
    }
    var winWidth = screen.availWidth - adjWidth;
    var winHeight = screen.availHeight - adjHeight;
    window.resizeTo(winWidth, winHeight);
}

