//Vertical Tabs on main page
var htabsIdString = "ntabs_news,ntabs_events,ntabs_inthenews";
var mtabsIdString = "mtabs_products,mtabs_solutions,mtabs_hotspot,mtabs_services,mtabs_support,mtabs_shopping";
var stabsIdString = "stabs_challenge,stabs_solution,stabs_components,stabs_benefits,stabs_whyec";

function tabsover(tabsIdString, tabindex, imgpath) {
	var thetabs = tabsIdString.split(",");
	x=document.getElementById(thetabs[tabindex]).src;
	theImage = x.substring(x.length-6, x.length-4);
	theImageType = x.substring(x.length-3, x.length);
	if (tabsIdString == htabsIdString) {
		//alert(document.getElementById(thetabs[tabindex] + '_content').style.display);
		if (document.getElementById(thetabs[tabindex] + '_content').style.display != "block") {
			document.getElementById(thetabs[tabindex]).src = imgpath + thetabs[tabindex] + '_over.' + theImageType;
		}
	} else {
		if (theImage != "on") {
			document.getElementById(thetabs[tabindex]).src = imgpath + thetabs[tabindex] + '_over.' + theImageType;
		}
	}
	return true;
}
function tabsout(tabsIdString, tabindex, imgpath) {
	var thetabs = tabsIdString.split(",");
	x=document.getElementById(thetabs[tabindex]).src;
	theImage = x.substring(x.length-6, x.length-4);
	theImageType = x.substring(x.length-3, x.length);
	if (tabsIdString == htabsIdString) {
		if (document.getElementById(thetabs[tabindex] + '_content').style.display != "block") {
			document.getElementById(thetabs[tabindex]).src = imgpath + thetabs[tabindex] + '_off.' + theImageType;
		}
	} else {
		if (theImage != "on") {
			document.getElementById(thetabs[tabindex]).src = imgpath + thetabs[tabindex] + '_off.' + theImageType;
		}	
	}
	return true;
}
function tabsclick(tabsIdString, tabindex, imgpath) {
	var thetabs = tabsIdString.split(",");
	x=document.getElementById(thetabs[tabindex]).src;
	theImageType = x.substring(x.length-3, x.length);	
	for (i=0; i<=thetabs.length; i++) {
		if (i == tabindex) {
			x.src = imgpath + thetabs[tabindex] + '_on.' + theImageType;
			document.getElementById(thetabs[tabindex] + '_content').style.display = "block";
		} else {
			document.getElementById(thetabs[i]).src = imgpath + thetabs[i] + '_off.' + theImageType;
			document.getElementById(thetabs[i] + '_content').style.display = "none";		
		}
	}
}
function tabson(tabsIdString, tabindex) {
	var thetabs = tabsIdString.split(",");
	x=document.getElementById(thetabs[tabindex]);
	theImageType = x.substring(x.length-3, x.length);	
	for (i=0; i<=thetabs.length; i++) {
		if (i == tabindex) {
			x.src = imgpath + thetabs[tabindex] + '_on.' + theImageType;
		} else {
			document.getElementById(thetabs[i]).src = imgpath + thetabs[i] + '_off.' + theImageType;
		}
	}
}

