//Browser detect
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

if (version <5 && browser == "Netscape Navigator") {
	document.write('<p><b><font size="4">Sorry, but this web site requires version 6 and above of Netscape or version 5 and above of Internet Explorer.</b></p>');
}

//style
document.write('<style type="text/css">');
if (browser != "Netscape Navigator" && browser != "Safari") {
	document.write('#scrollContent { position: absolute; width: 230px; z-index: 1; left: 0px; top: 0px; border: 0px none #000000}');
	document.write('#scrollContainer { position:relative; width:230px; height:180px; background-color:#E6EDF6; layer-background-color:#ffffff; z-index:3; left: 0px; top: 0px; overflow: hidden; border: 1px none #E6EDF6; clip: rect(0px 230px 180px 0px }');
	document.write('#divContainer {	VISIBILITY: hidden; OVERFLOW: hidden; WIDTH:230px; CLIP: rect(0px 230px 180px 0px); POSITION: relative; HEIGHT: 180px; TOP: 0px; LEFT: 0px; }');
	document.write('.content { text-align:justify; width:95%; background:white; padding:8px; border:1px dashed #CCCCCC; margin:auto;}');
} else {
	document.write('#scrollContent { position: relative; width: 230px; z-index: 1; left: 0px; top: 0px; border: 0px none #000000}');
	document.write('#scrollContainer { position:relative; width:230px; height:180px; background-color:#E6EDF6; layer-background-color:#E6EDF6; z-index:3; left: 0px; top: 0px; overflow: hidden; border: 1px none #E6EDF6; clip: rect(0px 230px 180px 0px}');
	document.write('.content { text-align:justify; width:92%; background:white; padding:8px; border:1px dashed #CCCCCC; margin:auto;}');
}
document.write('</style>');

highlightcolour="#E6EDF6";
highlightbackground="#E6EDF6";
highlighttext='-';
normalcolour="#E6EDF6";
normalbackground="#E6EDF6";
normaltext='+';

// open window
function newwin(page,name,attributes)
{
        window.open(page,name,attributes);
}
//function to validate by length
function validlength(item, len) {
   return (item.length >= len);
}
//function to validate an email address
function validemail(item) {
   if (!validlength(item, 5)) return false;
   if (item.indexOf ('@', 0) == -1) return false;
   return true;
}
// display an error alert
function error(elem, text) {
// abort if we already found an error
   if (errfound) return;
   window.alert(text);
   elem.select();
   elem.focus();
   errfound = true;
}
// main validation function
function validate_optin() {
   errfound = false;
			if (!validemail(document.optin.email.value))
    			error(document.optin.email,"Sorry, Invalid Email Address!");

   return !errfound; /* true if there are no errors */
}
function validate_optin2() {
   errfound = false;
			if (!validemail(document.optin2.email.value))
    			error(document.optin2.email,"Sorry, Invalid Email Address!");

   return !errfound; /* true if there are no errors */
}

function validate_contact() {
   errfound = false;
			if (!validlength(document.contactinfo.first_name.value,1))
    			error(document.contactinfo.first_name,"Sorry, Invalid First Name.\n\nThis information is required.");
			if (!validlength(document.contactinfo.last_name.value,1))
    			error(document.contactinfo.last_name,"Sorry, Invalid Last Name.\n\nThis information is required.");
			if (!validemail(document.contactinfo.email.value))
    			error(document.contactinfo.email,"Sorry, Invalid Email Address.\n\nYou might have mistyped your email.");

   return !errfound; /* true if there are no errors */

}

//Date
var time = new Date(), year;
year = time.getFullYear();

//erase imput box content
var effaced=0;
function efface (elem) {
	if (effaced == 1){
		elem.value='';
	}
	effaced=effaced+1;
	//alert(effaced) 
}


