﻿_spBodyOnLoadFunctionNames.push("ReWriteArticleVideoImgLinks");
_spBodyOnLoadFunctionNames.push("ReWriteVideoImgLinks");
function ReWriteVideoImgLinks()
{  
	var fields,i;
	var VideoURL = "";  
	fields = document.getElementsByTagName('IMG');  
	for( i = 0; i < fields.length; i ++ ) 
	{    
		var imgsrc = fields[i].getAttribute('SRC');    
		if(imgsrc.indexOf("VideoIcon.gif") != -1) 
		{      
			VideoURL = "";
			VideoURL = fields[i].id;
			//fields[i].onclick = showFlashVideoPopup;  
			//fields[i].attachEvent("onclick", function() { showFlashVideoPopup(VideoURL) } );
			fields[i].onclick = function(){showFlashVideoPopup(this.id);};
			
		}  
	}  
}

function showFlashVideoPopup(VideoURL) {
  var popup;
  var currentSite = "";
  if (window.location.href.toLowerCase().indexOf('qnaar')>=0)
  	  currentSite = "qnaar";
  else
  if (window.location.href.toLowerCase().indexOf('qnaen')>=0)
  	  currentSite = "qnaen";

	var windowWidth = "800";
	var windowHeight = "615";
	var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

  	popup = window.open("/_controls/QNAVideoPlayer.aspx?CurrentSite=" + currentSite + "&VideoURL="+ VideoURL, "popup", "height=" + windowHeight + ",width=" + windowWidth + ",left=" + centerWidth + 
        ",top=" + centerHeight);

 
	 // popup = window.open("video.htm", "popup", "height=600,width=950");

  popup.focus();
//  return false;
}

function showMainFlashVideoPopup() {
  var popup;

  var currentSite = "";
  if (window.location.href.toLowerCase().indexOf('qnaar')>=0)
  	  currentSite = "qnaar";
  else
  if (window.location.href.toLowerCase().indexOf('qnaen')>=0)
  	  currentSite = "qnaen";
	var windowWidth = "800";
	var windowHeight = "615";
	var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

  	popup = window.open("/_controls/QNAVideoPlayer.aspx?CurrentSite=" + currentSite, "popup", "height=" + windowHeight + ",width=" + windowWidth + ",left=" + centerWidth + 
        ",top=" + centerHeight);
  	  
	popup.focus();
}

function ReWriteArticleVideoImgLinks()
{
	var fields,i;
	var VideoURL = "";  
	var found = false;
	/*fields = document.getElementsByTagName('SELECT');  
	for( i = 0; i < fields.length; i ++ ) 
	{    
		var selecttitle = fields[i].getAttribute('TITLE');    
		if(selecttitle.indexOf("QNAFlashVideoLinkAr") != -1) 
		{      
			found = true;		
			//fields[i].onchange = function(){AddArticleVideoLink(this.options[this.selectedIndex].text + ".flv");}			
		}
		else if(selecttitle.indexOf("QNAFlashVideoLinkEn") != -1) 
		{      
			found = true;		
			//fields[i].onchange = function(){AddArticleVideoLink(this.options[this.selectedIndex].text + ".flv");}			
		}
		  
	} */
	if (document.getElementById("SPQNAFlashVideoLinkAr_Hidden") != null)
		found = true;		
	else if (document.getElementById("SPQNAFlashVideoLinkEn_Hidden") != null)
		found = true;		
	
	if (found == false)
	{
		if (document.getElementById("ArticleVideoLink") != null)
		{
			if ((document.getElementById("ArticleVideoLink").getElementsByTagName("A") != null) && (document.getElementById("ArticleVideoLink").getElementsByTagName("A").length > 0) && (document.getElementById("ArticleVideoImgLink") != null))
			{
					  var imgAlt = "شاهد";
					  var currentSite = "qnaar";
					  if (window.location.href.toLowerCase().indexOf('qnaar')>=0)
					  {
					  	  currentSite = "qnaar";
					  	  imgAlt = "شاهد";
					  }
					  else
					  if (window.location.href.toLowerCase().indexOf('qnaen')>=0)
					  {
					  	  imgAlt = "Watch";					  
						  currentSite = "qnaen";
					  }	  
					if (document.getElementById("ArticleVideoLink").getElementsByTagName("A")[0].innerText != "")
					{
						VideoURL = document.getElementById("ArticleVideoLink").getElementsByTagName("A")[0].innerHTML + ".flv";
						//document.getElementById("ArticleVideoImgLink").innerHTML = "<img id=" + VideoURL + " src=/Images/" + currentSite + "/VideoIcon.gif alt=" + imgAlt + " border=0 align=absmiddle style=cursor:pointer;margin-right:2px;margin-left:2px>";//"<img id=""" + VideoURL + """ src=""/Images/QNAAr/VideoIcon.gif"" border=0 align=absmiddle style=""cursor:pointer;margin-right:2px;margin-left:2px"">";
					}
			}	
			document.getElementById("ArticleVideoLink").style.display = "none";
		}
	}

}

