﻿/* Instructions for the video gallery are in a README TXT file. */

// Declare all variables.
var browser=navigator.appName;
var i = 0; var f = 0; var c = 0; var d = 0; var h = 0; var x = 0; var g = 0;
var objectref = ""; var divcommand = ""; var xmlDoc; var lengthCalc = 0;
var tempVideoList = ""; var tempVariable = ""; var tempVariable2 = ""; var tempLinksList = "";
var flashList = new Array(); var linksList = new Array(); var sizeList = new Array(); var descList = new Array(); var nameList = new Array();

function eng() { var trogei = location.href; if (trogei.lastIndexOf("la=2") > 0) return true; else return false; }

// Multiply the blank space.
function multiplyStr(f) { var returnStr;
for (h=0;h<=f;h++) { returnStr = returnStr + ""; }
return returnStr; }

// Count substring occurances on string.
String.prototype.count=function(s1) { return (this.length - this.replace(new RegExp(s1,"g"), '').length) / s1.length; }

// Function to verify XML files.
function verify() 
{ if (xmlDoc.readyState != 4) { return false; } }

// Function to create a list of video links.
function linksPage(numbah)
{ c = 0;
x = 0;
d = numbah;
g = d;
numbah = numbah * 4 - 3;
tempLinksList = "<table width=\"100%\" bgcolor=\"#f9f9f8\" align=\"center\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">";
for (h=0;h<=3;h++) { tempLinksList = tempLinksList + linksList[numbah]; d++; numbah++; } 
tempVariable = linksList.length - 1;
tempLinksList = "";
for (h=1;h<=tempVariable+3;h=h+4) { 
if (linksList[h] != 'undefined' && linksList[h] != null) { c++;
if (g == c) { tempLinksList = tempLinksList + ""; }
else { tempLinksList = tempLinksList + ""; } } } tempLinksList = tempLinksList + "</td></tr></table>";
if (tempLinksList.count('Τύπος αρχείου : FLV') < 4) { tempLinksList = tempLinksList + multiplyStr(4 - tempLinksList.count('Τύπος αρχείου : FLV') - 1); }
return tempLinksList.replace("undefined","").replace("undefined","").replace("undefined","").replace("undefined","").replace("undefined",""); }
function setCookie(c_name,value,expiredays)
{ }
function getCookie(c_name)
{ return "1"; }

// Function to add a new flash player object.
function newPrint(file, ilame) 
{
  	var ext = /^.+\.([^.]+)$/.exec(file);
  	ext == null ? "" : ext[1];  

	if (browser === "Netscape") 
	{
		var additionalParams = "";
	}
	else 
	{ 	//id=\"FlashID\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"
		var additionalParams = "id=\"HUY\" name=\"HYETA\" type=\"application/x-shockwave-flash\"";  
	}
	
	if (file.length >= 2) 
	{ 
		f++;
		flashList[f] = "<strong>" + descList[0] + "</strong>"
		+ "<div align=\"center\" style=\"visibility:visible\" ><object " + additionalParams + " style=\"visibility:visible\" type=\"application/x-shockwave-flash\" data=\"/videos/itv/player_4.3_for_plugin.swf\" width=\"240\" height=\"210\">"
		+ "<param name=\"movie\" value=\"/videos/itv/player_4.3_for_plugin.swf\">"
		+ "<param name=\"allowFullScreen\" value=\"true\">"
		+ "<param name=\"autostart\" value=\"false\">"
		+ "<param name=\"image\" value=\"" + file.replace(".flv","") + ".jpg\">"
		+ "<param name=\"allowScriptAccess\" value=\"always\">"
		+ "<param name=\"Enable\" value=\"0\">"
		+ "<param name=\"wmode\" value=\"transparent\">"
		+ "<param name=\"flashvars\" value=\"width=240&amp;height=210&amp;file=" + file + "&amp;fullscreen=true&amp;image=" + file.replace(ext[1],"") + "jpg&amp;plugins=/videos/itv/jwp4-streamsense-plugin.swf&amp;autostart=false&amp;\"> "
		+ ""
		+ "</object></div>";
		visiDiv('default');	
		linksList[f] = "";
			window.onload = function () 
			{ 
			if (document.all) { document.all.whereToList.innerHTML = linksPage('1'); }
			else { document.getElementById('whereToList').innerHTML = linksPage('1'); }
			}
	} 
}

