/************************************************************************************
Nigel Francois
Front-End Interface developer 2005
http://www.intro-net.co.uk
*************************************************************************************/

/************************************************************************************
DETECT BROWSER
*************************************************************************************/
// Check the browser...we're looking for ie/win, but not aol
var isIE5 	= 	(document.all && document.getElementById && navigator.appName.indexOf('Microsoft') != -1 && navigator.appVersion.indexOf('MSIE 5.0') != -1) ? true : false;
var isIE55 	= 	(document.getElementById && navigator.appName.indexOf('Microsoft') != -1 && navigator.appVersion.indexOf('MSIE 5.5') != -1) ? true : false;
var isIE6 	= 	(document.getElementById && navigator.appName.indexOf('Microsoft') != -1 && navigator.appVersion.indexOf('MSIE 6.0') != -1) ? true : false;
var isIE7 	= 	(document.getElementById && navigator.appName.indexOf('Microsoft') != -1 && navigator.appVersion.indexOf('MSIE 7.0') != -1) ? true : false;
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isSafari=	(navigator.userAgent.indexOf('Safari')!=-1) ? true : false;
var isMacIE =	(navigator.userAgent.indexOf('MSIE')!=-1 && navigator.userAgent.indexOf('Mac')!=-1) ? true : false;
var isGecko = 	(!document.all && document.getElementById) ? true : false;
var isOP=(
		  (navigator.appName.indexOf('Opera') != -1)
		  ||(navigator.plugins.length>0 && navigator.appName.indexOf('Microsoft') != -1)
		  ||(!navigator.product && navigator.appName.indexOf('Netscape') != -1)
		  )
var isWindows=(navigator.userAgent.toLowerCase().indexOf('win')!=-1) ? true : false;
var isMac=(navigator.userAgent.toLowerCase().indexOf('mac')!=-1) ? true : false;

var thisbrowser = 'unknown';

//FireFox PC AND MAC
if (isGecko)
{
	if(isMac)
	{
		document.write('<link rel="stylesheet" href="css/MacGeckostyle.css" type="text/css">');
//		alert('MacGeckostyle.css');
		thisbrowser = "MacGecko";
	}
	else
	{
		document.write('<link rel="stylesheet" href="css/Geckostyle.css" type="text/css">');
//		alert('Geckostyle.css');
		thisbrowser = "PCGecko";
	}
}

//IE 5 WINDOWS
if (isIE)
{
	thisbrowser = "IE";
	if(isIE5 && isWindows)
	{
		document.write('<link rel="stylesheet" href="css/IE5style.css" type="text/css">');
//		alert('IE5style.css');
		thisbrowser = "IE5 Windows";
	}

	//IE 5.5 WINDOWS
	if (isIE55)
	{
		thisbrowser = "IE";
		if(isIE55 && isWindows)
		{
			document.write('<link rel="stylesheet" href="css/IE55style.css" type="text/css">');
//			alert('IE55style.css');
			thisbrowser = "IE55 Windows";
		}
	}

	//IE 6 WINDOWS
	if (isIE6)
	{
		thisbrowser = "IE";
		if(isIE6 && isWindows)
		{
			document.write('<link rel="stylesheet" href="css/IE6style.css" type="text/css">');
//			alert('style.css');
			thisbrowser = "IE6 Windows";
		}
	}
	//MAC IE
		if(isMac)
		{
			document.write('<link rel="stylesheet" href="css/IEMacstyle.css" type="text/css">');
//			alert('IEMacstyle.css');
			thisbrowser = "IE Mac";
		}

}


//MAC SAFARI
if(isSafari)
{
	thisbrowser = "Safari";
	document.write('<link rel="stylesheet" href="css/safari.css" type="text/css">');
//		alert('safari.css');
}

document.write(''+
'<!--[if lt IE 6]>'+
'<style type="text/css" media="screen">'+
'		 * html .bannerlink    { color: expression((document.body.clientWidth < 778) ? "#cc0000" : "#cc0000" ); }'+
'   </style>'+
'<![endif]-->'+
'');
//alert(navigator.userAgent);

//alert(thisbrowser);

/* if tou want to support OPERA browser
if (isOP)
	{
	if(isWindows){
	var thisbrowser = 'Opera';
	isIE4=false;isIE5=false;isGecko=false;isIE=false;
	}
}
*/
/************************************************************************************
STORE CLINT VARIABLES
*************************************************************************************/
var displayText="";
var randomnumber1=0;
var randomnumber2=0;

