//------------------------------------------------------------------------------------------------------------------
//Rollover
//------------------------------------------------------------------------------------------------------------------
function RollOver(strPage, strCampaign) {
	if (document.images)
    	{
   	    //Main Nav
	    btnHomeon= new Image(54,9);
	    btnHomeon.src="images/btnHome_On.gif";
	    btnHomeoff= new Image(54,9);	     
	    btnHomeoff.src="images/btnHome.gif";

	    btnPortfolioon= new Image(54,9);
	    btnPortfolioon.src="images/btnPortfolio_On.gif";
	    btnPortfoliooff= new Image(54,9);	     
	    btnPortfoliooff.src="images/btnPortfolio.gif";

	    btnProfileon= new Image(54,9);
	    btnProfileon.src="images/btnProfile_On.gif";
	    btnProfileoff= new Image(54,9);	     
	    btnProfileoff.src="images/btnProfile.gif";

	    btnNewson= new Image(54,9);
	    btnNewson.src="images/btnNews_On.gif";
	    btnNewsoff= new Image(54,9);	     
	    btnNewsoff.src="images/btnNews.gif";

	    btnContacton= new Image(54,9);
	    btnContacton.src="images/btnContact_On.gif";
	    btnContactoff= new Image(54,9);	     
	    btnContactoff.src="images/btnContact.gif";
	}
}
 
function lightup(imgName)
 {
   if (document.images)
    {
      imgOn=eval(imgName + "on.src");
      document[imgName].src= imgOn;
    }
 }
 
function turnoff(imgName)
 {
   if (document.images)
    {
      imgOff=eval(imgName + "off.src");
      document[imgName].src= imgOff;
    }
 }
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Center the screen
//------------------------------------------------------------------------------------------------------------------
var intContentWidth = 900;	
var intContentHeight = 700;	
var intBrowserWidth = 0; 
var intBrowserHeight = 0;

function PositionGetBrowserSize(){
	if(navigator.userAgent.indexOf("Firefox") != -1) {
		intBrowserWidth = document.body.offsetWidth-19; 
		intBrowserHeight = document.body.clientHeight;
	} else {
		if (navigator.appName=="Netscape"){
			intBrowserWidth = window.innerWidth-19; 
			intBrowserHeight = window.innerHeight;
		}else if (navigator.appName.indexOf("Microsoft")!=-1){
			intBrowserWidth = document.body.offsetWidth-19; 
			intBrowserHeight = document.body.offsetHeight;
		}
	}
}

function PositionGetLeftAlignment(){
	var intLeft = ((intBrowserWidth/2)-(intContentWidth/2))
	if(intLeft < 0) intLeft = 0;
	return intLeft;
}

function PositionGetTopAlignment(){
	var intTop = (intBrowserHeight/2)-(intContentHeight/2);
	if(intTop < 0) intTop = 0;
	return intTop
}

function PositionResize(){
	PositionGetBrowserSize();
	var theDivStyle = document.getElementById('content').style
	theDivStyle.left = PositionGetLeftAlignment();
	theDivStyle.top = PositionGetTopAlignment();		
}
//------------------------------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------------------------------
// Function pops up a blank window with no url to be used as the submission target of the forms below
//------------------------------------------------------------------------------------------------------------------
function ShowPopup(name, width, height, pstrPageName){
	pop = window.open(pstrPageName, name, "resizable=no,scrollbars=yes,width="+width+",height="+height);
	pop.focus();
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Left and Right Functions
//------------------------------------------------------------------------------------------------------------------
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Get the Browser Name
//------------------------------------------------------------------------------------------------------------------
	var detect = navigator.userAgent.toLowerCase();
var thestring, place;
		
function getBrowserName () {
	var OS,browser,version;
			
	if (checkString('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkString('safari')) browser = "Safari"
	else if (checkString('omniweb')) browser = "OmniWeb"
	else if (checkString('opera')) browser = "Opera"
	else if (checkString('webtv')) browser = "WebTV";
	else if (checkString('icab')) browser = "iCab"
	else if (checkString('msie')) browser = "Internet Explorer"
	else if (!checkString('compatible'))
	{
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";
			
	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS)
	{
		if (checkString('linux')) OS = "Linux";
		else if (checkString('x11')) OS = "Unix";
		else if (checkString('mac')) OS = "Mac"
		else if (checkString('win')) OS = "Windows"
		else OS = "an unknown operating system";
	}
			
	return browser;
}
		
function checkString(string)
{			
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
//------------------------------------------------------------------------------------------------------------------


//------------------------------------------------------------------------------------------------------------------
//Trim function
//------------------------------------------------------------------------------------------------------------------
function trimAll(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Check Email function
//------------------------------------------------------------------------------------------------------------------
function isValidEmail(pstrEmail){
	 var filter=/^.+@.+\..{2,3}$/
	
	 if (filter.test(pstrEmail))
	    return true
	 else {
		return false
	}
}
//------------------------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//Check if a text field is numeric
//------------------------------------------------------------------------------------------------------------------
function isNumeric(sText)
{
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	var i;
	
	for (i = 0; i < sText.length; i++) { 
	   Char = sText.charAt(i); 

	   if (ValidChars.indexOf(Char) == -1) {
	      return false;
	   }
	}
	return true; 
}
//------------------------------------------------------------------------------------------------------------------
