var fileLoadingImage;
function init()
{
	//detectbrowser();	
}
function browserdetect()
{
	if((navigator.appVersion.indexOf("MSIE 6")!= -1) || (navigator.appName.toLowerCase() == "opera"))
	{
		//alert("IE 7.0");
		document.getElementById('contentwrapper').className = "contentWrapper_IEopera";
	}
	else
	{
		//alert("FF");
	}
}
//////////////////

function showlayer(obj1)
{
	var ele_visibibility = document.getElementById(obj1).style.display;
	if(ele_visibibility == "none")
	{
		document.getElementById(obj1).style.display ='';
	}
	else	
	{
		document.getElementById(obj1).style.display ='none';
	}
}

/////////////////

//////////////////

function showlayer2(obj1)
{
	var ele_visibibility = document.getElementById(obj1).style.display;
	if(ele_visibibility == "none")
	{
		document.getElementById(obj1).style.display ='';
	}
}

/////////////////


function tan_showlayer(obj1, obj2)
{
	if(document.title!='MindTree | Sitemap')
	{
		var ele_visibibility = document.getElementById(obj1).style.display;
		if(ele_visibibility == "none")
		{
			document.getElementById(obj1).style.display ='';
			document.getElementById(obj2).src='../images/ico_on1.gif';
		}
		else	
		{
			document.getElementById(obj1).style.display ='none';
			document.getElementById(obj2).src='../images/ico_off1.gif';
		}
	}
	else 
	{
		var ele_visibibility = document.getElementById(obj1).style.display;
		if(ele_visibibility == "none")
		{
			document.getElementById(obj1).style.display ='';
			document.getElementById(obj2).src='../images/ico_on1.gif';
		}
		else	
		{
			document.getElementById(obj1).style.display ='none';
			document.getElementById(obj2).src='../images/ico_off1.gif';
		}
	}
}
function tan_showlayer1(obj1, obj2)
{
	var ele_visibibility = document.getElementById(obj1).style.display;
	if(ele_visibibility == "none")
	{
		document.getElementById(obj1).style.display ='';
		document.getElementById(obj2).src='../images/ico_on1.gif';
	}
	else	
	{
		document.getElementById(obj1).style.display ='none';
		document.getElementById(obj2).src='../images/ico_off1.gif';
	}
}
function navigate(obj)
{
	var selIndex = document.getElementById(obj).selectedIndex;
	var selectedpage = document.getElementById(obj).options[selIndex].value;
	window.location = selectedpage;
}
function detectbrowser()
{
	if(navigator.appName != "Microsoft Internet Explorer")
	{
		//document.getElementById('geckospecific').style.display = "";
		//document.getElementById('iespecific').style.display = "none";
		document.getElementById('spagensbrd').style.display = "";
		document.getElementById('disspageie').style.display = "none";
		init_ff();
	}
	else
	{
		//document.getElementById('geckospecific').style.display = "none";
		//document.getElementById('iespecific').style.display = "";
		document.getElementById('disspageie').style.display = "";
		document.getElementById('spagensbrd').style.display = "none";
		initscroll();
	}
}
var pageWidth = 0;
var pageHeight = 0;
var windowWidth = 0;
var windowHeight = 0;

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	
}
//Adds a dynamic layer
//Code from-Multimediastudio Ltd (http://www.multimediastudio.com)
function buildhtml1(obj, imgname, w, h, imgmap)
{
	var ele_body = document.getElementById("largeimage");
	ele_body.innerHTML = "";
	var div_wrapper = document.createElement("div");
	var fileLoadingImage = "../../images/preloader.gif";	
	var var_imagemap = "#" + imgmap;
	div_wrapper.id = "imagewrapper";
	div_wrapper.className = "wrapper2";
	div_wrapper.onclick = function() {
		document.getElementById('largeimage').style.display = "none";
		document.getElementById('loading').style.display = "none";
		document.getElementById('industryservices').style.display = "";
	}
	div_wrapper.style.width = parseInt(pageWidth) + "px";
	if(document.title=="MindTree | R&D Services" || document.title=="MindTree | IT Services")
	{
	div_wrapper.style.height = parseInt(pageHeight) + 49 + "px";
	}
	else
	{
		div_wrapper.style.height = parseInt(pageHeight) + "px";
	}
	ele_body.appendChild(div_wrapper);
	
	var div_wrapper1 = document.createElement("div");
	
	//div_wrapper1.style.backgroundColor = "#FFFFFF";
	div_wrapper1.id = "imagewrapper1";
	div_wrapper1.className = "wrapper3";
	//div_wrapper1.innerHTML = "";
	/*if(document.title=="MindTree | R&D Services" || document.title=="MindTree | IT Services")
	{
	document.getElementById('scrollbox').style.display='none';
	
	}*/
	div_wrapper1.innerHTML = document.getElementById('preloader').innerHTML;
	
	ele_body.appendChild(div_wrapper1);
	setTimeout(function() { buildhtml(obj, imgname, w, h, imgmap)},1000);
	if(navigator.appName != "Microsoft Internet Explorer")
	{
		if(window.pageYOffset > 0)
		{
			div_wrapper1.style.top = parseInt(windowHeight/2) + parseInt(window.pageYOffset) - 36 + "px";
		}
		else
		{
			div_wrapper1.style.top = parseInt(windowHeight)/2 - 36 + "px";
		}
	}
	else
	{
		if(document.documentElement.scrollTop > 0)
		{
			div_wrapper1.style.top = parseInt(windowHeight)/2 + parseInt(document.documentElement.scrollTop) - 36 + "px";
		}
		else
		{
			div_wrapper1.style.top = parseInt(windowHeight)/2 - 36 + "px";
		}
	}
	div_wrapper1.style.left = parseInt(windowWidth)/2 - 36 + "px";
}
function buildhtml(obj, imgname, w, h, imgmap)
{
	var ele_body = document.getElementById("largeimage");
	ele_body.innerHTML = " ";
	var div_wrapper = document.createElement("div");
	var fileLoadingImage = "../images/preloader.gif";	
	var var_imagemap = "#" + imgmap;
	div_wrapper.id = "imagewrapper";
	div_wrapper.className = "wrapper2";
	div_wrapper.onclick = function() {
		document.getElementById('largeimage').style.display = "none";
		document.getElementById('industryservices').style.display = "";
	}
	div_wrapper.style.width = parseInt(pageWidth) + "px";
	if(document.title=="MindTree | R&D Services" || document.title=="MindTree | IT Services")
	{
	div_wrapper.style.height = parseInt(pageHeight) + 49 + "px";
	}
	else
	{
		div_wrapper.style.height = parseInt(pageHeight) + "px";
	}
	ele_body.appendChild(div_wrapper);
	
	var div_wrapper1 = document.createElement("div");
	
	//div_wrapper1.style.backgroundColor = "#FFFFFF";
	div_wrapper1.id = "imagewrapper1";
	div_wrapper1.className = "wrapper1";
	//alert("hello");
	div_wrapper1.innerHTML= document.getElementById(obj).innerHTML;
	if(navigator.appName != "Microsoft Internet Explorer")
	{
		if(window.pageYOffset > 0)
		{
			div_wrapper1.style.top = parseInt(windowHeight/2) + parseInt(window.pageYOffset) - parseInt(h)/2 + "px";
		}
		else
		{
			div_wrapper1.style.top = parseInt(windowHeight)/2 - parseInt(h)/2 + "px";
		}
	}
	else
	{
		if(document.documentElement.scrollTop > 0)
		{
			div_wrapper1.style.top = parseInt(windowHeight)/2 + parseInt(document.documentElement.scrollTop) - parseInt(h)/2 + "px";
		}
		else
		{
			div_wrapper1.style.top = parseInt(windowHeight)/2 - parseInt(h)/2 + "px";
		}
	}
	div_wrapper1.style.left = parseInt(windowWidth)/2 - parseInt(w)/2 + "px";
	ele_body.appendChild(div_wrapper1);
}
function tan_displaylargeimage(obj, imgname, w, h, imgmap)
{
		if(navigator.appName == "Microsoft Internet Explorer")
			{
				setTimeout(function() { time1(obj, imgname, w, h, imgmap)},3);
			}
			else
			{
				 time1(obj, imgname, w, h, imgmap);
			}

}

