function toggleDisplay(el, theCaller) {
	eid = document.getElementById(el);
	cid = document.getElementById(theCaller);
	
	if (eid.style.display == 'none') {
		eid.style.display = '';
		cid.style.fontWeight = 'bold';
	} else {
		eid.style.display = 'none';
		cid.style.fontWeight = '';
	}
	
}


var previousHilightedElement = '';

function hilight(el) {
	var i = 0;
	
	if (previousHilightedElement != '') {
		document.getElementById(previousHilightedElement).className = 'hilightOff';
	}
	
	document.getElementById(el).className = 'hilightOn';
	
	// ...and then flicker
	setTimeout("document.getElementById('"+ el +"').className = 'hilightOff'", 310);
	setTimeout("document.getElementById('"+ el +"').className = 'hilightOn'", 370);
	setTimeout("document.getElementById('"+ el +"').className = 'hilightOff'", 410);
	setTimeout("document.getElementById('"+ el +"').className = 'hilightOn'", 470);
	
	previousHilightedElement = el;
}

function hilightSelect(el) {
	el.backgroundColor = '#fffcf0';
}

function unhilightSelect(el) {
	el.backgroundColor = '';
}


function smAtom(Type, Key, Description) {
	// class for possible <SELECT> entries
	
	this.Type = Type;
	this.Key = Key;
	this.Description = Description;;
}

function smUrl(Code, Url) {
	// class for possible <SELECT> combinations and their destinations
	
	this.Code = Code;
	this.Url = Url;
}

function smObject() {
	// class to hold the current combination.
	// only want one instance of this; a global of sorts.
	
	this.Platform = '';
	this.Target = '';
	this.Product = '';
	this.Version = '';
	this.Topic = '';
	this.rex = '.*';	// regex for filtering valid combinations using the code used in URLs[].Code
}

function populateSelect(SelectList, Type, Filter) {
	// fills a <SELECT>
	// items only get added to the <SELECT> if
	
	var i;
	var j = 0;
	var validKeys = new Array();
	var matches = new Array();
	
	// filter by regex
	for (i = 0; i < URLs.length; i++) {
		re = new RegExp(smSelection.rex);
		matches = re.exec(URLs[i].Code);
		if (matches != undefined) {
			if (matches[1] != undefined) {
				validKeys.push(matches[1]);
			}
		}
	}
	
	// draw
	for (i = 0; i < Atoms.length; i++) {
		if (Atoms[i].Type == Type) {
			if ((!Filter) || inArray(validKeys, Atoms[i].Key)) {
				SelectList.options[j] = new Option(Atoms[i].Description);
				SelectList.options[j].value = Atoms[i].Key;
				j++;
			}
		}
	}
}

function inArray(arr, val) {
	// returns true if val is in arr[]
	
	var i;
	
	for (i = 0; i < arr.length; i++) {
		if (arr[i] === val)
			return true;
	}
	return false;	
}


function escapeForRegExp(s) {
	// makes chars in s safe for passing through a RegExp
	// eg. escape chars like +|*.
	
	re = /([\.\+\\\-\*\$\^])/g
	return s.replace(re, "\\$1");
}



function clearSelect(SelectList) {
	// remove every item, aka <OPTION>, in a <SELECT>
	
	var i;
	
	for (i = SelectList.options.length; i > 0; i--) {
		SelectList.options[i - 1] = null;
	}
}

function getUrlFromCode(Code) {
	// loop over URLs[] and return the .Url where .Code matches
	
	var i;
	
	for (i = 0; i < URLs.length; i++) {
		if (URLs[i].Code === Code)
			return URLs[i].Url;
	}
}

function jumpToLocation() {
	// check that we have a fully filled out smSelection()
	// build a Code from smSelection()s properties
	// get the URL for this Code and go to it
	
	var Code;
	
	if (smSelection.Product != '' &&
	    smSelection.Platform != '' &&
	    smSelection.Version != '' &&
	    smSelection.Target != '' &&
	    smSelection.Topic != '') {
		Code = smSelection.Product +','
		Code += smSelection.Version +','
		Code += smSelection.Platform +','
		Code += smSelection.Target +','
		Code += smSelection.Topic
		
		// alert(smSelection.Platform +"\n"+ smSelection.Target +"\n"+ smSelection.Product +"\n"+ smSelection.Version +"\n"+ smSelection.Topic +"\n"+ smSelection.rex);
		window.parent.location = getUrlFromCode(Code);
	}
}

