function highlightScrollItem(tag){ 

var divBox = document.getElementById(tag);
//alert(tag);
divBox.style.backgroundColor = "";
//divBox.style.backgroundColor = "#222222";
return;
}

function restoreScrollItem(tag){ 

var divBox = document.getElementById(tag);
divBox.style.backgroundColor = "";
return;
}

function highlightButton(butID){ 
var docButton = document.getElementById(butID);
docButton.src = "./images/left-menu-selected-button.gif";
//divBox.style.backgroundColor = "#222222";
return;
}

function restoreButton(butID){ 
//alert(""+button);
var docButton = document.getElementById(butID);
docButton.src = "./images/Left-menu-button-unselected.gif";
return;
}

function highlightButton2(butID){ 
var docButton = document.getElementById(butID);
docButton.src = "./images/right-menu-selected-area.gif";
//divBox.style.backgroundColor = "#222222";
return;
}

function restoreButton2(butID){ 
//alert(""+button);
var docButton = document.getElementById(butID);
docButton.src = "./images/right-menu-unselected-button.gif";
return;
}

function ajaxFunction(type, vid, offset, cid){

	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}

	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState==4 || ajaxRequest.readyState=="complete"){
          if (type == 'paginate')
			var ajaxDisplay = document.getElementById('ajaxDiv');
          if (type == 'channelGuide')
			var ajaxDisplay = document.getElementById('scrollingVideosText');
          if (type == 'userPage')
		    if (cid == 'confirmedFriends')
			  var ajaxDisplay = document.getElementById('confirmed');	
            else if (cid == 'storyBoard')
			  var ajaxDisplay = document.getElementById('userWallContent');		
            else if (cid == 'groupsJoined')
			  var ajaxDisplay = document.getElementById('groupsJoined');	
            else
			  var ajaxDisplay = document.getElementById('biography');			
			ajaxDisplay.style.display = "";		
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}

//	alert("hi");	

    if (type == 'paginate'){
  
	  var rowsPerPage = 4;
      var queryString = "?vid=" + vid + "&rowsPerPage=" + rowsPerPage + "&offset=" + offset + "&cid=" + cid ; 
	  ajaxRequest.open("GET", "commentsAjax.php" + queryString, true);
	  ajaxRequest.send(null);
    }	
	
    if (type == 'channelGuide'){
	  var rowsPerPage = 10;
//	  alert("Hi");
      var queryString = "?vid=" + vid + "&rowsPerPage=" + rowsPerPage + "&page=" + offset + "&cid=" + cid ; 
	  ajaxRequest.open("GET", "ajaxChannelGuide.php" + queryString, true);
	  ajaxRequest.send(null);	
	}
	
    if (type == 'userPage'){
	  var rowsPerPage = 10;
	  if (cid == 'confirmedFriends')
	    rowsPerPage = 25;
	  if ((cid == 'groupsJoined')||(cid == 'images'))
	    rowsPerPage = 5;		
      var queryString = "?pageUid=" + vid + "&rowsPerPage=" + rowsPerPage + "&page=" + offset + "&action=" + cid ; 
//	  alert(queryString);
      ajaxRequest.open("GET", root +"/ajaxFunctions.php" + queryString, true);
	  ajaxRequest.send(null);	
	}	
	
    if (type == 'addListItem'){
	  var rowsPerPage = 10;
	  var listCategory = document.getElementById('listCategory').value;
	  var listItem = document.getElementById('listItem').value;
      alert(listCategory+' '+listItem);
      var queryString = "?category=" + listCategory + "&listItem=" + listItem; 
//	  ajaxRequest.open("GET", "ajaxChannelGuide.php" + queryString, true);
//	  ajaxRequest.send(null);	
	}
	
}

function changeAdminChannel(cid){
  var link = "./video.php?cid=" + cid;
  window.location = link;
}

function changePageSection(pageListID){
  var link = "./adminPageCreator.php?pageListID=" + pageListID;
  window.location = link;
}

function changePageFileName(pageID){
  var link = "./adminPageEdit.php?pageID=" + pageID;
  window.location = link;
}

function changePageMp3Edit(mp3ID){
  var link = "./mp3Edit.php?mp3ID=" + mp3ID;
  window.location = link;
}

function changeGroupList(categoryID){
  var link = "./groupList.php?categoryID=" + categoryID;
  window.location = link;
}