//Content Items highlight
function highlight (theObject, theCondition) {
	if (theCondition == 1) {
		switch(theObject.id) {
			case 'products':
				theColor = '#003158'
				theIndex = '01';
				//theBottom = document.getElementById('products_back');
				break;
			case 'solutions':
				theColor = '#004582'
				theIndex = '09';
				//theBottom = document.getElementById('solutions_back');
				break;
			case 'services':
				theColor = '#005aa8'
				theIndex = '07';
				//theBottom = document.getElementById('services_back');
				break;
			case 'support':
				theColor = '#007ceb'
				theIndex = '10';
				//theBottom = document.getElementById('support_back');
				break;
			case 'shopping':
				theColor = '#f24e9e'
				theIndex = '05';
				//theBottom = document.getElementById('shopping_back');
				break;
			default:
				theColor = '#f6f6f6'
				theIndex = '00';
				//theBottom = "";
		}
		var coll = theObject.getElementsByTagName("a");
		for (i=0; i<coll.length; i++) {
		    coll[i].style.color = "#fff";}

		theObject.style.backgroundImage = "url(images/menus/"+theIndex+"_menu_top.jpg)";
		theObject.style.backgroundPosition = "top right";
		theObject.style.backgroundRepeat = "no-repeat";
		theObject.style.backgroundColor = theColor;
		//theBottom.style.background = "url(images/menus/"+theIndex+"_menu_bottom.jpg) top left no-repeat;";
		//theObject.className = 'optionitem_hover';
	} else if (theCondition == 0) {
		var coll = theObject.getElementsByTagName("a");
				for (i=0; i<coll.length; i++) {
		    coll[i].style.color = "#636466";}
		theObject.style.backgroundColor = "#fff";
		theObject.style.backgroundImage = "";
		theObject.style.backgroundPosition = "";
		theObject.style.backgroundRepeat = "";
		//theBottom.style.background = "";
		//theObject.className = 'optionitem';
		//theObject.style.a.color = '#636466';

	}
}
//Highlight for news and events tabs
function highlight_tabs (theObject, theCondition) {
	if (theCondition == 1) {
		theColor = '#aaa'
		theObject.style.backgroundColor = theColor;
		theObject.style.color = "#fff";
		x = theObject.getElementsByTagName("a");
		x[0].style.color = "#fff";
	} else if (theCondition == 0) {
		theObject.style.backgroundColor = "";
		theObject.style.color = "#000";
		x = theObject.getElementsByTagName("a");
		x[0].style.color = "#000";
	}
}

//Linkportal functions
function linkportal(linkurl, linkname, event) {
	x = document.getElementById('linkframe');
	x.src = 'linkportal.php?url='+linkurl+'&amp;title='+linkname;
  y = document.getElementById('linkdiv');
	y.x = event.cleintX;
	y.y = event.clientY;
	y.width = "200px";
	y.height = "200px";
	y.style.visibility='visible';
}
function linkportalclose() {
	y = document.getElementById('linkdiv');
	y.width = "0px";
	y.height = "0px";	
	y.style.visibility='hidden';
}

//DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
function echeck(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1){
		 alert("Invalid E-mail ID");
		 return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		 alert("Invalid E-mail ID");
		 return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Invalid E-mail ID");
			return false;
	}
	 if (str.indexOf(at,(lat+1))!=-1){
			alert("Invalid E-mail ID");
			return false;
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Invalid E-mail ID");
			return false;
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
			alert("Invalid E-mail ID");
			return false;
	 }
	 if (str.indexOf(" ")!=-1){
			alert("Invalid E-mail ID");
			return false;
	 }
	 return true;
}
function ValidateForm(theform){
	var firstname = theform.firstname;
	if ((firstname.value==null)||(firstname.value=="")){
		alert("Please Enter your First Name");
		firstname.focus();
		return false;
	}

	var lastname = theform.lastname;
	if ((lastname.value==null)||(lastname.value=="")){
		alert("Please Enter your Last Name");
		lastname.focus();
		return false;
	}

	var emailID=theform.email;
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	return true;
}

//Collapsible content
function dsp(loc){
	 if(document.getElementById){
			var foc=loc.firstChild;
			foc=loc.firstChild.innerHTML?
				 loc.firstChild:
				 loc.firstChild.nextSibling;
			foc.innerHTML=foc.innerHTML=='+'?'-':'+';
			foc=loc.parentNode.nextSibling.style?
				 loc.parentNode.nextSibling:
				 loc.parentNode.nextSibling.nextSibling;
			foc.style.display=foc.style.display=='block'?'none':'block';
		}
}
function dsp2(loc, id){
	 if(document.getElementById){
			var foc=loc.firstChild;
			foc=loc.firstChild.innerHTML?
				 loc.firstChild:
				 loc.firstChild.nextSibling;
			foc.innerHTML=foc.innerHTML=='+'?'-':'+';
			foc=document.getElementById('p'+id);	 
			foc.style.display=foc.style.display=='block'?'none':'block';
		}
}
if(!document.getElementById)
   document.write('<style type="text/css"><!--\n'+
      '.dspcont{display:block;}\n'+
      '//--></style>');
