// JavaScript Document
var height_flag=false;
var leftdivision_height=0;;
var centerdivision_height=0;
var rightdivision_height=0;

var libLoaded = false;
var htmlLoaded = false;

/*
Live Date Script- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use,
visit http://www.dynamicdrive.com
*/


var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='ffffff' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+dn
+"</b></font></small>"
/*
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
*/
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}





function openenterpriseWindow(url, name) {
  popupWin = window.open(url, name, 'resizable=no,toolbar=no,height=390,width=530')
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) 
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
	

function changeColor(id,color) {
	var i;
	for (i=1;i<=2;i++) {
		document.getElementById(id+i).style.backgroundColor = color;
	}
}

function changeColorTheme(id,color) {
	for (var i=1;i<=2;i++) {
		document.getElementById(id+i).style.backgroundColor = color;
	}
}


function toggleVisibility() 
{
 if(htmlLoaded == true && libLoaded == true)
 {
  var inc, endInc=arguments.length;
  for (inc=0; inc<endInc; inc+=2) 
  {
    var id = arguments[inc];
    if (arguments[inc+1] == 'hidden')param="hidden";
    else if(arguments[inc+1]=='visible')param="visible";
    if (document.getElementById) 
	  eval("document.getElementById(id).style.visibility = \"" + param + "\"");
    else
	{
      if (document.layers) 
        document.layers[id].visibility = param;
      else if (document.all) 
        eval("document.all." + id + ".style.visibility = \"" + param + "\"");
      }
   }
  }
}

