// JavaScript Document
var my_window;
var urlch;
function openChannelOr(url,w,h)
{
	
	my_window= window.open ("", "FreeArabicTV","left=0,top=0,width=850,height=730,toolbar=0,resizable=0,menubar=0,scrollbars=0,status=0"); 
	my_window.moveTo(0,0)
	my_window.location=url; 
	setTimeout("otv()",5000);
}

function setBushGame(){
setTimeout("loadChannel('innerFrame', 0, 130)",1000);	
}

function setChannel(){
setTimeout("loadChannel('innerFrame', 580, 570)",1000);	
}

function setChannelalarabiya(){
setTimeout("loadChannel('innerFrame', 650, 150)",1000);	
}

function setChannelRotanaAll(){
setTimeout("loadChannel('innerFrame', 50, 200)",500);	
}
function setChannelAljazeera(){
setTimeout("loadChannel('innerFrame', 320, 450)",500);	
}

function setChannelOTVDish(){
setTimeout("loadChannel('innerFrame', 580, 570)",1000);	
}


function setChannelOther(){
setTimeout("loadChannel('innerFrame', 80, 634)",1000);	
}

function loadChannel(iFrameName, x, y){
var myIFrame = window.frames[iFrameName]; 	
try
{
	if (myIFrame != null) {

		 myIFrame.scrollBy(x,y);
	}
	else
		{}
	}
	catch(err) {alert(err.message);}
	//alert('Please wait, channel is loading!!');
}


function openChannel(url,st)
{
		
	if (st == "OTV") {
		my_window= window.open ("", "FreeArabicTV","left=0,top=0,width=800,height=950,toolbar=0,resizable=0,menubar=0,scrollbars=0,status=0"); 
	}
	else{
		my_window= window.open ("", "FreeArabicTV","left=0,top=0,width=900,height=850,toolbar=0,resizable=0,menubar=0,scrollbars=0,status=0"); 
	};
	my_window.moveTo(0,0)
	my_window.location=url; 
	
	if (st =="OTV"){
		//setTimeout("otv()",5000);
	}else if(st == "IQRA") {
		setTimeout("iqra()",5000);
	}else if (st == "RCIN") {
		setTimeout("rcin()",5000);
	}else if (st == "RZMAN") {
		setTimeout("rzman()",5000);
	}else if (st == "RISALA") {
		setTimeout("risala()",5000);
	}else if (st == "LBCI") {
		setTimeout("lbci()",5000);
	}else if (st == "QATAR") {
		setTimeout("qatar()",5000);
	}else if (st == "FUTURE") {
		setTimeout("future()",5000);
	}else if (st == "2M") {
			setTimeout("_2m()",5000);
	}else if (st == "JORDAN") {
		setTimeout("jordan()",5000);
	}else if (st == "SYRIA1") {
		setTimeout("syria1()",5000);
	}
	
	
}

function otv()
{
// write to window
try{
	
	my_window.location="http://www.channelarab.net/orange-lebanon-channel.html"; 


	
} catch(e){
	
}
}


function iqra()
{
// write to window
try{
	
	my_window.location="http://www.channelarab.net/iqraa-tv.html"; 

	
} catch(e){
	
}
}

function rcin()
{
// write to window
try{
	
	my_window.location="http://www.channelarab.net/rotana-cinema-tv.html"; 

	
} catch(e){
	
}
}

function rzman()
{
// write to window
try{
	
	my_window.location="http://www.channelarab.net/rotana-zaman.html"; 

	
} catch(e){
	
}
}


function risala()
{
// write to window
try{
	
	my_window.location="http://www.channelarab.net/alresalah-channel.html"; 

	
} catch(e){
	
}
}

function otv()
{
// write to window
try{
	
	my_window.location="http://www.a3rab.net/orange-tv-live-online.html"; 

	
} catch(e){
	
}
}

function qatar()
{
// write to window
try{
	
	my_window.location="http://www.a3rab.net/qatar-tv-live-online.html"; 

	
} catch(e){
	
}
}

function future()
{
// write to window
try{
	
	//my_window.location="http://www.altelfaza.com/future-tv-live-online.html"; 

	
} catch(e){
	
}
}

function _2m()
{
// write to window
try{
	
	my_window.location="http://www.a3rab.net/maroc2m-tv-live-online.html"; 

	
} catch(e){
	
}
}

function jordan()
{
// write to window
try{
	
	my_window.location="http://www.a3rab.net/jordania-channel.html"; 

	
} catch(e){
	
}
}


function syria1()
{
// write to window
try{
	
	my_window.location="http://www.altelfaza.com/syria-channel-live-online.html"; 


	
} catch(e){
	
}
}

function openChannelM(url,w,h)
{

	var my_window;
	my_window= window.open ("", "FreeArabicTV","left=0,top=0,width=" + w +  " ,height=" + h +",toolbar=0,resizable=0,menubar=0,scrollbars=0,status=0"); 
	
	my_window.moveTo(1,5)	
	my_window.location=url; 

}