function time1(obj, imgname, w, h, imgmap)
{
	if(document.getElementById('imagewrapper1'))
	{
		document.getElementById('largeimage').style.display = "";
		document.getElementById('industryservices').style.display = "none";
		buildhtml1(obj, imgname, w, h, imgmap);
	}
	else
	{
		document.getElementById('industryservices').style.display = "none";
		buildhtml1(obj, imgname, w, h, imgmap);
	}
}


function closeimg() {
		document.getElementById('largeimage').style.display = "none";
		document.getElementById('industryservices').style.display = "";
	/*if(document.title=="MindTree | R&D Services" || document.title=="MindTree | IT Services")
	{
	document.getElementById('scrollbox').style.display='';
	initHS3();
	}*/
	}
function preloader() 
{
getPageSize();
//fileLoadingImage = new Image(); 
//fileLoadingImage.src = "../images/preloader.gif";
//fileLoadingImage1 = new Image(); 
//fileLoadingImage1.src = "../../images/preloader.gif";
if(document.getElementById('clicktoenlarge'))
	{
	document.getElementById('clicktoenlarge').style.display = "";
	}
	if(document.getElementById('clicktoenlarge1'))
	{
	document.getElementById('clicktoenlarge1').style.display = "";
	}

if(document.title=="MindTree | R&D Services" || document.title=="MindTree | IT Services" )
	{
	initHS3();
	}
}