/************************************************************************************
TEXT BANNER LINKS DATA ARRAY
syntax : URL|LINK_TEXT
The values are seperated by the | vertical line
URL is placed on the left and LINK_TEXT is placed on the right
*************************************************************************************/
var textArray= new Array(
"http://www2.americanexpress.kz/ru/page/Travel|ТУРИСТИЧЕСКИЕ УСЛУГИ",
"http://www2.americanexpress.kz/ru/page/PersonalCards|КАРТЫ",
"http://www2.americanexpress.kz/ru/page/TariffsFees|ЛЬГОТНЫЙ ПЕРИОД",
"http://www2.americanexpress.kz/ru/page/CardTypes|СТРАХОВАНИЕ"
);
/************************************************************************************
IMAGE BANNER LINKS DATA ARRAY
syntax : URL|IMAGE_URL|IMAGE_ALT_TEXT
The values are separated by the | vertical line
URL is placed on the left, IMAGE_URL is placed in the middle ( excluding [.jpg] ) and IMAGE_ALT_TEXT is placed on the right
*************************************************************************************/
var imgArray= new Array(
"http://www2.americanexpress.kz/ru/page/Travel|img1|ТУРИСТИЧЕСКИЕ УСЛУГИ",
"http://www2.americanexpress.kz/ru/page/PersonalCards|img2|КАРТЫ",
"http://www2.americanexpress.kz/ru/page/CardTypes|img3|СТРАХОВАНИЕ",
"http://www2.americanexpress.kz/ru/page/TariffsFees|img4|ЛЬГОТНЫЙ ПЕРИОД"
);
/************************************************************************************
ENSURES THAT THE LINK2 AND LINK3 RANDOM LINKS ARE NOT IDENTICAL
*10 = generate a random number between 1 and 10.
Change the value to reflect the quantity of items in the TEXT BANNER LINKS DATA ARRAY

-- 8 mar 2007 - changed the below to reflect an addition to the text array,
changed imgArray.length to textArray.length -- Jbuckley
*************************************************************************************/
if(imgArray.length > 1)
{
	while(randomnumber1==randomnumber2)
	{
		randomnumber1=Math.floor(Math.random()*textArray.length); 	//
		randomnumber2=Math.floor(Math.random()*textArray.length); 	//
	}
}

/************************************************************************************
DOCUMENT WRITE IMAGE BANNER LINK
*2 = generate a random number between 1 and 2.
Change the value to reflect the quantity of items in the IMAGE BANNER LINKS DATA ARRAY
*************************************************************************************/
function doBannerLink()
{
var randomnumber=Math.floor(Math.random()*imgArray.length); 	//
$bannerLink=imgArray[randomnumber].split("|")
document.write('<a href="'+($bannerLink[0])+'"><img src="images/banners/'+($bannerLink[1])+'.jpg" width="540" height="210" alt="'+($bannerLink[2])+'" title="'+($bannerLink[2])+'"></a>');
displayText+='<a href="'+($bannerLink[0])+'"><img src="images/banners/'+($bannerLink[1])+'.jpg" width="540" height="210" alt="'+($bannerLink[2])+'" title="'+($bannerLink[2])+'"></a>\n\n';
}
/************************************************************************************
DOCUMENT WRITE TEXT BANNER LINKS
*************************************************************************************/
function doTextLink(whichLink)
{
ie5Adjust="";
if(isIE5) ie5Adjust="style=\"display:block;padding:3px 0px 3px 0px;text-align:center\"";
if(whichLink==2)
	{
	$textLink=textArray[randomnumber1].split("|")
	document.write('<a href="'+($textLink[0])+'" class="bannerlink" '+(ie5Adjust)+'>'+($textLink[1])+'</a><span class="fixAccessLink"> | </span>');
	displayText+='<a href="'+($textLink[0])+'" class="bannerlink">'+($textLink[1])+'</a>\n\n';
	}
if(whichLink==3)
	{
	$textLink=textArray[randomnumber2].split("|")
	document.write('<a href="'+($textLink[0])+'" class="bannerlink" '+(ie5Adjust)+'>'+($textLink[1])+'</a><span class="fixAccessLink"> | </span>');
	displayText+='<a href="'+($textLink[0])+'" class="bannerlink">'+($textLink[1])+'</a>\n\n';
	}
}
/************************************************************************************
MAC FIX
Not used
The Mac was not loading the banner links so I gathered the HTML that the javascript
created for the BANNER LINKS into a variable called displayText.
A link was placed on the HTML page with a link to the below function to display the HTML.
*************************************************************************************/
function getLinks()
{
Mycc=document.getElementById("cc");
Mycc.innerText=displayText;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function change(id, newClass) {
	identity=document.getElementById(id);
	identity.className=newClass;
}

startList = function()
	{
for(i=0;i< document.links.length; i++){
	if(document.links[i].className.indexOf("cssMenu")!=-1){
		var startTag=""; var endTag="";
		var $width=180;
		if(isIE6)$width=100;
		{startTag="<table class='navbarTD' style='width:!+($width)+'px;cursor:hand' cellpadding=0 cellspacing=0 border=0><tr><td style='cursor:hand'>";endTag="</td></tr></table>"}
		document.links[i].innerHTML=startTag+(document.links[i].innerHTML)+endTag;
		document.links[i].onmousedown=function(){
			location.href=this.href;
			}
		document.links[i].onmouseover=function(){
			var thisMenu=eval('document.getElementById("'+(this.className)+'")');
			thisMenu.className="mainitemsOver";
			}
		document.links[i].onmouseout=function(){
			var thisMenu=eval('document.getElementById("'+(this.className)+'")');
			thisMenu.className="mainitems";
			}
		}
	}


	if (document.all || document.getElementById)
		{
		var cssdropdownRoot = document.getElementById("cssdropdown");
		if(cssdropdownRoot)
			{
			for (i=0; i<cssdropdownRoot.childNodes.length; i++)
				{
				var node = cssdropdownRoot.childNodes[i];
				if (node.nodeName=="LI")
					{
					node.onmouseover=function(){
						this.className="mainitemsOver";//+=" over";
						}
					node.onmouseout=function(){
						this.className="mainitems";//this.className.replace(" over", "");
						}
					}
				}
			}
		}
	}

function getMenuItem(URLtxt,URLlink,URLtarget)
{
document.write('<a href="'+(URLlink)+'" target="'+(URLtarget)+'">'+(URLtxt)+'<\/a>')
}

if (window.attachEvent)
window.attachEvent("onload", startList)
else
window.onload=startList;
