
var mc = (navigator.appVersion.toLowerCase().indexOf("mac")!=-1) ? true : false;
var ie = (document.all) ? true : false;

function get_el(ip_id){
	if (ie){
		return document.all[ip_id];
	} else {
		return document.getElementById(ip_id);
	}
}

onresize = function(){
	if (typeof(ticker)!="undefined") ticker.position();
	if (typeof(scrl)!="undefined") scrl.position();
}

var ticker = {};
ticker.speed = 1;
ticker.width = 710;

ticker.init_ticker = function(){
	this.tCDv = get_el("tickerContainer");
	if (!this.tCDv) return;
	if (!this.tCDv || !this.tCDv.style) return;
	this.tCDv.style.height = 16;
	this.dv = get_el("ticker");
	this.text_width = this.dv.clientWidth;
	this.x = 0;
	this.position();
	setInterval("ticker.move();",40);
}

ticker.move = function(){
	this.x-=this.speed;
	if (this.x<-(this.text_width+(this.width/2))) this.x=this.width;
	this.dv.style.left = this.x;
	this.dv.style.clip="rect(0 "+(this.width-this.x)+" 50 0)";
}

ticker.position = function(){
	//if ((!(ie && !mc)) || !this.tCDv) return;
	//var y = this.tCDv.style.top = ((document.body.offsetHeight-470)/2)+432;
	//if (y<437) this.tCDv.style.top=437;
}	


var err_els=[];

function form_validate(fm){
	var el,vl,sp;
	var error = false;
	
	for (var i=0;i<err_els.length;i++){
		var ar = err_els[i];
		var el = ar[0];
		var sp = ar[1];
		el.style.backgroundColor="#ffffff";
		sp.innerHTML="";
	}		
	err_els=[];		
	for (i=0;i<rqd.length;i++){
		el = fm.elements[rqd[i]];
		sp = get_el("val_"+rqd[i]);
		if (!sp) continue;
		if (typeof(el)=="undefined") continue;
		if (el.type=="text" || el.type=="password" || el.type=="textarea") vl=el.value;
		if (el.type=="select-one") vl = el.options[el.selectedIndex].value;
		if (el.name=="email" && el.value.indexOf("@")==-1){
			sp.innerHTML = "<nobr>[ your email address is incorrect ]<nobr>";
			el.style.backgroundColor="#FFE6EB";
			err_els[err_els.length] = [el,sp];
			el.focus();
			error = true;
		}
		if (vl==""){
			if (!error) el.focus();
			error = true;
			if (el.type=="text" || el.type=="textarea" || el.type=="password") sp.innerHTML = "<nobr>[ please enter  a value ]</nobr>";
			if (el.type=="select-one") sp.innerHTML = "<nobr>[ please select ]<nobr>";
			el.style.backgroundColor="#FFE6EB";
			err_els[err_els.length] = [el,sp];
		}
	}
	return !error;
}


	
scrl = {};
	
scrl.init = function(){
	return;
	this.heightAllocated = 205;
	this.scrollDistance = 142;
	this.pgYCentre = document.body.offsetHeight/2;
	this.newsHeadingDiv = get_el("newsHeading");
	if (!this.newsHeadingDiv) return;
	this.newsContentDiv = get_el("newsContent");
	this.newsArrowUpDiv = get_el("newsArrowUp");
	this.newsArrowDownDiv = get_el("newsArrowDown");
	this.newsContentContainerDiv = get_el("newsContentContainer");
	
	this.newsHeadingHeight = parseInt(this.newsHeadingDiv.offsetHeight);
	this.contentHeight =  parseInt(this.newsContentDiv.offsetHeight);

	this.contentHeightAllocated = this.heightAllocated - this.newsHeadingHeight;
	this.contentScrollHeight = this.contentHeight - this.contentHeightAllocated
		
	this.newsContentContainerDiv.style.height = this.contentHeightAllocated;
	this.newsArrowUpDiv.style.visibility="hidden";
	this.newsArrowUpDiv.style.top = this.newsHeadingHeight+15;
	this.newsArrowDownDiv.style.top = this.heightAllocated-42;
	this.newsContentContainerDiv.offsetTopOrig = this.newsContentContainerDiv.offsetTop;

	if (this.contentScrollHeight>0) this.newsArrowDownDiv.style.visibility="visible";
	if (ie && mc) this.newsContentDiv.style.position="absolute";
}


scrl.position = function(){
	return;
	if (ie && !mc && this.newsHeadingDiv){
		this.newsContentContainerDiv.style.top = - this.pgYCentre + (document.body.offsetHeight/2) + this.newsContentContainerDiv.offsetTopOrig-15;
		with (this.newsHeadingDiv){
			style.position="absolute";
			style.top = (document.body.offsetHeight/2)+24;
			style.left = this.newsContentContainerDiv.style.left;
		}
		with (this.newsHeadingDiv){
			style.position="absolute";
			style.top = (document.body.offsetHeight/2)-5;
			style.left = this.newsContentContainerDiv.style.left;
		}
		with (this.newsArrowUpDiv){
			style.position="absolute";
			style.top = (document.body.offsetHeight/2)+this.newsHeadingHeight+10;
			style.left = this.newsContentContainerDiv.style.left;
		}
		with (this.newsArrowDownDiv){
			style.position="absolute";
			style.top = (document.body.offsetHeight/2)+204;
			style.left = this.newsContentContainerDiv.style.left;
		}
	}
}

scrl.scroll = function(ip_dir){
	if (this.dir) return;
	this.yCurrent = parseInt(this.newsContentDiv.style.top);
	this.y = 0;
	this.dir = ip_dir;
	if (ip_dir=="down"){
		var distanceFromStop = this.contentScrollHeight + this.yCurrent;
		this.travel = (distanceFromStop<this.scrollDistance) ? distanceFromStop : this.scrollDistance;
		if ((distanceFromStop-5)<this.scrollDistance){
			this.newsArrowDownDiv.style.visibility="hidden";
		}
		this.newsArrowUpDiv.style.visibility="visible";
	}
	if (ip_dir=="up"){
		var distanceFromStop = -this.yCurrent;
		this.travel = (distanceFromStop<this.scrollDistance) ? distanceFromStop : this.scrollDistance;
		if ((distanceFromStop-5)<this.scrollDistance){
			this.newsArrowUpDiv.style.visibility="hidden";
		}
		this.newsArrowDownDiv.style.visibility="visible";
	}
	this.ivl = setInterval("scrl.move();",30);
}

scrl.move = function(){
		y = (this.y>0) ? this.y : -this.y;
		a = this.travel-y;
		b = parseInt(a/12+1);

		this.y+= (this.dir=="up") ? b : -b;
		if (a<1){
			this.dir = false;
			clearInterval(this.ivl);
		}
		this.newsContentDiv.style.top = this.yCurrent + this.y;
}