// Function to edit the Div container of all the videos.
function visiDiv(tempnum) { if (tempnum == 'default') { tempVariable = flashList[1];

if (document.all) { document.all.whereToPosition.innerHTML = tempVariable; }
else { document.getElementById('whereToPosition').innerHTML = tempVariable; }

}
else { tempVariable = flashList[tempnum];

if (document.all) { document.all.whereToPosition.innerHTML = tempVariable; }
else { document.getElementById('whereToPosition').innerHTML = tempVariable; }

} }

// Function to initiate XML loading.
function loadXML(xmlFile) 
{ 
document.write("<table align=\"center\" border=\"0\" padding=\"0px\"><tr><td id=\"whereToPosition\">&nbsp;</td></tr></table><table width=\"456\" align=\"center\" border=\"0\" padding=\"0px\"><tr><td id=\"whereToList\">&nbsp;</td></tr></table>");
	if (browser === "Opera" || browser==="Netscape") 
	{
		var xmlhttp = new window.XMLHttpRequest();
		xmlhttp.open("GET",xmlFile,false);
		xmlhttp.send(null);
		var xmlDoc = xmlhttp.responseXML.documentElement;
		var x=xmlDoc.getElementsByTagName("Path")
		for (i=0; i < x.length; i++)
		{
			if (xmlDoc.childNodes[i].textContent != ' ')
			{
				descList[i] = xmlDoc.getElementsByTagName("Path")[i].getAttribute("desc")
				sizeList[i] = xmlDoc.getElementsByTagName("Path")[i].getAttribute("size");
				nameList[i] = xmlDoc.getElementsByTagName("Path")[i].firstChild.nodeValue;
			}				
		}
		newPrint(nameList[0], 1);		
	} 
	else if (browser === "Microsoft Internet Explorer") {
	    xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
	    xmlDoc.async=false; 
	    xmlDoc.load(xmlFile); 
	    xmlObj=xmlDoc.documentElement; 
		xmlDoc.onreadystatechange=verify;
	    tempVideoList = "<table width=\"100%\" align=\"center\" border=\"0\" cellspacing=\"4\" cellpadding=\"4\">";
	    for (i=0; i < xmlObj.childNodes.length ; i++) 
	    {
		   sizeList[i] = xmlDoc.documentElement.childNodes[i].getAttribute("size");
		   descList[i] = xmlDoc.documentElement.childNodes[i].getAttribute("desc");
		   nameList[i] = xmlDoc.getElementsByTagName("Path")[i].firstChild.nodeValue;
	    }
		//newPrint(xmlObj.childNodes[0].firstChild.text);
		newPrint(nameList[0], 1);
	} 
	else
	{		
		xmlDoc=document.implementation.createDocument("", "doc", null);
		xmlDoc.async=false;
		xmlDoc.load(xmlFile);
		tempVideoList = "<table width=\"100%\" align=\"center\" border=\"0\" cellspacing=\"4\" cellpadding=\"4\">";  
		var axh = xmlDoc.getElementsByTagName("Path").length;
	  
		for (i=0;i < axh;i++) 
		{
			if (xmlDoc.getElementsByTagName("Path")[i]) { sizeList[i] = xmlDoc.getElementsByTagName("Path")[i].getAttribute("size"); }
			if (xmlDoc.getElementsByTagName("Path")[i]) { descList[i] = xmlDoc.getElementsByTagName("Path")[i].getAttribute("desc"); }	
			
		} 
		newPrint(xmlDoc.documentElement.childNodes[0].textContent);

	}
	
return null;
}
// Load the specified XML.
loadXML(XMLFileName);