function changeTourEdit(tourID){
  var link = "./tourEdit.php?tourID=" + tourID;
  window.location = link;
}

function changeTour(cityID){
  var link = "./index.php?cityID=" + cityID;
  window.location = link;
}

function Expand(divID)
{
	var oBox = document.getElementById(divID);
	if (oBox)
	{
		if (oBox.style.display == 'none')
		{
			oBox.style.display = 'block';
		}
		else
		{
			oBox.style.display = 'none';
		}
	}
}


function addToBlast(numBlast, firstBlast ) {
var blastTo = firstBlast;
var box;
var blastCount = 0;
var error = "";
for (var j = 0; j < numBlast; j++) {
box = eval("document.blastForm.blast" + j); 	
if (box.checked == true) 
{

  blastCount++;	
  if (blastCount <= 15)
    blastTo += box.value + ", ";
}
   }  
  if (blastCount > 15)
    alert("You can only blast at most 15 people. You have "+blastCount+" checked.");   
blast = eval("document.blastForm.blast");    
blast.innerHTML = blastTo;
}

function addToSendGift(numBlast, cost) {
var blastTo = "";
var box;
var i = 0;
var totalCost;
var estCost;
for (var j = 0; j < numBlast; j++) {
  box = eval("document.blastForm.blast" + j); 	  
  if (box.checked == true)
  {
	estCost = cost*(i+1);
	if (estCost < document.blastForm.totalPts.value)
	{
      blastTo += box.value + ", ";
      i++;
	}else{
	  alert("Sorry, you don't have enough points to send this gift to this user.")
      box.checked = "";
	}
  }  
}
blast = eval("document.blastForm.blast");    
blast.innerHTML = blastTo;
totalCost = eval("document.blastForm.totalCost");    
totalCost.value = cost*i;
}

function detailsTab(divID)
{
    var oBox = document.getElementById(divID);
    var oBoxTab = document.getElementById(divID+"Tab");	
	if (oBox)
	{
//        var biography = document.getElementById('biography');
//        var creditStar = document.getElementById('creditStar');	
        document.getElementById("biography").style.display = 'none';		
        document.getElementById("creditStar").style.display = 'none';
        document.getElementById("creditDirector").style.display = 'none';		
        document.getElementById("creditProducer").style.display = 'none';
        document.getElementById("biographyTab").style.backgroundColor = '#AA0000';		
        document.getElementById("creditStarTab").style.backgroundColor = '#AA0000';
        document.getElementById("creditDirectorTab").style.backgroundColor = '#AA0000';		
        document.getElementById("creditProducerTab").style.backgroundColor = '#AA0000';		
        oBox.style.display = 'block';
		oBoxTab.style.backgroundColor = '#000000';
	}
}

function friendsTab(divID)
{
    var oBox = document.getElementById(divID);
    var oBoxTab = document.getElementById(divID+"Tab");	
	if (oBox)
	{
//        var biography = document.getElementById('biography');
//        var creditStar = document.getElementById('creditStar');	
        document.getElementById("confirmed").style.display = 'none';		
        document.getElementById("pending").style.display = 'none';
        document.getElementById("confirmedTab").style.backgroundColor = '#AA0000';		
        document.getElementById("pendingTab").style.backgroundColor = '#AA0000';		
        oBox.style.display = 'block';
		oBoxTab.style.backgroundColor = '#000000';
	}
}

function showTip(divID)
{
	var oBox = document.getElementById(divID);
	var oBoxPtr = document.getElementById("ptr"+divID);	
	if (oBox)
	{
		if (oBox.style.display == 'none')
		{
			oBoxPtr.style.display = 'block';			
			oBox.style.display = 'block';
		}
	}
}
function hideTip(divID)
{
	var oBox = document.getElementById(divID);
	var oBoxPtr = document.getElementById("ptr"+divID);		
	if (oBox)
	{
			oBoxPtr.style.display = 'none';			
			oBox.style.display = 'none';
	}
}