function AddArticleVideoLink(VideoURL)
{
	if (document.getElementById("ArticleVideoLink") != null)
	{
		//document.getElementById("ArticleVideoLink").innerHTML = "<img id=" + VideoURL + " src=/Images/QNAAr/VideoIcon.gif border=0 align=absmiddle style=cursor:pointer;margin-right:2px;margin-left:2px>";//"<img id=""" + VideoURL + """ src=""/Images/QNAAr/VideoIcon.gif"" border=0 align=absmiddle style=""cursor:pointer;margin-right:2px;margin-left:2px"">";
	}	
	
}
function addbookmark(url, name)
{
if (document.all)
window.external.AddFavorite(url,name);
}

/*-----------------------------------------------------------*/	
							
var isReady=true ;
function doSaveAs()
{						
if (document.execCommand){
if (isReady){window.document.execCommand("SaveAs",null,document.title.replace(/\|/g,' - '));}
}else{
alert('Feature available only in Internet Exlorer 4.0 and later.');
}
}											

/*-----------------------------------------------------------*/

function QNAprintPartAr()

{
var html = '<HTML>\n<HEAD>\n';
if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}

html += '\n</HEAD>\n<BODY dir="rtl">\n<TABLE bgcolor="white" height="600">\n<TR>\n<TD valign="top"><TABLE bgcolor="white" width="100%" align="center">\n<TR>\n<TD align="center">\n<img src="/images/QNAAr/PrintQNALogo.gif" alt=""ØÈÇÚÉ ÎÈÑ ãä æßÇáÉ ÇáÃäÈÇÁ ÇáÞØÑíÉ />\n</TD>\n</TR>\n\n<TR>\n<TD align="center">\n<img src="/images/QNAAr/PrintQNATitle.gif" alt=""ØÈÇÚÉ ÎÈÑ ãä æßÇáÉ ÇáÃäÈÇÁ ÇáÞØÑíÉ />\n</TD>\n</TR>\n<TR>\n<TD><hr class="PrintNewsHr">\n</TD>\n</TR>\n</TABLE>\n';
var printReadyElem = document.getElementById("QNAprintPart");
var BCM = document.getElementById("BCM");
if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
html +='<DIV style="padding-RIGHT:15PX;padding-LEFT:15PX;padding-top:10px;">';
html += BCM .innerHTML;
html +='</DIV>';

}
else
{
alert("Could not Print this page");
return;
}

html += '\n<TABLE bgcolor="white" width="100%">\n<TR>\n<TD><hr class="PrintNewsHr">\n</TD>\n</TR>\n\n<TR>\n<TD class="PrintNewsUrl" align="left">' + location.href + '\n</TD>\n</TR>\n</TABLE>\n</TD>\n</TR>\n</TABLE>\n</BODY>\n</HTML><script type="text/javascript">document.getElementById("Up").style.display = "none";document.getElementById("ResizeFont").style.display = "none";document.getElementById("ImageCaptionBullet").src = "/images/QNAAr/ImageCaptionBulletPrint.GIF";</script><script type="text/javascript">document.getElementById("ResizeFont").style.display = "none";document.getElementById("ImageCaptionBullet").src = "/images/QNAAr/ImageCaptionBulletPrint.GIF";</script>';



