// ####################################################
//	code to separate the query parameters
// ####################################################
function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}

//BUILDS OUT THE QUERY PARAMETER - SOLVE FOR queryString('someParameter')
function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

function mainSub(form) {
	searchChoice = form.domain.selectedIndex;	

  	if (form.s.value == "") { // don't go anywhere without a search val  
     return false;
  	}	
	
  	if (form.domain.options[searchChoice].value == "Quote") {
     	form.action="/research/quote.gsp";
     	return true;
  	} else if (form.domain.options[searchChoice].value == "web") {    			self.location="http://msxml.infospace.com/info.silin3/dog/results?otmpl=dog/webresults.htm&qkw="+ escape(form.s.value)+"&qcat=web&top=1";
  	} else if (form.domain.options[searchChoice].value == "charts") {
    	form.action="/research/chart.gsp";
		return true;
  	} else if (form.domain.options[searchChoice].value == "full") {
    	form.action="/stocktalk/searchresults.gsp";
		return true;
  	} else if (form.domain.options[searchChoice].value == "titles") {
    	form.action="/stocktalk/searchresults.gsp";
		return true;
  	} else if (form.domain.options[searchChoice].value == "news") {
    	self.location="http://kevxml2a.infospace.com/info.silin3/kevxml?otmpl=finance/stocknews.htm&kcfg=bw&qsym="+ escape(form.s.value);
  	} else if (form.domain.options[searchChoice].value == "profile") {
    	self.location="http://kevxml2a.infospace.com/info.silin3/finance/research/profile.htm?qsym="+ escape(form.s.value);
  	} else if (form.domain.options[searchChoice].value == "earnings") {
    	self.location="http://kevxml2a.infospace.com/info.silin3/finance/research/earn_est.htm?qsym="+ escape(form.s.value);
  	} else if (form.domain.options[searchChoice].value == "histprices") {
    	form.action="/research/historical.gsp";
		return true;
  	} else if (form.domain.options[searchChoice].value == "invsent") {
    	self.location="http://siliconinvestor.allpredictive.com/l/si/SILand.aspx?a=mpdr&r=1&s="+ escape(form.s.value);
  	}			
  	return false;
}

function launch_window(p_filename,p_winname,p_width,p_height){
	window.name = "main"
	var agt=navigator.userAgent.toLowerCase(); 
	var isnt_webtv  = (agt.indexOf('webtv') ==-1); 
	if (isnt_webtv){            
		curpopup = window.open(p_filename,p_winname,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=0,top=0,screenX=0,screenY=0,width=' + p_width + ',height=' + p_height)
	}
}
 // Real-Time Portfolio Popup
function portpop() {  
	popupWin = window.open('/incls/portpop.html','WindowName','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=360') 
}



function toggleChart(symbol){
chUrl = "http://fnapp.infospace.com/fn/chart?time=15m&period=30&title=symbol&w=177&bgc=EEEEEE&symbol="+symbol
	//chUrl = "http://fnapp.infospace.com/fn/chart?symbol="+symbol+"&time=15m&period=30&w=177&pc=5E86AE&tkc=000000&ftc=cccccc"
	if (symbol == "INDU") {
		cg = "dija";
	} else if (symbol == "COMPX"){
		cg = "nasd";
	} else if (symbol == "INX"){
		cg = "sp500";
	}
	chNavUrl = "/global_images/chart_"+cg+".gif";
	document.chart.src = chUrl;
	document.chartNav.src = chNavUrl;
}