function changeBG(image, wallpaper, colorScheme){
	

  if (wallpaper)	
  {
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);

	if (browser == "Microsoft Internet Explorer")
	{
      document.body.style.background = '#000000';	  
      document.body.style.backgroundImage = 'url(http://2.0television.com/uploads/wallpaper/'+wallpaper+')';	  
      document.body.style.backgroundRepeat = 'no-repeat';
      document.body.style.backgroundPosition = 'center';
      document.body.style.backgroundAttachment = 'fixed';	  

    }  else
	{
      document.getElementById("body2").style.backgroundImage = 'url(http://2.0television.com/uploads/wallpaper/'+wallpaper+')';
    if (image)	
      document.body.style.backgroundImage = 'url(http://2.0television.com/images/background/'+image+')';	
	}
  }else 	
    if (image)	
      document.body.style.backgroundImage = 'url(http://2.0television.com/images/background/'+image+')';
/*  if (theme == 'b')
  {
     var all     = document.getElementsByTagName('*');
     var id_only = [];
     var id_only2 = [];	 
     for(var i=0; i<all.length; ++i)
     {
          if(all[i].className == 'bold')
               id_only.push(all[i]);
          if(all[i].className == 'userDetails')
               id_only2.push(all[i]);
 
     }
     for(var j=0; j<id_only.length; ++j)
     {
          var e = id_only[j];
          e.style.color = "#F95";
     }
  }
     for(var j=0; j<id_only2.length; ++j)
     {
          var e = id_only2[j];
          e.style.color = "#CCC";
     }  */
}

function doBlink() {
  // Blink, Blink, Blink...
  var blink = document.all.tags("blink")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  // Make sure it is IE4
  if (document.all)
    setInterval("doBlink()",700)
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 

var blinkStatus = 1;
var currentHeadline = 3;
var mouseOverHeadline = false;
function stopBlink() {
  mouseOverHeadline	= true;
}
function startBlink() {
  mouseOverHeadline	= false;
}

function showHeadline() {
  alert("hi");
}
	
function doBlink2() {
  if (blinkStatus == 1)
  {
	if (mouseOverHeadline == false)
	{
    document.getElementById("headline"+currentHeadline).style.display = 'none';
	if (currentHeadline == 3)
	  currentHeadline = 1;
	else if (currentHeadline == 1)
	  currentHeadline = 2;
	else
	  currentHeadline = 3;	
    document.getElementById("headline"+currentHeadline).style.display = 'block';
    opacity("headline"+currentHeadline, 0, 95, 1500);	
    opacity("ptrcomment1000", 0, 95, 1500);	
    opacity("ptrcomment1001", 0, 95, 1500);
    opacity("ptrcomment1002", 0, 95, 1500);
    opacity("ptrcomment1003", 0, 95, 1500);	
			
//    document.getElementById("headline"+currentHeadline, 95, 0, 1500);	  
    blinkStatus = 2;	
	}		
  }  
  else if (blinkStatus == 2)
  {
	  
    blinkStatus = 3;	
  }
  else if (blinkStatus == 3)
  {
    if (mouseOverHeadline == false)
    {	  
      opacity("headline"+currentHeadline, 95, 0, 1500);		  
      opacity("ptrcomment1000", 95, 0, 1500);		
      opacity("ptrcomment1001", 95, 0, 1500);
      opacity("ptrcomment1002", 95, 0, 1500);
      opacity("ptrcomment1003", 95, 0, 1500);		  
      blinkStatus = 1;
	}
  }
   
	
}

function startBlink2() {
  setInterval("doBlink2()",5000);
}

window.onload = startBlink;

function resize(imgSrc){
var newImg = new Image();
newImg.src = imgSrc;
var height = newImg.height;
var width = newImg.width;
var newwidth;
if (width/height > 1.34)
{
  if (width > 520)
  {
    newwidth=520;
    newheight=Math.round((height/width)*520);
  } else
  {
    newwidth=width;
    newheight=height;  
  }	  
}else
{
  if (height > 390)
  {
  newheight=390;
  newwidth=Math.round((width/height)*390);
  } else
  {
    newwidth=width;
    newheight=height;  
  }	  
}

return [newwidth,newheight];
}

function viewBlastList() {
  document.getElementById('blastGroup').style.display = "";	
  document.getElementById('blastTextArea').style.display = "";	  
  document.getElementById('blastHeight').style.height = '230px';	 
}

function viewListForm() {
  document.getElementById('listForm').style.display = "";	
//  document.getElementById('blastTextArea').style.display = "";	  
  document.getElementById('listFormHeight').style.height = '0px';	 
}
