﻿/************** PLAYER FUNCTIONS        ************************/

function switchMovie(path, target, title)
{
if (target == 'True') 
{
//var element = document.getElementById('content_wrapper');
document.getElementById('content_wrapper').innerHTML = embedPopup(path);
//var element = document.getElementById('videotitle');
document.getElementById('videotitle').innerHTML = title;
document.getElementById("infoDblClick").style.visibility = 'hidden';
//window.open(path,'mywindow','width=400,height=440,toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');
return;
}
else if (target == 'False')
{
var file = path;
//var element = document.getElementById('content_wrapper');
document.getElementById('content_wrapper').innerHTML = embedLink(file);
//var element = document.getElementById('videotitle');
document.getElementById('videotitle').innerHTML = title;
document.getElementById("infoDblClick").style.visibility = 'visible';
return;
}
//
}

function startIntro(path, target, title)
{
if (target == 'False')
{
var file = path;
//var element = document.getElementById('content_wrapper');
document.getElementById('content_wrapper').innerHTML = embedIntro(file);
//var element = document.getElementById('videotitle');
document.getElementById('videotitle').innerHTML = title;
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}
}

function embedIntro(path)
{
return '<embed src="' + path + '" autostart="true" width="440" showstatusbar="true" showcontrols="true" height="370">';
}

function embedLink(path)
{
return '<embed src="' + path + '" autostart="true" width="440" showstatusbar="true" showcontrols="true" height="370">';
}

function embedPopup(linkurl)
{
return '<center><br /><br /><div style="color: #ffffff; font: normal 14px Verdana, Tahoma; text-align: center; vertical-align:middle; height: 440px"><a href="' + linkurl + '" target="_blank">' + 'Click here to watch the selected channel' + '<br />' + 'A new window will open' + '</a></div></center>';
}


//Za animacija
function startIntroo(path, target, title)
{
if (target == 'False')
{
var file = path;
//var element = document.getElementById('content_wrapper');
document.getElementById('content_wrapper').innerHTML = embedIntroo(file);
//var element = document.getElementById('videotitle');
document.getElementById('videotitle').innerHTML = title;
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}
}

//startIntroo('Images/Watch-Online-Tv-Channels.swf', 'False', 'Watch online TV');
function embedIntroo(path)
{
return '<embed src="' + path + '" autostart="true" width="440" showstatusbar="true" showcontrols="true" height="278">';
}


function loadTVInstructionImage(){
document.getElementById('content_wrapper').innerHTML = embedTVInstructionImage();
document.getElementById('videotitle').innerHTML = "Read more about how to get started";
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}
function embedTVInstructionImage()
{
return '<img src="Images/How-To-Watch-Online-Tv-Channels-Instructions.jpg" alt="Get Entertained watching internet and web television. Online Tv channels" />';
}

function loadRadioInstructionImage(){
document.getElementById('content_wrapper').innerHTML = embedRadioInstructionImage();
document.getElementById('videotitle').innerHTML = "Read more about how to get started";
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}
function embedRadioInstructionImage()
{
return '<img src="Images/How-To-Listen-Online-Radio-Stations-Instructions.jpg" alt="Get Entertained listening internet and web Radio stations. Online Radio Stations" />';
}


function loadInstructionImage(path){
document.getElementById('content_wrapper').innerHTML = embedInstructionImage(path);
document.getElementById('videotitle').innerHTML = "Read more about how to get started";
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}
function embedInstructionImage(path)
{
return '<img src="' + path + '" alt="Get Entertained ! Have some fun !" />';
}

/* GAMES */
function switchGame(path, title){
    var file = path;
    //var element = document.getElementById('content_wrapper');
    document.getElementById('content_wrapper').innerHTML = embedGame(file);
    //var element = document.getElementById('videotitle');
    document.getElementById('videotitle').innerHTML = title;
    return;
}
    
function embedGame(uri, hi){    
    return '<embed src="' + uri + '" menu="false" quality="high" width="490" height="360" name="miniclipGame" align="middle" type="application/x-shockwave-flash" />';
}


function switchingGame(path, title, heig, desc){
    var file = path;
    //var element = document.getElementById('content_wrapper');
    document.getElementById('content_wrapper').innerHTML = embedingGame(file, heig, desc);
    //var element = document.getElementById('videotitle');
    document.getElementById('videotitle').innerHTML = title;
    //var tad = document.getElementById('sodrzina');
    var a = heig * 1;
    var b = 100;
    var c = a + b;
    document.getElementById('sodrzina').style.height = c.toString() + 'px';  
    document.title=title;  
    return;
}

