function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// resize fix for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var cur_lyr;	// holds id of currently visible layer

// 2006/12/05 revised by Betty.  
function get_css(id)  {
	
	if (window.navigator.userAgent.indexOf("MSIE")>=1){
		document.getElementById(id).style.marginTop = "0px";	

	}else if (window.navigator.userAgent.indexOf("FIREFOX")>=1){
		document.getElementById(id).style.marginTop = "0px";
		document.getElementById("topmargin").style.marginTop = "-12px";
		document.getElementById("lyr2").style.marginTop = "-12px";
	}else
	{
		document.getElementById("lyr1").style.marginTop = "-12px";
		document.getElementById("lyr2").style.marginTop = "-12px";
	}

  swapLayers(id);
}

function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "block";
  
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "none";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0)
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}


///footer positoin ////

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('container').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			var footerTop = footerElement.offsetTop
			if (footerTop+footerHeight<windowHeight){
				footerElement.style.position = "absolute";
				footerElement.style.top = windowHeight-footerHeight;
			}
		}
	}
}
window.onload = function() {
	//setFooter();
}
window.onresize = function() {
	//setFooter();
}


// General Function
function ChangePage(xform,page)	{
	var browser_type = "";
	if (window.navigator.userAgent.indexOf("Firefox")>=1){
		browser_type = "ff";
	}else{
		browser_type = "ie";
	}
	if (browser_type=="ff"){
		slen = document.forms.length;
		for(i=0;i<slen;i++){
			if(document.forms[i].getAttribute("name")==xform){
				MyObj = document.forms[i];
			}
		}
		MyObj.page.value = page;
		MyObj.submit();
	}else{
		MyObj = eval(xform);
		MyObj.submit();
	}
	MyObj = eval(xform);
  	MyObj.page.value = page;
  	MyObj.submit();
}

function OpenDiv(rno){
	var browser_type = "";
	if (window.navigator.userAgent.indexOf("Firefox")>=1){
		browser_type = "ff";
	}else{
		browser_type = "ie";
	}
	if (browser_type=="ff"){
		var RegionDivs = new Array();
		div_objs = document.getElementsByTagName("div");
		slen = div_objs.length;
		div_num = 0;
		for(i=0;i<slen;i++){
			if (div_objs[i].id=="RegionDiv"){
				RegionDivs[div_num] = div_objs[i];
				div_num++;
			}
		}
		slen = RegionDivs.length;
        for (i=0;i<slen;i++){
            if (RegionDivs[i].getAttribute("rno")==rno){
                RegionDivs[i].style.display = "block";
            }else{
                RegionDivs[i].style.display = "none";
            }
        }
	}else{
	    slen = RegionDiv.length;
	    if (slen>=1){
	        for (i=0;i<slen;i++){
	            if (RegionDiv[i].rno==rno){
	                RegionDiv[i].style.display = "block";
	            }else{
	                RegionDiv[i].style.display = "none";
	            }
	        }
	    }else{
	        RegionDiv.style.display = "block";
	    }
	}
}

function GoCountry(cno){
    //alert(cno);
    url_path = window.location.pathname;
    window.location = url_path+"#bookmark"+cno;
    //bm_obj = document.getElementById("country_bm"+cno);
    //eval("bm_obj=fmContactUs.bookmark_"+cno);
    //window.setTimeout(bm_obj.click(),1000000);
    //bm_obj.focus();
}

function popup(urlstr){
    re = / /gi;
    if (urlstr.replace(re,"")==""){return;}
    window.open(urlstr,"new_window","resizable");
}

function show_flash(){
	if (obj=document.getElementById("flash_obj")){obj.style.display = "block";}
}


function DownloadNewWay(URL, TargetWindow, SpecialAlert)
{
	var BrowserVersion = navigator.userAgent.match(/MSIE /i);
	if(BrowserVersion==null)
	{
		URL = URL.replace(/ftp\/pub\/downloadlibrary\//i, "");
	}
	
	if(SpecialAlert!="")
	{
		alert(SpecialAlert);
	}
	if(TargetWindow!="")
	{
		setTimeout("window.open('"+URL+"')",2000);
	}
	else
	{
		setTimeout("window.location.href='"+URL+"'",2000);
	}
}
