/*jQuery Marquee*/
$(document).ready(function() {

	//this is the useful function to scroll a text inside an element...

	function startScrolling(scroller_obj, velocity, start_from){
		//bind animation to the children inside the scroller element
		scroller_obj.children().bind('marquee', function(event,c) {
			//text to scroll
			var ob = $(this);
			//scroller width
			var sw = parseInt(ob.parent().width());
			//text width
			var tw = parseInt(ob.width());
			//text left position relative to the offset parent
			var tl = parseInt(ob.position().left);
			//velocity converted to calculate duration
			var v  = velocity>0 && velocity<100 ? (100-velocity)*100 : 5000;
			//same velocity for different text's length in relation with duration
			var dr = (v*tw/sw)+v;
			//is it scrolling from right or left?
			switch(start_from){
			case 'right':
				//is it the first time?
				if(typeof c == 'undefined'){
					//if yes, start from the absolute right
					ob.css({ left: sw });
					sw = -tw;
				}else{
					//else calculate destination position
					sw = tl - (tw + sw);
				};
				break;
			default:
				if(typeof c == 'undefined'){
					//start from the absolute left
					ob.css({ left: -tw });
				}else{
					//else calculate destination position
					sw += tl + tw;
				};
			}
			//attach animation to scroller element and start it by a trigger
			ob.animate(	{left:sw},
						{	duration:dr,
							easing:'linear',
							complete:function(){ob.trigger('marquee');},
							step:function(){
								//check if scroller limits are reached
								if(start_from == 'right'){
									if(parseInt(ob.position().left) < -parseInt(ob.width())){
										//we need to stop and restart animation
										ob.stop();
										ob.trigger('marquee');
									};
								}else{
									if(parseInt(ob.position().left) > parseInt(ob.parent().width())){
										ob.stop();
										ob.trigger('marquee');
									};
								};
							}
						});
		}).trigger('marquee');
		//pause scrolling animation on mouse over
		scroller_obj.mouseover(function(){
			$(this).children().stop();
		});
		//resume scrolling animation on mouse out
		scroller_obj.mouseout(function(){
			$(this).children().trigger('marquee',['resume']);
		});
	};

	//the main app starts here...

	//change the cursor type for each scroller
	$('.scroller').css("cursor","pointer");

	//settings to pass to function
	var scroller			= $('.scroller');	// element(s) to scroll
	var scrolling_velocity 	= 40; 				// 1-99
	var scrolling_from 		= 'right';			// 'right' or 'left'

	//call the function and start to scroll..
	startScrolling( scroller, scrolling_velocity, scrolling_from );

	//create a new scroller but it starts from left...
	$('#arScroller').css("cursor","pointer");
	startScrolling( $('#arScroller'), 40, 'left');

});


// Text Blink EFX
var flashlinks=new Array()

function changelinkcolor(){
for (i=0; i< flashlinks.length; i++){
var flashtype=document.getElementById? flashlinks[i].getAttribute("flashtype")*1 : flashlinks[i].flashtype*1
var flashcolor=document.getElementById? flashlinks[i].getAttribute("flashcolor") : flashlinks[i].flashcolor
if (flashtype==0){
if (flashlinks[i].style.color!=flashcolor)
flashlinks[i].style.color=flashcolor
else
flashlinks[i].style.color=''
}
else if (flashtype==1){
if (flashlinks[i].style.backgroundColor!=flashcolor)
flashlinks[i].style.backgroundColor=flashcolor
else
flashlinks[i].style.backgroundColor=''
}
}
}

function init(){
var i=0
if (document.all){
while (eval("document.all.flashlink"+i)!=null){
flashlinks[i]= eval("document.all.flashlink"+i)
i++
} 
}
else if (document.getElementById){
while (document.getElementById("flashlink"+i)!=null){
flashlinks[i]= document.getElementById("flashlink"+i)
i++
}
}
setInterval("changelinkcolor()", 400)
}

if (window.addEventListener)
window.addEventListener("load", init, false)
else if (window.attachEvent)
window.attachEvent("onload", init)
else if (document.all)
window.onload=init
// End Text Blink EFX

function ExternalLinks(myLink)
{
	popup1=window.open(myLink,'_blank','');
	window.scroll(0,0);
}

function PrivacyPolicy()
{
	popup1=window.open('English/AboutUs/Policy.html','_blank','alwaysraised=yes,scrollbars=yes,titlebar=no,top=' + (screen.height - 600)/2 + ',left=' + (screen.width - 700)/2 + ',width=700,height=600');
	window.scroll(0,0);
}

function StayAnimated(idtag)
{
if (document.all && idtag != "") {document.images[idtag].src = document.images[idtag].src;}
}

 function webMail()
  {
	popup1=window.open('https://mail.riyadbank.com','_blank','');
  }
 
function PrivacyPolicy_ar()
{
	popup1=window.open('Arabic/AboutUs/Policy.html','_blank','alwaysraised=yes,scrollbars=yes,titlebar=no,top=' + (screen.height - 600)/2 + ',left=' + (screen.width - 700)/2 + ',width=700,height=600');
	window.scroll(0,0);
}