function embedingGame(uri, hi, desc){
return '<div style="margin-left: 5px; height: auto;"><object id="csSWF" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="490" height="' + hi + '" codebase="http://active.macromedia.com/flash7/cabs/ swflash.cab#version=9,0,28,0">'
                + '<param name="src" value="' + uri + '"/>'
                + '<param name="bgcolor" value="#001633"/>'
                + '<param name="quality" value="best"/>'
                + '<param name="allowScriptAccess" value="always"/>'
                + '<param name="allowFullScreen" value="true"/>'
                + '<param name="scale" value="showall"/>'
                + '<param name="flashVars" value="autostart=true"/>'
                + '<embed name="csSWF" src="' + uri + '" width="490" height="' + hi + '" bgcolor="#001633" quality="best" allowScriptAccess="always" allowFullScreen="true" '
                + 'scale="showall" flashVars="autostart=true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
                + '</embed>'
                + '</object></div>'
                + '<div style="font: normal 10px Tahoma, Verdana; color: #e67817; padding-left: 20px; width: 450px;">' + '*' + desc + '</div>'
}   
    
function seeDescription(description){
//var element = document.getElementById('lblInfoAbovePlayer');
document.getElementById('lblInfoAbovePlayer').innerHTML = description;
}

//embed the contact form to the middle of the page
function appearContactForm(linkUrl)
{
var element = document.getElementById('content_wrapper');
element.innerHTML = embedFramedForm(linkUrl);
var element = document.getElementById('videotitle');
element.innerHTML = 'Contact form';
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}

function embedFramedForm(path)
{
return '<iframe src="' + path + '" width="440px" height="380px" scrolling="no" frameborder="0"></iframe>';
}



//embed the problem form to the middle of the page
function appearProblemsForm(linkUrl)
{
var element = document.getElementById('content_wrapper');
element.innerHTML = embedFramedForm(linkUrl);
var element = document.getElementById('videotitle');
element.innerHTML = 'Problems';
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}

//embed the news form to the middle of the page
function appearNewsForm(linkUrl)
{
var element = document.getElementById('content_wrapper');
element.innerHTML = embedFramedForm(linkUrl);
var element = document.getElementById('videotitle');
element.innerHTML = 'News';
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}


//embed the terms form to the middle of the page
function appearTermsForm(linkUrl)
{
var element = document.getElementById('content_wrapper');
element.innerHTML = embedScrollingForm(linkUrl);
var element = document.getElementById('videotitle');
element.innerHTML = 'Terms of use';
document.getElementById("infoDblClick").style.visibility = 'hidden';
return;
}
function embedScrollingForm(path)
{
return '<iframe src="' + path + '" width="440px" height="420px" scrolling="yes" frameborder="0"></iframe>';
}

//embed the RSS forms to the middle of the page
function appearRSSForms(linkUrl, title)
{
var element = document.getElementById('content_wrapper');
element.innerHTML = embedFramedRSSForm(linkUrl);
var element = document.getElementById('videotitle');
element.innerHTML = title;
return;
}

function embedFramedRSSForm(path)
{
return '<iframe src="' + path + '" width="470px" height="440px" scrolling="yes" frameborder="0"></iframe>';
}

/* NEWS PAPERS */
//embed the contact form to the middle of the page
function appearFramedForm(linkUrl, title)
{
var element = document.getElementById('content_wrapper');
element.innerHTML = embedNewsFramedForm(linkUrl);
var element = document.getElementById('videotitle');
element.innerHTML = title;
document.title=title;
return;
}

function embedNewsFramedForm(path)
{
return '<iframe src="' + path + '" width="520px" height="500px" scrolling="auto" frameborder="0"></iframe>';
}

/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Update log:
	
		March, 15th: Fixed problem with sliding in MSIE
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	
var expandFirstItemAutomatically = false;	// Expand first menu item automatically ?
var initMenuIdToExpand = false;	// Id of menu item that should be initially expanded. the id is defined in the <li> tag.
var expandMenuItemByUrl = true;	// Menu will automatically expand by url - i.e. if the href of the menu item is in the current location, it will expand


var initialMenuItemAlwaysExpanded = true;	// NOT IMPLEMENTED YET

var dhtmlgoodies_slmenuObj;
var divToScroll = false;
var ulToScroll = false;	
var divCounter = 1;
var otherDivsToScroll = new Array();
var divToHide = false;
var parentDivToHide = new Array();
var ulToHide = false;
var offsetOpera = 0;
if(navigator.userAgent.indexOf('Opera')>=0)offsetOpera=1;	
var slideMenuHeightOfCurrentBox = 0;
var objectsToExpand = new Array();
var initExpandIndex = 0;
var alwaysExpanedItems = new Array();
	
function popMenusToShow()
{
	var obj = divToScroll;
	var endArray = new Array();
	while(obj && obj.tagName!='BODY'){
		if(obj.tagName=='DIV' && obj.id.indexOf('slideDiv')>=0){
			var objFound = -1;
			for(var no=0;no<otherDivsToScroll.length;no++){
				if(otherDivsToScroll[no]==obj){
					objFound = no;		
				}					
			}	
			if(objFound>=0){
				otherDivsToScroll.splice(objFound,1);	
			}		
		}	
		obj = obj.parentNode;
	}	
}