// scrollable area
function objFind(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=objFind(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function scrollNow(el, x, y, a, b, c, s) { //v2.8 PVII
 var g,elo=el,f="",m=false,d="";x=parseInt(x);y=parseInt(y);
 var t = 'g.p7Magic = setTimeout("scrollNow(\''+elo+'\','; 
 if ((g=objFind(el))!=null) {d=(document.layers)?g:g.style;}else{return;}
 if (parseInt(s)>0) {eval(t+x+','+y+','+a+','+b+','+c+',0)",' + s+')');return;}
 var xx=(parseInt(d.left))?parseInt(d.left):0;
 var yy=(parseInt(d.top))?parseInt(d.top):0;
 if(parseInt(c)==1) {x+=xx;y+=yy;m=true;c=0;}
 else if (c==2) {m=false;clearTimeout(g.p7Magic);}
 else {var i=parseInt(a);
  if (eval(g.moved)){clearTimeout(g.p7Magic);}
  if (xx<x){xx+=i;m=true;if(xx>x){xx=x;}}
  if (xx>x){xx-=i;m=true;if(xx<x){xx=x;}}
  if (yy<y){yy+=i;m=true;if(yy>y){yy=y;}}
  if (yy>y){yy-=i;m=true;if(yy<y){yy=y;}}}
 if (m){if((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1)&& navigator.userAgent.indexOf("Opera")==-1){
    xx+="px";yy+="px";}
  d.left=xx;d.top=yy;g.moved=true;eval(t+x+','+y+','+a+','+b+','+c+',0)",'+b+')');
  }else {g.moved=false;}
}

/*
	domCollapse()
	written by Christian Heilmann
	with help from Scott Benish and Craig Saila of the webdesign-L list
	homepage: http://www.onlinetools.org/tools/domcollapse.php
*/
function domCollapse(which){
	if (document.getElementById && document.createTextNode){
		if (which=="dispall") {domCollapseAll(1);}
		else if (which=="hideall") {domCollapseAll(0);}
		else {
			m=document.getElementById("menu");
			trig=m.getElementsByTagName("div").item(which).style.display;
			t=m.getElementsByTagName("h2").item(which);
			h=t.getElementsByTagName("a").item(0).firstChild;
			if (trig=="block") trig="none";
			else if (trig=="" || trig=="none") trig="block";
			if (trig=="none"){
				h.nodeValue=h.nodeValue.replace(highlighttext,normaltext);
				t.style.background=normalbackground;
				t.style.color=normalcolour;
				}
			else {
				h.nodeValue=h.nodeValue.replace(normaltext,highlighttext);
				t.style.background=highlightbackground;
				t.style.color=highlightcolour;
				}
			m.getElementsByTagName("div").item(which).style.display=trig;
		}
	}
} 

/*
	function domCollapseAll(show)
*/
function domCollapseAll(show){
	if (document.getElementById && document.createTextNode){
		m=document.getElementById("menu");
		for (i=0;i<m.getElementsByTagName("div").length;i++){
			t=m.getElementsByTagName("h2").item(i);
			h=t.getElementsByTagName("a").item(0).firstChild;
			if (show==1){
				h.nodeValue=h.nodeValue.replace(normaltext,highlighttext);
				t.style.background=highlightbackground;
				t.style.color=highlightcolour;
				m.getElementsByTagName("div").item(i).style.display="block";
			}
			else {
				h.nodeValue=h.nodeValue.replace(highlighttext,normaltext);
				t.style.background=normalbackground;
				t.style.color=normalcolour;
				m.getElementsByTagName("div").item(i).style.display="none";
			}
		}
	}
}
// Adding backwards compatibility
if (document.getElementById && document.createTextNode){
	document.write('<style type="text/css">#menu div{display:none;}</style>')
	}



function changePos() {
if(name) {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
img.style.left = xPos + document.body.scrollLeft;
img.style.top = yPos + document.body.scrollTop;
}
else {
height = window.innerHeight;
width = window.innerWidth;
Hoffset = document.img.clip.height;
Woffset = document.img.clip.width;
document.img.pageY = yPos + window.pageYOffset;
document.img.pageX = xPos + window.pageXOffset;
}
if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
   }
}
function start() {
if(name) img.visibility = "visible";
else document.img.visibility = "visible";
interval = setInterval('changePos()',delay);
}
function pauseResume() {
if(pause) {
clearInterval(interval);
pause = false;
}
else {
interval = setInterval('changePos()',delay);
pause = true;
   }
}


function getLeft(obj) {
	return (obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft + getLeft(obj.offsetParent));
}
function getTop(obj) {
	return (obj.offsetParent==null ? obj.offsetTop : obj.offsetTop + getTop(obj.offsetParent));
}