//  this JS is used to open a window that looks like a pop-up 
function openPopUpWindow(file, windowName, width, height, scrollbars) {
	if ( ! windowName )
		windowName = "";

	if ( ! width )
		width = 600;

	if ( ! height )
		height = 400;

	if ( ! scrollbars )
		scrollbars = "Yes";
	if ( scrollbars === "Y" )
		scrollbars = "Yes";
	if ( scrollbars === "N" )
		scrollbars = "No";
	else
		scrollbars = "Yes";

	Win = open(file, windowName, 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,width=' + width + ',height=' + height + ',scrollbars=' + scrollbars);
	Win.focus();
}

//  this JS is used to open a window that looks like a pop-up
function newWindow(urlParam, nameParam, paParams) {
	paWindow = window.open(urlParam, nameParam, paParams)
}

/* function is called from body:onload to set the height of left sidebar and center content area */
function setDivHeightWidth()
{
	var cheight=getHeight("centerdivision");
	
	if ( document.getElementById("rightdivision") )
		rightdivision_height = getHeight("rightdivision");

	if ( document.getElementById("leftdivision") )
		leftdivision_height=getHeight("leftdivision");

	if(cheight>leftdivision_height)
		centerdivision_height=cheight;
	else
		centerdivision_height=leftdivision_height;

	if(rightdivision_height>centerdivision_height)
		centerdivision_height=rightdivision_height;

	if ( document.getElementById("leftdivision") )
		setHeight("leftdivision",centerdivision_height);

setHeight("centerdivision",centerdivision_height);

	if ( document.getElementById("rightdivision") ) {
		setHeight("rightdivision",centerdivision_height);
	}

	if ( ! document.getElementById("rightdivision") ) {
		// if no right nav, add width to center div
		var cWidth = 750;
		cWidth  = parseInt(cWidth) - document.getElementById("leftdivision").offsetWidth ;
		document.getElementById("centerdivision").style.width=cWidth+'px';
	}


	if ( ! document.getElementById("leftdivision") ) {
		// if no left  nav, add width to center div
		var cWidth = 750;
		cWidth  = parseInt(cWidth) - document.getElementById("rightdivision").offsetWidth ;
		document.getElementById("centerdivision").style.width=cWidth+'px';
	}
}

/* function is called to determine the height of specific div on the page
@Params:ID for the div
@returns:height of the div
*/
function getHeight(cont)
{
	h=document.getElementById(cont).offsetHeight;
	return h;	
}

/* function is called to set the height of specific div on the page
@Params:ID for the div
@Params:height that needs to be set for that div 
*/
function setHeight(cont,cheight)
{
	document.getElementById(cont).style.height=cheight+'px';
}

/* function is called to display the first level heading for the page.
   @Params:token -> This is an identifier which determines the image and the
                    hidden div which need to be displayed.
*/
function showSubLevel1(token) {
if(	document.getElementById(token+"-sublevel")) {
	if(	document.getElementById(token+"-sublevel").style.display=="none")
		{
			document.getElementById(token+"-sublevel").style.display="block";
			document.getElementById(token+"-solidline").style.display="none";
			h1=document.getElementById(token+"-sublevel").offsetHeight;
			leftdivision_height=leftdivision_height+h1;
			// Checking if height of left sidebar has become greater than center content div   
			if (leftdivision_height>centerdivision_height)
			{ 
			document.getElementById("leftdivision").style.height=leftdivision_height+'px';
			} 
			document.getElementById(token).style.backgroundImage='url(http://www.asil-inc.com/CSS/CSSImages/nav-arrow-down.gif)';
		} else {
			h1=document.getElementById(token+"-sublevel").offsetHeight;
			leftdivision_height=leftdivision_height-h1;
			document.getElementById(token+"-sublevel").style.display="none";
			document.getElementById(token+"-solidline").style.display="block";
			document.getElementById(token).style.backgroundImage='url(http://www.asil-inc.com/CSS/CSSImages/nav-arrow-right.gif)';
			if((leftdivision_height>centerdivision_height) )
			{
				document.getElementById("leftdivision").style.height=leftdivision_height+'px';
				document.getElementById("centerdivision").style.height=centerdivision_height+'px';
			} else {
				document.getElementById("leftdivision").style.height=centerdivision_height+'px';
				document.getElementById("centerdivision").style.height=centerdivision_height+'px';
				if ( document.getElementById("rightdivision") )
					document.getElementById("rightdivision").style.height=centerdivision_height+'px';
			}
		}
	}
}


/* Function is called to display the second level heading for the page.
   It also makes sure that the height of the left sidebar alters to keep
   all the information in leftsidebar div(once the height of the left sidebar
   becomes more than the center division)
   @Params:token -> This is an identifier which determines the image and the
                    hidden div which need to be displayed.
*/
function showSubLevel2(token)
{
// Checking if the div needs to be expanded or collapsed
	if(	document.getElementById(token+"-sublevel")) {
		if(	document.getElementById(token+"-sublevel").style.display=="none")
		{
			document.getElementById(token+"-sublevel").style.display="block";
			h1=document.getElementById(token+"-sublevel").offsetHeight;
			leftdivision_height=leftdivision_height+h1;
			// Checking if height of left sidebar has become greater than center content div   
			if (leftdivision_height>centerdivision_height)
			{ 
				height_flag=true;
				document.getElementById("leftdivision").style.height=leftdivision_height+'px';
			} 
			document.getElementById(token+"-image").src="http://www.asil-inc.com/CSS/CSSImages/nav-collapse.gif";
		} else {
			h1=document.getElementById(token+"-sublevel").offsetHeight;
			leftdivision_height=leftdivision_height-h1;
			document.getElementById("leftdivision").style.display='none';
			document.getElementById(token).style.display='block';
			document.getElementById(token+"-sublevel").style.display='none';
			document.getElementById(token+"-image").src="http://www.asil-inc.com/CSS/CSSImages/nav-expand.gif";
			if(height_flag || (leftdivision_height>centerdivision_height) )
			{
				document.getElementById("leftdivision").style.height=leftdivision_height+'px';
				height_flag=false;
			} else {
				document.getElementById("leftdivision").style.height=centerdivision_height+'px';
				document.getElementById("centerdivision").style.height=centerdivision_height+'px';
				if ( document.getElementById("rightdivision") )
					document.getElementById("rightdivision").style.height=centerdivision_height+'px';
			}
			document.getElementById("leftdivision").style.display='block';
		}
	}
}
function select_country_option( form ) {
	with ( form.country_url ) {
		if ( options[options.selectedIndex].value != "" ) {
			location.href = options[options.selectedIndex].value;
		}
	}
	return true;
}

function get_contact_value()
{
for (var i=0; i < document.contactform.contact.length; i++)
   {
   if (document.contactform.contact[i].checked)
      {
      var contact_val = document.contactform.contact[i].value;
	  window.location.href = contact_val;
      return false;
      }
   }
}


libLoaded=true;
htmlLoaded=true;