function showSubMenu(e,inputObj)
{

	if(this && this.tagName)inputObj = this.parentNode;
	if(inputObj && inputObj.tagName=='LI'){
		divToScroll = inputObj.getElementsByTagName('DIV')[0];
		for(var no=0;no<otherDivsToScroll.length;no++){
			if(otherDivsToScroll[no]==divToScroll)return;
		}			
	}
	hidingInProcess = false;
	if(otherDivsToScroll.length>0){
		if(divToScroll){				
			if(otherDivsToScroll.length>0){
				popMenusToShow();
			}
			if(otherDivsToScroll.length>0){	
				autoHideMenus();
				hidingInProcess = true;
			}
		}	
	}		
	if(divToScroll && !hidingInProcess){
		divToScroll.style.display='';
		otherDivsToScroll.length = 0;
		otherDivToScroll = divToScroll.parentNode;
		otherDivsToScroll.push(divToScroll);	
		while(otherDivToScroll && otherDivToScroll.tagName!='BODY'){
			if(otherDivToScroll.tagName=='DIV' && otherDivToScroll.id.indexOf('slideDiv')>=0){
				otherDivsToScroll.push(otherDivToScroll);
									
			}
			otherDivToScroll = otherDivToScroll.parentNode;
		}			
		ulToScroll = divToScroll.getElementsByTagName('UL')[0];
		if(divToScroll.style.height.replace('px','')/1<=1)scrollDownSub();
	}	
	

}



function autoHideMenus()
{
	if(otherDivsToScroll.length>0){
		divToHide = otherDivsToScroll[otherDivsToScroll.length-1];
		parentDivToHide.length=0;
		var obj = divToHide.parentNode.parentNode.parentNode;
		while(obj && obj.tagName=='DIV'){			
			if(obj.id.indexOf('slideDiv')>=0)parentDivToHide.push(obj);
			obj = obj.parentNode.parentNode.parentNode;
		}
		var tmpHeight = (divToHide.style.height.replace('px','')/1 - slideMenuHeightOfCurrentBox);
		if(tmpHeight<0)tmpHeight=0;
		if(slideMenuHeightOfCurrentBox)divToHide.style.height = tmpHeight  + 'px';
		ulToHide = divToHide.getElementsByTagName('UL')[0];
		slideMenuHeightOfCurrentBox = ulToHide.offsetHeight;
		scrollUpMenu();		
	}else{
		slideMenuHeightOfCurrentBox = 0;
		showSubMenu();			
	}
}


function scrollUpMenu()
{

	var height = divToHide.offsetHeight;
	height-=15;
	if(height<0)height=0;
	divToHide.style.height = height + 'px';

	for(var no=0;no<parentDivToHide.length;no++){	
		parentDivToHide[no].style.height = parentDivToHide[no].getElementsByTagName('UL')[0].offsetHeight + 'px';
	}
	if(height>0){
		setTimeout('scrollUpMenu()',5);
	}else{
		divToHide.style.display='none';
		otherDivsToScroll.length = otherDivsToScroll.length-1;
		autoHideMenus();			
	}
}	

function scrollDownSub()
{
	if(divToScroll){			
		var height = divToScroll.offsetHeight/1;
		var offsetMove =Math.min(15,(ulToScroll.offsetHeight - height));
		height = height +offsetMove ;
		divToScroll.style.height = height + 'px';
		
		for(var no=1;no<otherDivsToScroll.length;no++){
			var tmpHeight = otherDivsToScroll[no].offsetHeight/1 + offsetMove;
			otherDivsToScroll[no].style.height = tmpHeight + 'px';
		}			
		if(height<ulToScroll.offsetHeight)setTimeout('scrollDownSub()',5); else {
			divToScroll = false;
			ulToScroll = false;
			if(objectsToExpand.length>0 && initExpandIndex<(objectsToExpand.length-1)){
				initExpandIndex++;
				
				showSubMenu(false,objectsToExpand[initExpandIndex]);
			}
		}
	}
}
	
function initSubItems(inputObj,currentDepth)
{		
	divCounter++;		
	var div = document.createElement('DIV');	// Creating new div		
	div.style.overflow = 'hidden';	
	div.style.position = 'relative';
	div.style.display='none';
	div.style.height = '1px';
	div.id = 'slideDiv' + divCounter;
	div.className = 'slideMenuDiv' + currentDepth;		
	inputObj.parentNode.appendChild(div);	// Appending DIV as child element of <LI> that is parent of input <UL>		
	div.appendChild(inputObj);	// Appending <UL> to the div
	var menuItem = inputObj.getElementsByTagName('LI')[0];
	while(menuItem){
		if(menuItem.tagName=='LI'){
			var aTag = menuItem.getElementsByTagName('A')[0];
			aTag.className='slMenuItem_depth'+currentDepth;	
			var subUl = menuItem.getElementsByTagName('UL');
			if(subUl.length>0){
				initSubItems(subUl[0],currentDepth+1);					
			}
			aTag.onclick = showSubMenu;				
		}			
		menuItem = menuItem.nextSibling;						
	}		
}