var printWin = window.open("","QNAprintPart",'height=600,width=600,scrollbars =1');
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
printWin.print();
}

/*-----------------------------------------------------------*/

function QNAprintPartEn()

{
var html = '<HTML>\n<HEAD>\n';
if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}

html += '\n</HEAD>\n<BODY dir="ltr">\n<TABLE bgcolor="white" height="600">\n<TR>\n<TD valign="top"><TABLE bgcolor="white" width="100%" align="center">\n<TR>\n<TD align="center">\n<img src="/images/QNAAr/PrintQNALogo.gif" alt=""ØÈÇÚÉ ÎÈÑ ãä æßÇáÉ ÇáÃäÈÇÁ ÇáÞØÑíÉ />\n</TD>\n</TR>\n\n<TR>\n<TD align="center">\n<img src="/images/QNAAr/PrintQNATitle.gif" alt=""ØÈÇÚÉ ÎÈÑ ãä æßÇáÉ ÇáÃäÈÇÁ ÇáÞØÑíÉ />\n</TD>\n</TR>\n<TR>\n<TD><hr class="PrintNewsHr">\n</TD>\n</TR>\n</TABLE>\n';
var printReadyElem = document.getElementById("QNAprintPart");
var BCM = document.getElementById("BCM");
if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
html +='<DIV style="padding-RIGHT:15PX;padding-LEFT:15PX;padding-top:10px;" dir="ltr">';
html += BCM .innerHTML;
html +='</DIV>';

}
else
{
alert("Could not Print this page");
return;
}

html += '\n<TABLE bgcolor="white" width="100%">\n<TR>\n<TD><hr class="PrintNewsHr">\n</TD>\n</TR>\n\n<TR>\n<TD class="PrintNewsUrl" align="left">' + location.href + '\n</TD>\n</TR>\n</TABLE>\n</TD>\n</TR>\n</TABLE>\n</BODY>\n</HTML><script type="text/javascript">document.getElementById("Up").style.display = "none";document.getElementById("ResizeFont").style.display = "none";document.getElementById("ImageCaptionBullet").src = "/images/QNAAr/ImageCaptionBulletPrint.GIF";</script><script type="text/javascript">document.getElementById("ResizeFont").style.display = "none";document.getElementById("ImageCaptionBullet").src = "/images/QNAAr/ImageCaptionBulletPrint.GIF";</script>';



var printWin = window.open("","QNAprintPart",'height=600,width=600,scrollbars =1');
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
printWin.print();
}

/************************************************************/
function ChangeStyle(obj, flag)
{
	if (flag == 0)
	{
		obj.style.fontFamily = 'Traditional Arabic, Times New Roman, Times, serif';
		obj.style.textDecoration='';
		obj.style.color='#005190';
	}
	else
	{
		obj.style.fontFamily = 'Traditional Arabic, Times New Roman, Times, serif';
		obj.style.textDecoration='none';
		obj.style.color='#9d0046';
	}
}
	
/************************************************************/
function ChangeStyleEn(obj, flag)
{
	if (flag == 0)
	{
		obj.style.fontFamily = 'Arial';
		obj.style.textDecoration='none';
		obj.style.color='#005190';
	}
	else
	{
		obj.style.fontFamily = 'Arial';
		obj.style.textDecoration='none';
		obj.style.color='#9d0046';
	}
}
	
/************************************************************/
function ChangeStyleFTP(obj, flag)
{
	if (flag == 0)
	{
		obj.style.fontFamily = 'Arial';
		obj.style.textDecoration='';
		obj.style.color='#005190';
	}
	else
	{
		obj.style.fontFamily = 'Arial';
		obj.style.textDecoration='none';
		obj.style.color='#9d0046';
	}
}

/************************************************************/
function ChangeStyleReports(obj, flag)
{
	if (flag == 0)
	{
		obj.style.fontFamily = 'Traditional Arabic, Times New Roman, Times, serif';
		obj.style.textDecoration='';
		obj.style.color='#4C4C4C';
	}
	else
	{
		obj.style.fontFamily = 'Traditional Arabic, Times New Roman, Times, serif';
		obj.style.textDecoration='none';
		obj.style.color='#9d0046';
	}
}

