// JavaScript Document
var flashPath='/gff/ar/flash/';

$(document).ready(docReadyFReplace);

function docReadyFReplace(){
	
	flash_replacement();
	
}

//-------------------------------------------------
function flash_replacement(){
	titleText=replace_special_chars($('#ab_homeFlash h1').text());
	title2Text=replace_special_chars($('#ab_homeFlash h2').text());

	var textSize = 20;
	var bgAlpha = 35;
	var subText = title2Text;
	var subTextSize = 15;
	var subTextColor = '0xFFFFFF'
	if(location.href.indexOf('/news_article/') > -1 || location.href.indexOf('/image_gallery_details/') > -1 || location.href.indexOf('/blog_details/') > -1){
		//get h1 tag conent 
		h1Text = $('#ab_homeFlash h1').text();
		h1Text = splitBySpace(h1Text, 80);
		
		
		titleText = replace_special_chars( encodeURI(h1Text[0]) );
		
		textSize = 18;
		textColor = '0xFFFFFF';
		bgColor = '0xFFFFFF';
		bgAlpha = 35;
		if(h1Text.length > 1){
			subText =  replace_special_chars( encodeURI(h1Text[1]) );
			
			subTextSize = 18;
			subTextColor = '0xFFFFFF'
		}
		
		
	}

	
	$('#ab_homeFlash').empty().append('<div id="flashTitle"></div>');

	
	var flashvars = {
			fontPath: flashPath+"fonts/hcb.swf",
			text: titleText,
			textSize: textSize,
			textColor: '0xFFFFFF',
			headColor:'0xeffae00',
			//textColor: '0xffffff',
			//bgColor:'0xc0b447',
			bgAlpha: bgAlpha,
			margin: "0 0 0 0",
			subText: subText,
			subTextSize: subTextSize,
			subTextColor: subTextColor,
			spacing: 23,
			lang: 'ar'
		};	
		var params = {
			menu: "false",
			scale: "noScale",
			allowFullscreen: "true",
			allowScriptAccess: "always",
			bgcolor: "#FFFFFF",
			wmode: "transparent"
		};
		var attributes = {
			id:"ab_homeFlashText"
		};

		swfobject.embedSWF(flashPath+"HTMLTitle.swf", "flashTitle", "728", "90", "10.0.0", null, flashvars, params, attributes);
		
	////////////////////////for page Title////////////////////////////////////////////////////
		titleText1=replace_special_chars( encodeURI( $('#static_title h1').text() ) );
		$('#static_title').empty().append('<div id="flashTitle1"></div>');
		var flashvars1 = {
			fontPath: flashPath+"fonts/hcb.swf",
			text: titleText1,
			textSize: 15,
			headColor:'0x875713',
			textColor: '0xce8f23',
			//textColor: '0xffffff',
			//bgColor:'0xc0b447',
			bgAlpha: bgAlpha,
			margin: "0 0 0 0",
			//subText: subText,
			subTextSize: subTextSize,
			subTextColor: subTextColor,
			spacing:5,
              lang: 'ar'
		};
		var params1 = {
			menu: "false",
			scale: "noScale",
			allowFullscreen: "true",
			allowScriptAccess: "always",
			bgcolor: "#FFFFFF",
			wmode: "transparent"
		};
		var attributes1 = {
			id:"ab_homeFlashText_inner"
		};
		swfobject.embedSWF(flashPath+"HTMLTitle.swf", "flashTitle1", "728", "50px", "10.0.0", null, flashvars1, params1, attributes1);
	
	}

function rgb(R,G,B) {return "#"+toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}
		
//-------------------------------------------------
function replace_special_chars(string){
	return string.replace("&", "%26").replace("?", "%3F");
}// fun. replace_special_chars