function initSlideDownMenu()
{
	dhtmlgoodies_slmenuObj = document.getElementById('dhtmlgoodies_slidedown_menu');
	dhtmlgoodies_slmenuObj.style.visibility='visible';
	var mainUl = dhtmlgoodies_slmenuObj.getElementsByTagName('UL')[0];		
	var mainMenuItem = mainUl.getElementsByTagName('LI')[0];
	mainItemCounter = 1;
	while(mainMenuItem){			
		if(mainMenuItem.tagName=='LI'){
			var aTag = mainMenuItem.getElementsByTagName('A')[0];
			aTag.className='slMenuItem_depth1';	
			var subUl = mainMenuItem.getElementsByTagName('UL');
			if(subUl.length>0){
				mainMenuItem.id = 'mainMenuItem' + mainItemCounter;
				initSubItems(subUl[0],2);
				aTag.onclick = showSubMenu;
				mainItemCounter++;
			}				
		}			
		mainMenuItem = mainMenuItem.nextSibling;	
	}		
	
	if(location.search.indexOf('mainMenuItemToSlide')>=0){
		var items = location.search.split('&');
		for(var no=0;no<items.length;no++){
			if(items[no].indexOf('mainMenuItemToSlide')>=0){
				values = items[no].split('=');
				showSubMenu(false,document.getElementById('mainMenuItem' + values[1]));	
				initMenuIdToExpand = false;				
			}
		}			
	}else if(expandFirstItemAutomatically>0){
		if(document.getElementById('mainMenuItem' + expandFirstItemAutomatically)){
			showSubMenu(false,document.getElementById('mainMenuItem' + expandFirstItemAutomatically));
			initMenuIdToExpand = false;
		}
	}

	if(expandMenuItemByUrl)
	{
		var aTags = dhtmlgoodies_slmenuObj.getElementsByTagName('A');
		for(var no=0;no<aTags.length;no++){
			var hrefToCheckOn = aTags[no].href;				
			if(location.href.indexOf(hrefToCheckOn)>=0 && hrefToCheckOn.indexOf('#')<hrefToCheckOn.length-1){
				initMenuIdToExpand = false;
				var obj = aTags[no].parentNode;
				while(obj && obj.id!='dhtmlgoodies_slidedown_menu'){
					if(obj.tagName=='LI'){							
						var subUl = obj.getElementsByTagName('UL');
						if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
						if(subUl.length>0){								
							objectsToExpand.unshift(obj);
						}
					}
					obj = obj.parentNode;	
				}
				showSubMenu(false,objectsToExpand[0]);
				break;					
			}			
		}
	}
			
	if(initMenuIdToExpand)
	{
		objectsToExpand = new Array();
		var obj = document.getElementById(initMenuIdToExpand)
		while(obj && obj.id!='dhtmlgoodies_slidedown_menu'){
			if(obj.tagName=='LI'){
				var subUl = obj.getElementsByTagName('UL');
				if(initialMenuItemAlwaysExpanded)alwaysExpanedItems[obj.parentNode] = true;
				if(subUl.length>0){						
					objectsToExpand.unshift(obj);
				}
			}
			obj = obj.parentNode;	
		}
		
		showSubMenu(false,objectsToExpand[0]);
	}		
}


   /* AJAX FOR THE COUNTER */
    
    var xmlhttp;
    function HandlerOnReadyStateChange(){
        //"loaded"
        if (xmlhttp.readyState==4){
          //"OK"
          if (xmlhttp.status==200)
          {
              document.getElementById("spnThanks").innerHTML="Thank you for downloading Desktop Entertainment TV.";
          }
          else
          {
             document.getElementById("spnThanks").innerHTML="Try again!!! Thanks!!!.";
          }
        }
      }
      
     function downloadDETV(){
     
       if (window.XMLHttpRequest)
       {
         xmlhttp=new XMLHttpRequest()
       }
       // code for IE
       else if (window.ActiveXObject)
       {
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
       }
       if (xmlhttp!=null)
       {
          url = 'http://www.entertainmentresidence.com/Downloads/Download.aspx';
          xmlhttp.onreadystatechange=HandlerOnReadyStateChange
          xmlhttp.open("GET",url,true)
          xmlhttp.send(null)
       }
       else
       {
           alert("Your browser does not support XMLHTTP.")
       }
    }