function sack(file) {
	this.xmlhttp = null;

	this.resetData = function() {
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
  		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}
		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}
		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}
		this.setVar("rndval", new Date().getTime());
		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}
			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}
							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}


function openwebsitesurvey(){
 					lnk="webpages/website_survey.asp"
					var win=window.open(lnk,"","width=700,height=570,toolbars=0,scrollbars=1,resizable=no")
					}
 /* Ajax Live Price*/
  var enableCache = false;
    var jsCache = new Array();
    var AjaxObjects = new Array();

    function ShowContent(divId,ajaxIndex,url)      {
	        document.getElementById(divId).innerHTML = AjaxObjects[ajaxIndex].response;
	        if(enableCache){
		        jsCache[url] = 	AjaxObjects[ajaxIndex].response;
	        }
	        AjaxObjects[ajaxIndex] = false;
        }

    function Ajax(divId,url)     {
	 
	        if(enableCache && jsCache[url]){
		        document.getElementById(divId).innerHTML = jsCache[url];
		        return;
	        }	
	        var ajaxIndex = AjaxObjects.length;
	        AjaxObjects[ajaxIndex] = new sack();
	        AjaxObjects[ajaxIndex].requestFile = url;
	        AjaxObjects[ajaxIndex].onCompletion = function(){ ShowContent(divId,ajaxIndex,url); };
	        AjaxObjects[ajaxIndex].runAJAX();
        }   
var Commodityname
 if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
else // Internet Explorer 5/6
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET","webpages/commodities_symbols.xml",false);
xhttp.send("");
xmlDoc=xhttp.responseXML;
var x=xmlDoc.getElementsByTagName("commodities");
var bgcolVal = 0


function ChartStoreAjax()
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="charts/charts_data.asp";
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
 
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


 setTimeout("ChartStoreAjax()", 600000);
 
function beforeValidate(frm)
{
    if (frm.terms.value=="") {
	  alert("Enter your search query");
	  frm.terms.focus();
	  return false;	  
	  }

}
 
 
 function xml_file(filename)
{ 
 document.getElementById('chartname').value= filename;
 
		var so = new SWFObject("charts/line_chart.swf", "line_chart", "270", "95", "8");
		so.addVariable("path", "charts/");
		so.addVariable("settings_file", encodeURIComponent("charts/line_chart_commodities.xml"));
		so.addVariable("data_file", encodeURIComponent("charts/"+document.getElementById('chartname').value+".xml"));	
		so.addVariable("preloader_color", "#FFFFFF");
		so.addParam("wmode", "transparent");
		so.write("flashcontent");

}
function showChart(chNo) {
	  var hrefIDVal;	 
	  
	  for (var i=0;i<4;i++) {	   
	 	  hrefIDVal="gifChartAnc"+i;		 
			  document.getElementById(hrefIDVal).className="none";			 
	  	}
 	   hrefIDVal="gifChartAnc"+chNo;
    	   document.getElementById(hrefIDVal).className="current";
	  }



/* Market Tab script start */
function m(o){return document.getElementById(o);}
function MdHoverLi(n){
for(var i=1;i<=3;i++){m('md'+i).className='normaltabmd';m('mdc0'+i).className='undis';}m('mdc0'+n).className='dis';m('md'+n).className='hovertabmd';
}
/* Market Tab script end*/

  function loadNews() {
  document.getElementById("spotPriceFeedsFrameID").src="http://www.mexnepal.com/webpages/nse_spot_prices_scroll.asp";
  document.getElementById("spotDataFrameID").src="http://www.mexnepal.com/webpages/nse_spot_prices_tab.asp";
    }

function ceo_interview()
{
var win=window.open("webpages/ceo_interview.html","ceo_interview","width=1020,height=760,toolbars=0,scrollbars=no,menubar=0,statubar=0")
}

window.onload=function()
	{	
		loadNews(); 
	 	//Bounce('divdemo',-100,180,1500,142,1000);
    }
var timerID = setInterval(mm_startdemo,20);
	function mm_startdemo() 	{
		var elem = document.getElementById('divdemo');
		}
	function mm_showIsdemo() {
		this.clearInterval(timerID);
		document.getElementById("divdemo").style.display=''; 
		}
  function mm_closedemo()    {
	   if (document.getElementById("divdemo").style.display=='block') {
		   	document.getElementById("divdemo").style.display='none';
  			}
	  }  
	  
