/*** bookmark.js ***/

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}
/*** END bookmark.js ***/

/*** calculator.js ***/

function checkDot(str){
}
function checkNum(str)
{
var firstNumber;
var secondNumber;
var dotFlag=false;
        for (var i = 0; i < str.length; i++) {
                var ch = str.substring(i, i+1)
                if (ch == "+" || ch == "/" || ch == "-" || ch == "*" ) {
                   firstNumber=str.substring(0,str.indexOf(ch));
	secondNumber=str.substring(str.indexOf(ch)+1,str.length);
	firstNumber=firstNumber.substring(firstNumber.indexOf('.'),firstNumber.lastIndexOf('.'));
	secondNumber=secondNumber.substring(secondNumber.indexOf('.'),secondNumber.lastIndexOf('.'))
//		alert('First Number');		
//		alert(firstNumber);
//		alert('Second Number');
//		alert(secondNumber);
		if(firstNumber != 0 ){
//		alert('Evry thing not okay with number 1');
		alert('Invalid Pattern with first Number');
		//break;
		return false;
		}
	                    if(secondNumber != 0){
//		alert('Evry thing not okay with number 2');
		alert('Invalid Pattern with second Number');
//		break;
		return false;
		}
		
  }
        }
        return true
}

function checkOperator(str,operator)
{
var opr=operator;
        for (var i = 0; i < str.length; i++) {
                var ch = str.substring(i, i+1)
               if (ch == "+" || ch == "/" || ch == "-" || ch == "*"    ) {
		return false;
		
			}
		}
return true;
	}
function backSpace(str)
{
document.Calc.Input.value=str.substring(0,str.length-1);
	}
/*** END calculator.js ***/	
	
	
/*** CurrentDate.js ***/

function getCurrentDate()
{
	var mydate=new Date()
	var year=mydate.getYear()
	if (year < 1000)
	year+=1900
	var day=mydate.getDay()
	var month=mydate.getMonth()
	var daym=mydate.getDate()
	if (daym<10)
	daym="0"+daym
	var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	theDate =  dayarray[day] + ", " + montharray[month] + " "+ daym + ", "+year;
	return theDate;
	/*document.write(dayarray[day]+" "+daym+", "+montharray[month]+" "+year;)*/
}

function getCurrentDateArabic()
{
	var mydateAR=new Date()
	var yearAR=mydateAR.getYear()
	if (yearAR < 1000)
	yearAR+=1900
	var dayAR=mydateAR.getDay()
	var monthAR=mydateAR.getMonth()
	var daymAR=mydateAR.getDate()
	if (daymAR<10)
	daymAR="0"+daymAR
	var dayarrayAR=new Array("&#1575;&#1604;&#1571;&#1581;&#1583;","&#1575;&#1604;&#1573;&#1579;&#1606;&#1610;&#1606;","&#1575;&#1604;&#1579;&#1604;&#1575;&#1579;&#1575;&#1569;","&#1575;&#1604;&#1571;&#1585;&#1576;&#1593;&#1575;&#1569;","&#1575;&#1604;&#1582;&#1605;&#1610;&#1587;","&#1575;&#1604;&#1580;&#1605;&#1593;&#1577;","&#1575;&#1604;&#1587;&#1576;&#1578;")
	var montharrayAR=new Array("&#1610;&#1606;&#1575;&#1610;&#1585;","&#1601;&#1576;&#1585;&#1575;&#1610;&#1585;","&#1605;&#1575;&#1585;&#1587;","&#1571;&#1576;&#1585;&#1610;&#1604;","&#1605;&#1575;&#1610;&#1608;","&#1610;&#1608;&#1606;&#1610;&#1608;","&#1610;&#1608;&#1604;&#1610;&#1608;","&#1571;&#1594;&#1587;&#1591;&#1587;","&#1587;&#1576;&#1578;&#1605;&#1576;&#1585;","&#1571;&#1603;&#1578;&#1608;&#1576;&#1585;","&#1606;&#1608;&#1601;&#1605;&#1576;&#1585;","&#1583;&#1610;&#1587;&#1605;&#1576;&#1585;")
	theDateAR =  dayarrayAR[dayAR]+ ", " + montharrayAR[monthAR]+ " " + daymAR+ ", "+ yearAR;
	return theDateAR;
	/*document.write(dayarray[day]+" "+daym+", "+montharray[month]+" "+year;)*/
}
/*** END CurrentDate.js ***/

/*** fontSizeChanger.js ***/

function changeFontSize(titleFontSize, contentFontSize)
{
  //alert("Fonts received : " + titleFontSize + ", " + contentFontSize);
  //Get the Title element and set its new font size
  var contentTitleDIV = document.getElementById("inmaContentTitle");
  contentTitleDIV.style.fontSize = titleFontSize + "px";
  
  //Get the Content element and set its new font size
  var contentDIV = document.getElementById("inmaContent");
  contentDIV.style.fontSize = contentFontSize + "px";
  
  return;
}
/*** END fontSizeChanger.js ***/


/*** SendThisPageByMail.js  ***/

var path="";
function getMailtoText()
{
  var bodyText = 'Check this interesting news from Al Inma Bank ' + window.location + ' &#13;&#10;';
  document.getElementById('sendMailLink').href = 'mailto:?subject=Interesting Al Inma Bank News&body='+ bodyText;

}