/**
 * 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 ValidateRequestForm(){
	var emailID=document.reqform.email
	var nameID=document.reqform.name
	var phoneID=document.reqform.phone
	var replyprefid=document.reqform.replypref
	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
	}
	if ((nameID.value==null) || (nameID.value=="")){
		alert("Please Enter your name")
		nameID.focus()
		return false
	}
	
	if ((phoneID.value==null) || (phoneID.value=="")){
		alert("Please Enter your phone number")
		phoneID.focus()
		return false
	}
	

	getusertime();
	return true
 }
 
function getusertime(){
	var hours;
	var mins;
	var docid = document.reqform.time;
	Stamp = new Date();
	hours = Stamp.getHours();
	mins = Stamp.getMinutes();
	if(mins < 10){
		mins = "0"+mins;
	}
	docid.value=hours+":"+mins;
	
}
 


function adjustOptions(fl) {
	// this gets called by the onchange() of every <SELECT>
	// * updates smSelection()
	// * build a RegExp that gets used in populateSelect()
	// * clears <SELECT>s
	// * populates <SELECT>s
	// * hides/shows the GO button
	
	switch (fl.id) {
		case 'product':
			smSelection.Product = fl.options[fl.selectedIndex].value;
			smSelection.rex = '^'+ escapeForRegExp(smSelection.Product) +',([^,]+)';
			clearSelect(document.forms[0].version);
			clearSelect(document.forms[0].platform);
			clearSelect(document.forms[0].target);
			clearSelect(document.forms[0].topic);
			populateSelect(document.forms[0].version, 'version', true);
			document.forms[0].version.selectedIndex = -1;
			document.getElementById('submitButton').style.visibility = 'hidden';
			break;
	
		case 'version':
			smSelection.Version = fl.options[fl.selectedIndex].value;
			smSelection.rex = '^'+ escapeForRegExp(smSelection.Product) +',';
			smSelection.rex += escapeForRegExp(smSelection.Version) +',([^,]+)';
			clearSelect(document.forms[0].platform);
			clearSelect(document.forms[0].target);
			clearSelect(document.forms[0].topic);
			populateSelect(document.forms[0].platform, 'platform', true);
			document.forms[0].target.selectedIndex = -1;
			document.getElementById('submitButton').style.visibility = 'hidden';
			break;
			
		case 'platform':
			smSelection.Platform = fl.options[fl.selectedIndex].value;
			smSelection.rex = '^'+ escapeForRegExp(smSelection.Product) +',';
			smSelection.rex += escapeForRegExp(smSelection.Version) +',';
			smSelection.rex += escapeForRegExp(smSelection.Platform) +',([^,]+)';
			clearSelect(document.forms[0].target);
			clearSelect(document.forms[0].topic);
			populateSelect(document.forms[0].target, 'target', true);
			document.forms[0].target.selectedIndex = -1;
			document.getElementById('submitButton').style.visibility = 'hidden';
			break;	
			
		case 'target':
			smSelection.Target = fl.options[fl.selectedIndex].value;
			smSelection.rex = '^'+ escapeForRegExp(smSelection.Product) +',';
			smSelection.rex += escapeForRegExp(smSelection.Version) +',';
			smSelection.rex += escapeForRegExp(smSelection.Platform) +',';
			smSelection.rex += escapeForRegExp(smSelection.Target) +',([^,]+)';
			clearSelect(document.forms[0].topic);
			populateSelect(document.forms[0].topic, 'topic', true);
			document.forms[0].topic.selectedIndex = -1;
			document.getElementById('submitButton').style.visibility = 'hidden';
			
			switch (smSelection.Target) {
				case 'SW':
					document.getElementById('client-server_description').style.display = 'none';
					document.getElementById('empty_description').style.display = 'none';
					document.getElementById('workstation_description').style.display = '';
					break;
				case 'SCS':
					document.getElementById('workstation_description').style.display = 'none';
					document.getElementById('empty_description').style.display = 'none';
					document.getElementById('client-server_description').style.display = '';
					break;
				default:
					document.getElementById('empty_description').style.display = '';
					document.getElementById('workstation_description').style.display = 'none';
					document.getElementById('client-server_description').style.display = 'none';
					break;
				}
			break;
			
		case 'topic':
			smSelection.Topic = fl.options[fl.selectedIndex].value;
			document.getElementById('submitButton').style.visibility = 'visible';
			break;
	}
	
}

//
// instantiate those classes defined above.
//


// gets populated with smAtom()s in support_menu.js
var Atoms = new Array();

// gets populated with smUrl()s in support_menu.js too
var URLs = new Array();

// instantiate an smObject, there's only one of these for the whole page
var smSelection = new smObject();


// include the menu data script
document.write('<script type="text/javascript" language="JavaScript1.3" src="/inc/support_menu.js"></script>');
