var is_dom1 = (document.getElementById); //dom1
var is_docAll = (document.all && !document.getElementById); //ie4
var is_docLyr = (document.layers); //netscape4
var is_noDhtml = (!is_dom1 && !is_docAll && !is_docLyr); //no dhtml
var layerObj;
var layerShow='visible';
var layerHide='hidden';

var highlightcolor="EFF3FF"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/


// Open a new page function, called from Javascript menus
function Go(idx)
{
	if (mA[idx][5] !="") {
		OpenWindow("main.asp?page=" + mA[idx][0], mA[idx][5], 400, 300)
	} else {
		location.href = "main.asp?page=" + mA[idx][0];
	}
}

// For backward compatibility with older sites
function GetPage(page, parent, window, target)
{
	location.href = "main.asp?page=" + page;
}

// Standard function to open pages in a new window
function OpenWindow(URL, name, width, height)
{
	var width_add, height_add;
	width = Number(width);
	height = Number(height);
	width_add = 20;
	height_add = 70;
	width = width + width_add;
	height = height + height_add;
	//alert(width);
	win = window.open(URL, name, "scrollbars=yes,width=" + width + ",height=" + height);
	win.focus();
}

// Standard function to open pages in a new window
function OpenPriceWindow(URL, name, width, height)
{
	var width_add, height_add;
	width = Number(width);
	height = Number(height);
	width_add = 0;
	height_add = 50;
	width = width + width_add;
	height = height + height_add;
	//alert(width);
	win = window.open(URL, name, "scrollbars=yes,width=" + width + ",height=" + height);
	win.focus();
}

function newShowHideLayer(layerName, showOrHide, fromRight, fromTop)
{
	if(is_docAll)
	{
		layerObj = document.all(layerName).style;
		if (document.all('flash1'))
			flashObj = document.all('flash1').style;
		else
			flashObj = null;
	}
	else if(is_docLyr)
	{
		layerObj = document.layers[layerName];
		if (document.layers['flash1'])
			flashObj = document.layers['flash1'];
		else
			flashObj = null;
		layerShow = 'show';
		layerHide = 'hide';
	}
	else if(is_dom1)
	{
		layerObj = document.getElementById(layerName).style;
		if(document.getElementById('flash1'))
			flashObj = document.getElementById('flash1').style;
		else
			flashObj = null;
	}
	
	layerObj.right = fromRight;
	layerObj.top = fromTop;

	if(layerObj.visibility == layerShow || showOrHide == 'hide')
	{
  		layerObj.visibility = layerHide;
		if(flashObj)
			flashObj.visibility = layerShow;
	}
	else
	{
		if(flashObj)
			flashObj.visibility = layerHide;
		layerObj.visibility = layerShow;
	}
}

function service_keyword(character)
{
	url = '/main.asp?page=10&letter=' + character;
	window.azIndexFrame.location.href = url;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


//Function to check whether element clicked is form element
function checkel(which)
{
	if (which.style&&intended.test(which.tagName))
	{
		if (ns6&&eventobj.nodeType==3)
			eventobj=eventobj.parentNode.parentNode
		return true
	}
	else
		return false
}

//Function to highlight form element
function highlight(e)
{
	eventobj=ns6? e.target : event.srcElement
	if (previous!='')
	{
		if (checkel(previous))
			previous.style.backgroundColor=''
		previous=eventobj
		if (checkel(eventobj))
			eventobj.style.backgroundColor=highlightcolor
	}
	else
	{
		if (checkel(eventobj))
			eventobj.style.backgroundColor=highlightcolor
		previous=eventobj
	}
}



//Flash function to pause flash player
function stopFlash()
{
	
	var flashObj;
	
	if(is_docAll)
	{
		
		flashObj = document.all('flashhomepage');
	}
	else if(is_dom1)
	{
		flashObj = document.getElementById('flashhomepage');
	}

	bw = new lib_bwcheck()
	if(!bw.mac && !bw.ns6 && !bw.ns4)
	{
		if(flashObj)
		{
			flashObj.GotoFrame(47);
		}
	}
	
	
}


function lib_bwcheck()
{ 
  this.ver=navigator.appVersion
  this.agent=navigator.userAgent
  this.dom=document.getElementById?1:0
  this.opera5=this.agent.indexOf("Opera 5")>-1
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  this.ie=this.ie4||this.ie5||this.ie6
  this.ielayer=this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
  this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
  return this
}

var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	strHeight = strHeight + 30;
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function checkSearch()
{
	if (document.searchform.terms.value == '')
	{
		document.searchform.terms.value = 'Enter Keyword';
	}
}