<!--Javascript function onlaod-->
<!--the onLoad function to call functions need to be loaded on load-->
function FunonLoad(method,method2) {
    FunMendoQuery(method,method2);
    FunCall(method,method2);
	var my_method=method			
	FunVideoOnLoad(my_method);
	displayhidden()
}

<!--Function for video tabs-->
function FunVideoOnLoad(my_method){
            switch(my_method) {
    		case "environment":
        {FunCallVideo("ReutersEnvironmentVideo111");}
        	break;
    		case "sports":
        {FunCallVideo("BBCSportVideo211");}
        	break;
			default:
        {FunCallVideo("BBCWvidRdf");}
	}
}
				
<!--Function to get cookie-->
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

<!--Function to display hidden-->
function displayhidden() {
	document.getElementById('clock').style.display = '';
}

<!--Ajax Function request for LiveFeed  -->
function FunCallLiveFeed(argumentname)	{
	// send data to CF
	DWRUtil.useLoadingMessage();
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'myFuncLiveFeed', argumentname, jsReturnLiveFeed);
}
	// return data form CF
	function jsReturnLiveFeed(r) {
    	DWRUtil.setValue("livefeed",r);
	}
<!--Ajax Function for  nain menu query-->
function FunMendoQuery(argumentname,argumentname2)  {
		var instance = new casheWorld();
		instance.setCallbackHandler(doMenuQueryResults);
		instance.setQueryFormat("column");
		instance.doCountryQuery(argumentname,argumentname2);
		}

function doMenuQueryResults (r)  {
		//alert(r.DATA.NAME[i]);
		var divSectionLinks1=document.getElementById('sourcesmenu');
		var list=divSectionLinks1.getElementsByTagName('ul');
		for(i=0;i<list.length;i++){
		divSectionLinks1.removeChild(list[i]);
		}
			var x = getCookie('SECTIONS')
			var y = getCookie('COUNTRY')
			var z = getCookie('SOURCE')
			var divSectionLinks1=document.getElementById('sourcesmenu');
			var ul1=document.createElement('ul');
			divSectionLinks1.appendChild(ul1);
			for(i=0;i<r.DATA.NAME.length;i++){
			var	myList1 = document.createElement('li');
			ul1.appendChild(myList1);
			var a1 = document.createElement('a');	
					a1.setAttribute("href", "#method3=" + r.DATA.NAME[i]);
					a1.setAttribute("class", "linksmenu");
					a1.setAttribute("name", r.DATA.NAME[i]);
					a1.onclick = function(){
					var x = getCookie('SECTIONS')
					var y = getCookie('COUNTRY')
					var z = this.name
					var turl = "\'/"+x+"/"+y+"/"+z+"\'"
						document.getElementById("contentmain").innerHTML='<img id="loader" src="/images/ajax-loaderbig.gif" />'; 
						//setCookie(this.name); 
						FunCall(this.name);
						pageTracker._trackPageview(turl);
						}
			myList1.appendChild(a1);
			var text1=document.createTextNode(r.DATA.NAME_DIPLAYED[i]);
				a1.appendChild(text1);
			}
	}

<!--Ajax Function request for content -->
function FunCall(argumentname,argumentname2)	{
	// send data to CF
	var instance = new casheWorld();
	instance.setCallbackHandler(jsReturn);
	instance.setReturnFormat("json"); 
	instance.myFuncWorld(argumentname);		
}
// return data form CF
	function jsReturn(r) {
    	//alert(r);
		document.getElementById("contentmain").innerHTML = r;
		//Call the functions for logo and title
		var x = getCookie('SOURCE');
		FunCallSourceLogos(x);
		//FunCallSourceName(x);
		//Highlight the selected menu
		var sourcesmenu = document.getElementById("sourcesmenu");
		for (i = 0; i < sourcesmenu.childNodes[0].childNodes.length; i++) {
			if (sourcesmenu.childNodes[0].childNodes[i].childNodes[0].name == x) {
				sourcesmenu.childNodes[0].childNodes[i].setAttribute("selected", "yes");
			}
			else {
				sourcesmenu.childNodes[0].childNodes[i].setAttribute("selected", "no");
			}
			
		}
		
	}

	

<!--Ajax Function request logo for title content -->
function FunCallSourceLogos(argumentname) {
	//send data to CF
	var instance = new casheWorld();
	instance.setCallbackHandler(showLogo);
	instance.setReturnFormat("plain"); 
	instance.myFuncWorldLogos(argumentname);
    }
// return data form CF
	
function showLogo(l) {
var divLogos=document.getElementById('logos');
		var imageOld=divLogos.getElementsByTagName('img');
		for(i=0;i<imageOld.length;i++){
		divLogos.removeChild(imageOld[i]);
		}
			var divLogos=document.getElementById('logos');
			var	myImage1 = document.createElement('img');
				myImage1.setAttribute("src", l);
				divLogos.appendChild(myImage1);
}


<!--Ajax Function request for video content -->
function FunCallVideo(argumentname)	{
	// send data to CF
	var instance = new casheWorld();
	instance.setCallbackHandler(jsVReturn);
	instance.setReturnFormat("json"); 
	instance.myFuncWorldVideo(argumentname);
}
	// return data form CF
	function jsVReturn(v) {
    	//alert(r);
		document.getElementById("video").innerHTML = v;
	}	

<!--For pop-up window Video-->
var newwindow;
	function poptastic(url){
		newwindow=window.open(url,'name');
		if (window.focus) {newwindow.focus()}
	}	
			

//function readCookie(name) {
//	var nameEQ = name + "=";
//	var ca = document.cookie.split(';');
//	for(var i=0;i < ca.length;i++) {
//		var c = ca[i];
//		while (c.charAt(0)==' ') c = c.substring(1,c.length);
//		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
//	}
//	return null;
//}

//function eraseCookie(name) {
//	createCookie(name,"",-1);
//}
	
			
			
		