function zxcBAnimator(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime){
 if (typeof(zxcobj)=='string'){ zxcobj=document.getElementById(zxcobj); }
 if (!zxcobj||(!zxcsrt&&!zxcfin)||zxcsrt==zxcfin) return;
 var zxcoop=zxcobj[zxcmde.replace(/[-#]/g,'')+'oop'];
 if (zxcoop){
  clearTimeout(zxcoop.to);
  if (zxcoop.srtfin[0]==zxcsrt&&zxcoop.srtfin[1]==zxcfin&&zxcmde.match('#')) zxcoop.update([zxcoop.data[0],(zxcoop.srtfin[0]==zxcoop.data[2])?zxcfin:zxcsrt],zxctime);
  else zxcoop.update([zxcsrt,zxcfin],zxctime);
 }
 else zxcobj[zxcmde.replace(/[-#]/g,'')+'oop']=new zxcBAnimatorOOP(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime);
}

function zxcBAnimatorOOP(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime){
 this.srtfin=[zxcsrt,zxcfin];
 this.to=null;
 this.obj=zxcobj;
 this.mde=zxcmde.replace(/[-#]/g,'');
 this.update([zxcsrt,zxcfin],zxctime);
}

zxcBAnimatorOOP.prototype.update=function(zxcsrtfin,zxctime){
 this.time=zxctime||this.time||2000;
 this.data=[zxcsrtfin[0],zxcsrtfin[0],zxcsrtfin[1]];
 this.srttime=new Date().getTime();
 this.cng();
}

zxcBAnimatorOOP.prototype.cng=function(){
 var zxcms=new Date().getTime()-this.srttime;
 this.data[0]=(this.data[2]-this.data[1])/this.time*zxcms+this.data[1];
 if (this.mde!='left'&&this.mde!='top'&&this.data[0]<0) this.data[0]=0;
 if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
 else  zxcOpacity(this.obj,this.data[0]);
 if (zxcms<this.time) this.to=setTimeout(function(zxcoop){return function(){zxcoop.cng();}}(this),10);
 else {
  this.data[0]=this.data[2];
  if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
  else zxcOpacity(this.obj,this.data[0]);
 }
}

function zxcOpacity(zxcobj,zxcopc){
 if (zxcopc<0||zxcopc>100) return;
 zxcobj.style.filter='alpha(opacity='+zxcopc+')';
 zxcobj.style.opacity=zxcobj.style.MozOpacity=zxcobj.style.KhtmlOpacity=zxcopc/100-.001;
}
function Bounce(id,start,finish1,time1,finish2,time2){
 var zxcobj=document.getElementById(id);
 zxcobj.style.display="block";
 clearTimeout(zxcobj.bto);
 zxcBAnimator('top',zxcobj,start,finish1,time1);
 zxcobj.bto=setTimeout(function(){ zxcBAnimator('top',zxcobj,finish1,finish2,time2); },time1);
}


function xml_list(){
		var spval = new Array();
for (i=0;i<x.length;i++)
  {	
  spval[i]=x[i].childNodes[0].nodeValue;
  
  }
document.write('<div id="chartMenu">');
document.write('<ul class="chartMenuCls">');
document.write('<li><a href="javascript:void(0);" id="gifChartAnc0" onclick="xml_file(\''+spval[0]+'\');showChart(0)" title="'+spval[0]+' Live Price Chart" class="current">'+spval[0]+'</a></li>');

for(j=1;j<4;j++)
{										
document.write('<li><a href="javascript:void(0);" id="gifChartAnc'+j+'" onclick="xml_file(\''+spval[j]+'\');showChart('+j+')" title="'+spval[j]+' Live Price Chart">'+spval[j]+'</a></li>');
}
document.write('</ul>');
document.write('</div>');
document.write('<input id="chartname" name="chartname" value="'+spval[0]+'" type="hidden"/>');
}

function business_swf(){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="295" height="145">');
document.write('<param name="movie" value="charts/Business.swf" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<embed src="charts/Business.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="295" height="145"></embed>');
document.write('</object>');
}

function tickerSpot(dir){
		var tickerObj = document.getElementById('maqidSpotprice');
 		if (dir == 1) {
			var x=tickerObj.scrollDelay;
			x=x-5
			if(x<10)
				x=10
			tickerObj.scrollDelay=x;
			return false;				
		}
		if (dir == 2) {
			var x=tickerObj.scrollDelay;
			x=x+5
			if(x>100)
				x=100
			tickerObj.scrollDelay=x;
			return false;					
		}
	}