function sendInmaWebsiteToFriend()
{
  var inmaWebsite = 'http://www.alinma.com';	
  var bodyText = 'Check Al Inma Bank website : ' + inmaWebsite + ' &#13;&#10;';
  document.getElementById('sendMailLink').href = 'mailto:?subject=Al Inma Bank website&body='+ bodyText;

}


function sendMailByWCM(mailPath)
{
  //var inmaWebsite = 'http://www.alinma.com';	
  //var bodyText = 'Check Al Inma Bank website : ' + inmaWebsite + ' &#13;&#10;';
  //document.getElementById('sendMailLink').href = 'mailto:?subject=Al Inma Bank website&body='+ bodyText;
  
  window.open(mailPath,"_blank",'height=600,width=385');

}

function getMail(contentLink)
{
	  var bodyMail = 'Check this interesting news from Al Inma Bank ' + contentLink + ' &#13;&#10;';
  document.getElementById('sendMailLink').href = 'mailto:?subject=Interesting Al Inma Bank News&body='+ bodyMail;

}


function printNews() {
  window.open(path,"_blank");
  //window.print();
}

function toolTipLinks(contentLink, contentPrint){
var position = contentLink.indexOf('+');
if (position == -1)
path=contentPrint;
else
path=contentPrint.substring(0, position) + contentPrint.substring(position);

	 var bodyMail1 = 'Check this interesting news from Al Inma Bank ' + contentLink + ' &#13;&#10;';
var test = '<tr><td><a href="#" onClick="printNews()">Print</a><td><a href=\'mailto:?subject=Interesting Al Inma Bank News&body= '+ bodyMail1 + '\'>Send to friend</a></td></tr>';

return test;
}


function toolTipLinksArabic(contentLink, contentPrint){
var position = contentLink.indexOf('+');
if (position == -1)
path=contentPrint;
else
path=contentPrint.substring(0, position) + contentPrint.substring(position);

	 var bodyMail1 = 'Check this interesting news from Al Inma Bank ' + contentLink + ' &#13;&#10;';
var test = '<tr><td><a href="#" onClick="printNews()">\u0627\u0637\u0628\u0639</a><td><a href=\'mailto:?subject=Interesting Al Inma Bank News&body= '+ bodyMail1 + '\'>\u0623\u0631\u0633\u0644\u0020\u0644\u0635\u062f\u064a\u0642</a></td></tr>';

return test;
}

//Added by Christina
function sendMail(contentLink,contentPrint) {
var position = contentLink.indexOf('+');
if (position == -1){
    path=contentPrint;
}
else
{
	path=contentPrint.substring(0, position) + contentPrint.substring(position);
}
  window.open(path,"_blank",'height=600,width=385');
//  window.print();

}


//Addded Yahya
function sendMailWithLocale(contentLink,contentPrint,language) {
var position = contentLink.indexOf('+');
if (position == -1){
    path=contentPrint;
}
else
{
	path=contentPrint.substring(0, position) + contentPrint.substring(position);
	
}
path = path + "&language=" +language;
var MyWidth = (window.screen.width/2)-(193);
var MyHeight = (window.screen.height/2)-(265+10);
//window.open(path,"_blank",'height=530,width=385,top='+MyHeight+',left='+MyWidth);
//alert("JS Function - path : " + path);
//alert("JS Function - pathToContent : " + pathToContent);
//alert("JS Function - URL : " + sendNewsToFriendURL +"?pathToContent=" + path);

//var thePath = '/wps/portal/alinma/rss/?WCM_GLOBAL_CONTEXT=/wps/wcm/connect/web+content/Inma/All+Pages/News/News9&PAGEDESIGN=Inma_NewsEmail_PT_en&language=en';

//window.location = sendNewsToFriendURL + "?thePath=" + path;
//window.location = path;
window.location = path;

//window.open(path,"_blank",'height=600,width=585');
}

//Addded Yahya
// This function is called when user clicks the "Send Mail" blue icon that appears always on the bottom right corener
// it will send an email with Al Inma Bank website addrees
function sendHomePageByEMail(language) {

var sendMailURL = "/Send_Mail/AlinmaMail.jsp"
var MyWidth = (window.screen.width/2)-(193);
var MyHeight = (window.screen.height/2)-(265+10);
sendMailURL = sendMailURL + "?language=" +language;
window.open(sendMailURL,"_blank",'height=530,width=385,top='+MyHeight+',left='+MyWidth);
}

//Added by Yahya
function printContent(contentLink,contentPrint) {
var position = contentLink.indexOf('+');
if (position == -1){
    path=contentPrint;
}else
{
	path=contentPrint.substring(0, position) + contentPrint.substring(position);
}
  window.open(path,"_blank",'height=700,width=800,resizable=1,scrollbars=yes,top=50,left=300');
//  window.print();

}

/*** End SendThisPageByMail.js  ***/

function changeFontSizeOnHomePage(fontSize)
{
  //alert("Home Page Font Size  : " + fontSize);
  //Get the Title element and set its new font size
  var homePageContent = document.getElementById("homePageContent");
  homePageContent.style.fontSize = fontSize + "px";
  return;
}

/*** END fontSizeChanger.js ***/

//Added by Ahmed

function getBrowserName(){
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	var is_safari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
	if(is_chrome)
		return is_chrome;
	if(is_safari)
		return is_safari;
}
