var k=new Array();

function operation(temp,add,out)	{
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

function keepsearching(texthere) {
out = "|"; // replace this
add = ""; // with this
temp = "" + texthere; // temporary holder

temp=operation(temp,add,out);
out="<";
add="_";

temp=operation(temp,add,out);
out=">";
add="_";

temp=operation(temp,add,out);
return temp;
	
}

function v(textverifying)	{
	textfieldvalue=textverifying;
	if (textfieldvalue=="") {
		alert("The text field must not be blank.");
	} else if (textfieldvalue.length>20) {
		alert("Please limit to a max. of 20 characters");
	} else if (textfieldvalue.indexOf("'") >= 0 || textfieldvalue.indexOf('"') >= 0)	{
                alert("Field value cannot contain quotes.");
	} else if (textfieldvalue.indexOf('#') >= 0)	{
                alert("Field value cannot contain '#' characters.");
        } else if (textfieldvalue.indexOf('~') >= 0 ||  textfieldvalue.indexOf('`') >= 0)	{
                alert("Field value cannot contain '~/`' characters.");
        } else if (textfieldvalue.indexOf('(') >= 0)	{
                alert("Field value cannot contain '(' characters.");
        } else if (textfieldvalue.indexOf('@') >= 0)	{
                alert("Field value cannot contain '@' characters.");

	} else if (textfieldvalue.indexOf('+') >= 0)	{
                alert("Field value cannot contain '+' characters.");

	} else if (textfieldvalue.indexOf('-') >= 0)	{
                alert("Field value cannot contain '-' characters.");

	} else if (textfieldvalue.indexOf('*') >= 0)	{
                alert("Field value cannot contain '*' characters.");

	} else if (textfieldvalue.indexOf('/') >= 0)	{
                alert("Field value cannot contain '/' characters.");

	} else if (textfieldvalue.indexOf('=') >= 0)	{
                alert("Field value cannot contain '=' characters.");

	} else if (textfieldvalue.indexOf(')') >= 0)	{
                alert("Field value cannot contain ')' characters.");

	} else if (textfieldvalue.indexOf('{') >= 0)	{
                alert("Field value cannot contain '{' characters.");
	} else if (textfieldvalue.indexOf('}') >= 0)	{
                alert("Field value cannot contain '}' characters.");
	} else if (textfieldvalue.indexOf('[') >= 0)	{
                alert("Field value cannot contain '[' characters.");
	} else if (textfieldvalue.indexOf(']') >= 0)	{
                alert("Field value cannot contain ']' characters.");
	} else if (textfieldvalue.indexOf(' ') >= 0)	{
                alert("Field value cannot contain space characters.");
	} else if (textfieldvalue.indexOf('%') >= 0)	{
                alert("Field value cannot contain '%' characters.");

	} else if (textfieldvalue.indexOf('&') >= 0)	{
                alert("Field value cannot contain '&' characters.");
	} else if (textfieldvalue.indexOf('\\') >= 0)	{
                alert("Field value cannot contain '\' characters.");
	} else if (textfieldvalue.indexOf('^') >= 0)	{
                alert("Field value cannot contain '^' characters.");

	} else if (textfieldvalue.indexOf('$') >= 0)	{
                alert("Field value cannot contain '$' characters.");
	} else if (textfieldvalue.indexOf('!') >= 0)	{
                alert("Field value cannot contain '!' characters.");
       	} else {
		return true;
	}
}

function vi(textverify)	{
	textfieldvalueI=textverify;
	if (textfieldvalueI.indexOf("_") >= 0 || textfieldvalueI.indexOf('.') >= 0)	{
                alert("Field value cannot contain '_' or '.' quotes");
	} else if (textfieldvalueI.indexOf(":") >= 0 || textfieldvalueI.indexOf(';') >= 0){
                alert("Field value cannot contain ':' or ';' characters.");
        } else if (textfieldvalueI.indexOf("<") >= 0 || textfieldvalueI.indexOf('>') >= 0){
                alert("Field value cannot contain '<' or '>' characters.");
        } else if (textfieldvalueI.indexOf("|") >= 0){
                alert("Field value cannot contain '|' characters.");
        } else {
		return true;
	}	

}


function checkPName()	{

	tobepasson=document.formportfolio.portidentifier.value;
	if (v(tobepasson) && vi(tobepasson)) 	{
	temppname=tobepasson;
	document.formportfolio.portidentifier.value=keepsearching(temppname);
		u=document.formportfolio.portidentifier.value;
	newaddress='framecontent.asp?portidentifier='+u;
	parent.parent.frames[0].location.href=newaddress;
	x='loginpname.asp?portidentifier='+u;
	parent.frames[1].location.href=x;
	} else	{
	return false;
	}
}

function icheckPName()	{

	tobepasson=document.formportfolio.portidentifier.value;
	if (v(tobepasson) && vi(tobepasson)) 	{
	temppname=tobepasson;
	document.formportfolio.portidentifier.value=keepsearching(temppname);
		u=document.formportfolio.portidentifier.value;
	newaddress='framecontent.asp?portidentifier='+u;
	parent.parent.frames[0].location.href=newaddress;
	x='pname.asp?portidentifier='+u;
	parent.frames[1].location.href=x;
	} else	{
	return false;
	}
}

function CPName()	{
	tobepasson=document.formportfolio.portidentifier.value;
	if (tobepasson=="")	{
		alert("You must input a portfolio name first");
	} else {
		tobeverify=document.sssymbol.ssymbol.value;
		if (v(tobeverify) && vi(tobeverify)) 	{
		document.sssymbol.ssymbol.value=keepsearching(tobeverify);
	a=document.sssymbol.ssymbol.value;
	b=document.sssymbol.Countries.options[document.sssymbol.Countries.selectedIndex].value;	
	y='addhldg.asp?ssymbol='+a;
	y+='&Countries='+b;
	y+='&portidentifier='+tobepasson;
	parent.frames[1].location.href=y;
		} else	{return false;}
	}
}

function removehldg(form,calling)	{
	
		c=document.formportfolio.portidentifier.value;
		temmm=document.removeview.DDETAILS.options[document.removeview.DDETAILS.selectedIndex].value;
		k=temmm.split("|");
		a=k[0];
		b=k[1];
		if (b=="HONG+KONG")	{b="HONG%2BKONG";}
	if (calling=="re")	{
		y='removehldgs.asp?ccode='+a;
		y+='&CExchange='+b;
		y+='&portidentifier='+c;
	parent.frames[1].location.href=y;
	} else if (calling=="ch")	{
		URLextension="?Exchange="+b+"&Mode=JAVACHART&Symbol="+a;
		parent.frames[1].location.href="http://investor.stockpoint.com/quote.asp"+URLextension;

	} else if (calling=="qu")	{
		URLextension="?Exchange="+b+"&Symbol="+a+"&Company=";
		parent.frames[1].location.href="http://investor.stockpoint.com/quote.asp"+URLextension;
	}	
}

function logincheck()	{
	fff=document.loginform.username.value;
	ggg=document.loginform.userpwd.value;
	if (v(fff) && v(ggg) && vi(ggg) && vi(fff)) 	{
	temppname=fff;
	TName=ggg;
	document.loginform.username.value=keepsearching(temppname);
	document.loginform.userpwd.value=keepsearching(TName);
	u=document.loginform.username.value;
	uu=document.loginform.userpwd.value;
	document.loginform.submit();
	} else {
		return false;	
	}
}

function Registercheck()	{
	fff=document.registerform.trader.value;
	ggg=document.registerform.traderpwd.value;
	hhh=document.registerform.traderemail.value;
	if (v(fff) && v(ggg) && vi(ggg) && vi(fff)) 	{
	temppname=fff;
	TName=ggg;
	document.registerform.trader.value=keepsearching(temppname);
	document.registerform.traderpwd.value=keepsearching(TName);
	u=document.registerform.trader.value;
	uu=document.registerform.traderpwd.value;
		if (hhh.indexOf('@') >= 0) { 
			document.registerform.submit();
		} else {
			alert("Your mail address doesn't look right");
		}
	} else {
		return false;	
	}
}

function  numbercheck(checkfield)	{
	if (isNaN(checkfield))	{
		return false;
	} else {
		return true;
	}
}

function decimalcheck(checkfield1)	{
	twodec=checkfield1.lastIndexOf('.');
	fulllength=checkfield1.length;
	if (twodec>=0 && parseInt(fulllength)-parseInt(twodec)<4)	{
		return true;
	} else if(parseInt(twodec)<0)	{
		return true;
	} else {
		return false;
	} 
}

function lostpwd()	{
	fff=document.fgt.trader.value;
	ggg=document.fgt.tradermail.value;
	if (v(fff) && vi(fff)) 	{
	temppname=fff;
	TName=ggg;
	document.fgt.trader.value=keepsearching(temppname);
	document.fgt.tradermail.value=keepsearching(TName);
	u=document.fgt.trader.value;
	uu=document.fgt.tradermail.value;
	document.fgt.submit();
	} else {
		return false;	
	}
}

var xy = navigator.appVersion;
var xz = xy.substring(0,1);
var dpos=0;
function wheretomove(whichone,vcoordinate)	{
	if (navigator.appName=="Netscape" && xz=='4')	{
		eval("document.layers."+whichone+".top="+vcoordinate);
	} else {
		eval("document.all."+whichone+".style.top="+vcoordinate);
	}	
}

var inpos=125;
var dpos=0;
function startmoving()	{
	dpos++;
	wheretomove('laname1',parseInt(inpos-dpos));
	if (parseInt(inpos-dpos)<parseInt(-365))	{dpos=0;}
	setTimeout("startmoving()", 55);
}

pics=new Array();
var objcount=0;
function preload(imgname, first, second)	{
	pics [objcount]=new Array(3);
	pics [objcount][0]=new Image();
	pics [objcount][0].src=first;
	pics [objcount][1]=new Image();
	pics [objcount][1].src=second;
	pics [objcount][2]=imgname;
	objcount++;
}

preload ("Equity", "EquityNewson.jpg", "EquityNewsoff.jpg");
preload ("FX", "FXNewsOff", "FXNewsOn");
preload ("Derivatives", "DerivativesNewsoff.jpg", "DerivativesNewson.jpg");
preload ("Bonds", "BondsNewsoff.jpg", "BondsNewson.jpg");

function whattoshow(qbrowser,digitcheck)	{
	if (qbrowser=='Netscape' && xz=='4')	{
		if (digitcheck=='y')	{return 'show';} else {return 'hide';}
	} else {
		if (digitcheck=='y')	{return 'visible';} else {return 'hidden';}
	} 	
}

function whatlayer(whichone,yn)	{
	if (navigator.appName=="Netscape" && xz=='4')	{
eval("document.layers."+whichone+".visibility='"+whattoshow('Netscape',yn)+"'");
		
	} else {
		eval("document.all."+whichone+".style.visibility='"+whattoshow('IE',yn)+"'");
	}	
}


function formatCurrency(num,nformat) {
nnum=num.toString();
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
if (nformat=='Y')	{
	if (nnum.indexOf('.')>=0)	{
		ncents=nnum.split('.');
		if (ncents[1].length<='6')	{cents=ncents[1];
		} else	{
			cents=ncents[1].substring(0,6);
			
		}	
	} else	{
		cents='000000';
	}
	return (((sign)?'':'-') + num + '.' + cents);
} else {
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
}