function directsearchpage()
{
	//alert("hello world");
	window.location = "http://www.mindtree.com/searchresults.html";
}
//window.onload = preloader;
window.onload = function() {
	preloader();
}

function initHS3(){
var scroll1=document.getElementById("scroller1");

for(var j=0;j<myImages.length;j++){

scroll1.innerHTML+='<img id="pic'+j+'" src="'+preload[j].src+'" alt="'+myImages[j][2]+'" title="'+myImages[j][2]+'">'

if(imageSize!=0){ // use percentage size
newWidth=preload[j].width/100*imageSize;
newHeight=preload[j].height/100*imageSize;
}
else{ // use fixed size
newWidth=fixedWidth;
newHeight=fixedHeight;
}

document.getElementById("pic"+j).style.width=newWidth+"px"
document.getElementById("pic"+j).style.height=newHeight+"px"

if(document.getElementById("pic"+j).offsetHeight>biggest){
biggest=document.getElementById("pic"+j).offsetHeight;
}

document.getElementById("pic"+j).style.marginLeft=spacerWidth+"px";

totalWidth+=document.getElementById("pic"+j).offsetWidth+spacerWidth;

}

totalWidth+=1;

for(var k=0;k<myImages.length;k++){ // vertically center images
document.getElementById("pic"+k).style.marginBottom = (biggest-document.getElementById("pic"+k).offsetHeight)/2+"px";
}

if(document.getElementById&&document.all){
ieBorder=parseInt(document.getElementById("scrollbox").style.borderTopWidth)*2;
}

document.getElementById("scrollbox").style.height=biggest+ieBorder+"px";
scroll1.style.width=totalWidth+"px";
var scroll2=document.getElementById("scroller2");
scroll2.innerHTML=scroll1.innerHTML;
scroll2.style.left= (-scroll1.offsetWidth)+"px";
scroll2.style.top= -scroll1.offsetHeight+"px";
scroll2.style.width=totalWidth+"px";

if(dir==1){
speed= -speed;
}
scrollHS3()
}

