var bIsNN = navigator.userAgent.indexOf('Netscape')>-1;
var bIsOpera = navigator.userAgent.indexOf('Opera')>-1;
var bIsMac = navigator.userAgent.indexOf('Mac')>-1;
var bIsIE = (document.all)?!bIsOpera:false;

var	OperaBefore6
if (bIsOpera)
	OperaBefore6=parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("Opera")+6,navigator.userAgent.indexOf("Opera")+7))<6;
else
	OperaBefore6=false;


var	MacBefore5
if (bIsMac)
	MacBefore5 = parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5,navigator.userAgent.indexOf("MSIE")+6))<5;
else
	MacBefore5 = false

var IMG_CYCLE_PERIOD = 10000; // 10 seconds (10000 miliseconds) for full cycle of images.
function SetupImages()
{
	for (var i=0; i<ATypes.length; i++)
	{
		var imgName = "Img" + ATypes[i].id
		if (ATypes[i].img.length>0)
		{
			if ((x=MM_findObj(imgName))!=null)
				x.src=ATypes[i].img[0].toString();
		}
		else
			if ((x=MM_findObj(imgName))!=null)
				x.src="Images/spacer.gif";
		ATypes[i].PassedTime = (ATypes.length - i - 1) * (IMG_CYCLE_PERIOD/ATypes.length);
		ATypes[i].Period = IMG_CYCLE_PERIOD;
	}	
	window.setTimeout("RotateImages()",100)
}
function RotateImages()
{
	for (var typeID=0; typeID<ATypes.length; typeID++)
	{
		var imgName = "Img" + ATypes[typeID].id
		ATypes[typeID].PassedTime += 100;
		if (ATypes[typeID].PassedTime >= ATypes[typeID].Period)
		{
			ATypes[typeID].PassedTime = 0;
		
			ATypes[typeID].current += 1;
			if (ATypes[typeID].current >= ATypes[typeID].img.length)
				ATypes[typeID].current = 0;
			if ((x=MM_findObj(imgName))!=null)
			{
				if (ATypes[typeID].img[ATypes[typeID].current])
					x.src=ATypes[typeID].img[ATypes[typeID].current]
				else
					x.src="Images/spacer.gif";
			}
		}
	}
	window.setTimeout("RotateImages()",100)
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// resize/position main image properly to the page size - News page
function ResImNews()
{
	if ((x=MM_findObj('NewsContent'))!=null)
	{
		if ((y=MM_findObj('LeftStrip'))!=null)
		{
			var k = window.document.body.offsetHeight
			if (window.document.body.scrollHeight  && !(bIsMac && bIsIE))
				k = window.document.body.scrollHeight
			if (k<x.offsetHeight+229)
				k = x.offsetHeight+229
			if (x.scrollHeight && !(bIsMac && bIsIE))
				k = x.scrollHeight+229
			if (k>580)
				y.height=k
			if ((y=MM_findObj('BS'))!=null)
				if (y.height)
				{
					y.height++;
					y.height--;
				}
		}
	}
}

// resize/position main image properly to the page size
function ResIm()
{
	if ((x=MM_findObj('AboutDQContent'))!=null)
	{
		if ((y=MM_findObj('LeftStrip'))!=null)
		{
			var k = window.document.body.offsetHeight
			if (window.document.body.scrollHeight  && !(bIsMac && bIsIE))
				k = window.document.body.scrollHeight
			if (k<x.offsetHeight+174)
				k = x.offsetHeight+174
			if (x.scrollHeight && !(bIsMac && bIsIE))
				k = x.scrollHeight+174
			if (k>580)
				y.height=k
			if ((y=MM_findObj('BS'))!=null)
				if (y.height)
				{
					y.height++;
					y.height--;
				}
		}
	}
}


function ResYellowIm()
{
	
	var k = 0;
	if (window.document)
		if (window.document.body)
			k = window.document.body.offsetWidth-20;
	if (this.innerWidth != null && this.innerWidth != 'undefined')
		k = this.innerWidth;
	//if ((window.document.body.scrollWidth) && !(bIsMac && bIsIE) )
	//	k = window.document.body.scrollWidth
	if (k)
	{
		for (j = 1; j < 14; j++)
			if ((y=MM_findObj('YellowImg' + j))!=null)
					y.width=(k>842?k:842);
	}

	var l = 0;
	if (window.document)
		if (window.document.body)
			l = window.document.body.offsetHeight - (bIsMac?0:4);
	if (this.innerHeight != null && this.innerHeight != 'undefined')
		l = this.innerHeight;
	//if ((window.document.body.scrollHeight) && !(bIsMac && bIsIE) )
	//	l = window.document.body.scrollHeight
	if (l)
	{
		if ((y=MM_findObj('YellowImg12'))!=null)
					y.height=(l>580?l-550:30);
		/*if ((y=MM_findObj('YellowImgB'))!=null)
					y.height=(l>579?l-579:1);
		if ((y=MM_findObj('YellowImgC'))!=null)
		{
					if (k)
						y.width=(k>842?k-217:625);
					y.height=(l>579?l-579:1);
		}*/
	}
}


function ResImFAQ()
{
	if ((x=MM_findObj('Layer2'))!=null)
	{
		if ((y=MM_findObj('LeftStrip'))!=null)
		{
			var k = window.document.body.offsetHeight
			if (window.document.body.scrollHeight  && !(bIsMac && bIsIE))
				k = window.document.body.scrollHeight
			if (k<x.offsetHeight+210)
				k = x.offsetHeight+210
			if (x.scrollHeight && !(bIsMac && bIsIE))
				k = x.scrollHeight+210
			if (k>580)
				y.height=k
		}
	}
}

function ResImGrDes()
{
	if ((x=MM_findObj('Layer2'))!=null)
	{
		if ((y=MM_findObj('LeftStrip'))!=null)
		{
			/*var k = window.document.body.offsetHeight
			if (window.document.body.scrollHeight  && !(bIsMac && bIsIE))
				k = window.document.body.scrollHeight*/
			var k = 0;
			if (k<x.offsetHeight+211+89)
				k = x.offsetHeight+211+89
			if (x.scrollHeight && !(bIsMac && bIsIE))
				k = x.scrollHeight+211+89
			if (k>580)
			{
				y.height=k
				if ((y=MM_findObj('YellowBKG'))!=null)
					y.height=k-160
			}
			else
			{
				y.height=580
				if ((y=MM_findObj('YellowBKG'))!=null)
					y.height=420
			}
		}
	}
}


// resize/position image properly to the size of table of content on the Faqs page
function ResBGVert()
{
	if ((x=MM_findObj('FAQ_TOC'))!=null)
	{
		if ((y=MM_findObj('BGVert'))!=null)
		{
			var k = x.offsetHeight
			if (x.scrollHeight && !(bIsMac && bIsIE))
				k = x.scrollHeight
			y.height=(k+125)
		}
	}
}

function ResBGVert2()
{
	if ((x=MM_findObj('Layer2'))!=null)
	{
		if ((y=MM_findObj('BGVert'))!=null)
		{
			var k = x.offsetHeight
			if (x.scrollHeight && !(bIsMac && bIsIE))
				k = x.scrollHeight
			y.height=(k+4)
		}
	}
}

function ResFAQ()
{
	ResImFAQ();
	ResBGVert();
}

function ResGrDes()
{
	ResImGrDes();
	ResBGVert2();
}

function PortfSub(WTID,ClID)
{
	var strParam
	if (ClID)
		strParam = "client_id=" + ClID
	else
		strParam = "wt_id=" + WTID;
		
		wnd = window.open("PortfolioSub.asp?" + strParam, "PortfolioSub", 'height=458,width=538,left=100,top=10,location=no,menubar=no,titlebar=no,status=no,resizable=no,scrollbars=no')
		wnd.focus();
}

function PortfSubNew(WTID,ClID)
{
	var strParam
	if (ClID)
		strParam = "client_id=" + ClID
	else
		strParam = "wt_id=" + WTID;
		
		wnd = window.open("Portfolio.asp?" + strParam, "Portfolio", 'height=818,width=815,left=100,top=10,location=no,menubar=no,titlebar=no,status=no,resizable=no,scrollbars=no')
		wnd.focus();
}

var CurPos = -675;
function StartMove()
{
	if ((x=MM_findObj('TopStrip'))!=null)
		window.setTimeout("MoveImg()",100)
}
function MoveImg()
{
	if (CurPos<28)
		CurPos+=5
	else
		return;
	
	if ((obj=MM_findObj('TopStrip'))!=null)
	{
		if (obj.style)
			obj=obj.style;
		obj.left=CurPos;
		window.setTimeout("MoveImg()",10)
	}
}

if (bIsMac && bIsIE)
{
	if (MacBefore5)
		document.write("<style>.dpCaseStText {font-size: 10px; padding-bottom: 4px;} .dpCaseStud {width:104px;	padding-left: 8px; padding-bottom: 4px;} .CrDirectorText {	font-size: 10px; } </style>");
	else
		document.write("<style>.dpCaseStud {width:92px;	}</style>");
}