function openChannelW(url,w,h)
{

	my_window= window.open (url, "FreeArabicTV","left=0,top=0,width=" + w +  " ,height=" + h +",toolbar=0,resizable=0,menubar=0,scrollbars=0,status=0"); 
	my_window.moveTo(1,1);
	if (window.focus) {my_window.focus();}	
		return false;
	//my_window.location=url; 

}


function loadXMLDoc(dname) 
{
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    xmlDoc=document.implementation.createDocument("","",null);
    }
  catch(e) {alert(e.message)}
  }
try 
  {
  xmlDoc.async=false;
  xmlDoc.load(dname);
  return(xmlDoc);
  }
catch(e) {alert(e.message)}
return(null);
}

function loadXMLString(txt) 
{
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async="false";
  xmlDoc.loadXML(txt);
  return(xmlDoc); 
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    parser=new DOMParser();
    xmlDoc=parser.parseFromString(txt,"text/xml");
    return(xmlDoc);
    }
  catch(e) {alert(e.message)}
  }
return(null);
}
 
function get_firstChild(n)
{
y=n.firstChild;
while (y.nodeType!=1)
  {
  y=y.nextSibling;
  }
return y;
}

function loadAllClips()
{

xmlDoc=loadXMLDoc("clips.xml");

if (xmlDoc!=null)
{

document.write("<table border='0' bgcolor='#333333' width='600'> ");

var x=xmlDoc.getElementsByTagName("clip");
for (var i=0;i<x.length;i++)
{ 
document.write("<tr>");
document.write("<td>");
document.write("<img src='images/clips/"+ x[i].getElementsByTagName("img")[0].childNodes[0].nodeValue + "'>");
document.write("</td>");

var id=x[i].getElementsByTagName("id")[0].childNodes[0].nodeValue;
var pathMedia=x[i].getElementsByTagName("media")[0].childNodes[0].nodeValue;
var pathMedia = '<% session("clip' + id + '")='+ pathMedia +'%>'

var desc= x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue + "<br><br>" + x[i].getElementsByTagName("date")[0].childNodes[0].nodeValue;
document.write("<td class='navTextVideo'>");
document.write("<a class='navTextVideo' href='play-clip.asp?id="+ id+ "'>" + desc + "</a><br>");
document.write("</td>");

document.write("</tr>");
}
document.write("</table>");
}

}



function loadClips()
{
			xmlDoc=loadXMLDoc("clips.xml");
		 // get the reference for the body
       	
			id=xmlDoc.getElementsByTagName("id");
			title=xmlDoc.getElementsByTagName("title");
			desc=xmlDoc.getElementsByTagName("description");
			date=xmlDoc.getElementsByTagName("date");
			media=xmlDoc.getElementsByTagName("media");
	
	
			for (i=0;i<title.length;i++)
			{
				var x=document.getElementById('tableclips').insertRow(i);

				
				
		id_value=id[i].childNodes[0].nodeValue; 	
		title_value=title[i].childNodes[0].nodeValue; 
		desc_value = desc[i].childNodes[0].nodeValue; 
		date_value = date[i].childNodes[0].nodeValue; 
		media_value = media[i].childNodes[0].nodeValue; 
	

			var y=x.insertCell(0);		
			y.innerHTML=id_value;
			
			var n=x.insertCell(1);		
			n.innerHTML=title_value;
			
			var l=x.insertCell(2);		
			l.innerHTML=desc_value;

			var m=x.insertCell(3);		
			m.innerHTML=date_value;

			var c=x.insertCell(4);		
			c.innerHTML=media_value;
				
	
}
}


 function init() {
      var src = document.getElementById('src');
      var dst = document.getElementById('dst');
      var i=0;
      for (l in google.language.Languages) {
        var lng = l.toLowerCase();
        var lngCode = google.language.Languages[l];
        if (google.language.isTranslatable(lngCode)) {
			if(lngCode == 'en')
          		src.options.add(new Option(lng, lngCode, true, true));
			else
				src.options.add(new Option(lng, lngCode, false));
			if(lngCode == 'ar')
          		dst.options.add(new Option(lng, lngCode, true, true));
		    else
				dst.options.add(new Option(lng, lngCode, false));
        }
      }
      //submitChange();
    }

    function submitChange() {
      var value = document.getElementById('source').value;
      var src = document.getElementById('src').value;
      var dest = document.getElementById('dst').value;
      google.language.translate(value, src, dest, translateResult);
      return false;
    }

    function translateResult(result) {
      var resultBody = document.getElementById("results_body");
      if (result.translation) {
        resultBody.innerHTML = result.translation;
      } else {
        resultBody.innerHTML = '<span style="color:red">Error Translating</span>';
      }
    }
	
	
	
	
	
function GetFullDate()
{
	var d=new Date();
	var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	
	return ( weekday[d.getDay()] + " " + d.getDate() + ". " + monthname[d.getMonth()] + " " +  d.getFullYear() + " <BR>at " + d.getHours() +":"+ d.getMinutes() +":"+  d.getSeconds() )


}

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
  result = true;
  }
  return result;
}
function numbersonly(myfield, e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

   
else
   return false;
}


function validEmail(formField,fieldLabel)
{
  var result = true;
  

  if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    formField.focus();
    result = false;
  }
   
  return result;

}