function ChangeStyleReportsEn(obj, flag)
{
	if (flag == 0)
	{
		obj.style.fontFamily = 'Arial';
		obj.style.textDecoration='';
		obj.style.color='#4C4C4C';
	}
	else
	{
		obj.style.fontFamily = 'Arial';
		obj.style.textDecoration='none';
		obj.style.color='#9d0046';
	}
}

	
/************************************************************/


/************************************************************/
function ChangeStyleEmirSpeechesAr(obj, flag)
{
	if (flag == 0)
	{
		obj.style.fontFamily = 'Traditional Arabic, Times New Roman, Times, serif';
		obj.style.textDecoration='';
		obj.style.color='#545353';
	}
	else
	{
		obj.style.fontFamily = 'Traditional Arabic, Times New Roman, Times, serif';
		obj.style.textDecoration='none';
		obj.style.color='#B4B4B4';
	}
}

function ChangeStyleEmirSpeechesEn(obj, flag)
{
	if (flag == 0)
	{
		obj.style.fontFamily = 'Arial';
		obj.style.textDecoration='';
		obj.style.color='#545353';
	}
	else
	{
		obj.style.fontFamily = 'Arial';
		obj.style.textDecoration='none';
		obj.style.color='#B4B4B4';
	}
}

	
/************************************************************/


function popUpQatarGallery(URL)
{
day = new Date();	
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=500');");
}

function popUpQNAWeekEvents(URL)
{
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=500');");
}

function popUpQatarMap(URL)
{
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=530');");
}

/********************************************************************/

var tgs = new Array( 'div');

var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 3;

function FSize( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	sz += inc;
	if ( sz < 2 ) sz = 2;
	if ( sz > 5 ) sz = 5;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}


/********************************************************************/
if (document.getElementById("QNAProPublishingPagePropertiesActionQuickAccessButton_anchor"))
	alert(document.getElementById("QNAProPublishingPagePropertiesActionQuickAccessButton_anchor").className);
	//document.getElementById("QNAProPublishingPagePropertiesActionQuickAccessButton_anchor").setAttribute("Class", "thickbox");
/********************************************************************/

/*function QNASiteMasterMenuLoading()
{
    document.getElementById("LoadingMasterMenu").style.display = "none";
    document.getElementById("QNAMasterMenu").style.display = "inline";
    var oImg = document.getElementById("MasterMenuOnLoadImage");
    oImg.onload = function () {
      document.getElementById("LoadingMasterMenu").style.display = "inline";
      document.getElementById("QNAMasterMenu").style.display = "none";
    } 
}*/


/*function QNASiteServicesLoading()
{
    document.getElementById("LoadingSiteServices").style.display = "none";
    document.getElementById("QNASiteServices").style.display = "inline";
    var oImg = document.getElementById("SiteServicesOnLoadImage");
    oImg.onload = function () {
      document.getElementById("LoadingSiteServices").style.display = "inline";
      document.getElementById("QNASiteServices").style.display = "none";
    } 
}*/

function QNAWeatherTblLoading()
{
    document.getElementById("LoadingWeatherTbl").style.display = "none";
    document.getElementById("QNAWeatherTbl").style.display = "inline";
    var oImg = document.getElementById("QNAWeatherLoadImage");
    oImg.onload = function () {
      document.getElementById("LoadingWeatherTbl").style.display = "inline";
      document.getElementById("QNAWeatherTbl").style.display = "none";
    } 
}

function QNAExRatesTblLoading()
{
    document.getElementById("LoadingExRatesTbl").style.display = "none";
    document.getElementById("QNAExRatesTbl").style.display = "inline";
    var oImg = document.getElementById("QNAExRatesLoadImage");
    oImg.onload = function () {
      document.getElementById("LoadingExRatesTbl").style.display = "inline";
      document.getElementById("QNAExRatesTbl").style.display = "none";
    } 
}

/*/////////////////MR Forms//////////////////////*/

var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox


