// Detect Browser and OS
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;
}

function headerset(flag,url)
{

if(browser == "Internet Explorer")
{
parent.frames[0].document.all.header.innerHTML = flag + "&nbsp;";
//parent.frames[1].location.href = url;
}

if ((browser == "Netscape Navigator") && (version >= "5"))
{
parent.frames[0].document.getElementById("header").innerHTML = flag + "&nbsp;";
//parent.frames[1].location.href = url;
}

window.location.replace(url);  
}

function home()
{
headerset("home page", "main.htm");
}

function about()
{
headerset("about us", "about.htm");
}

function england()
{
headerset("england", "england.htm");
}

function australia()
{
headerset("australia", "australia.htm");
}

function china()
{
headerset("china", "china.htm");
}

function egypt()
{
headerset("egypt", "egypt.htm");
}

function geneva()
{
headerset("geneva", "geneva.htm");
}

function contact()
{
headerset("contacting us", "contact.htm");
}

function submitform()
{
window.document.forms[0].submit();
}

function RollOver(src)
{

if(browser == "Internet Explorer")
{
document.all[src].style.backgroundColor = "#D6EFDA";
document.all[src].style.cursor = "hand";
}

if ((browser == "Netscape Navigator") && (version >= "5"))
{
document.getElementById(src).style.backgroundColor = "#D6EFDA";
document.getElementById(src).style.cursor = "pointer";
}

}

function RollOut(src)
{

if(browser == "Internet Explorer")
{
document.all[src].style.backgroundColor = "";
document.all[src].style.cursor = "";
}

if ((browser == "Netscape Navigator") && (version >= "5"))
{
document.getElementById(src).style.backgroundColor = "";
}

}

engon= new Image (96,101);
engon.src="images/buttons/england_on.gif";
engoff= new Image (96,101);
engoff.src="images/buttons/england.gif";

auson= new Image (96,101);
auson.src="images/buttons/australia_on.gif";
ausoff= new Image (96,101);
ausoff.src="images/buttons/australia.gif";

chion= new Image (96,101);
chion.src="images/buttons/china_on.gif";
chioff= new Image (96,101);
chioff.src="images/buttons/china.gif";

egyon= new Image (96,101);
egyon.src="images/buttons/egypt_on.gif";
egyoff= new Image (96,101);
egyoff.src="images/buttons/egypt.gif";

genon= new Image (96,101);
genon.src="images/buttons/geneva_on.gif";
genoff= new Image (96,101);
genoff.src="images/buttons/geneva.gif";

function lightup(imgName)
{
imgOn=eval(imgName + "on.src");
document[imgName].src= imgOn;
}

function turnoff(imgName)
{
imgOff=eval(imgName + "off.src");
document[imgName].src= imgOff;
}

function doastrix()
{

if (document.forms[0].Select.value == "Email me with an answer to my enquiry")
{
if(browser == "Internet Explorer")
{
document.all.a_email.innerHTML = "&nbsp;*";
document.all.a_telephone.innerHTML = "&nbsp;";
document.all.a_fax.innerHTML = "&nbsp;";
}

if ((browser == "Netscape Navigator") && (version >= "5"))
{
document.getElementById("a_email").innerHTML = "&nbsp;*";
document.getElementById("a_telephone").innerHTML = "&nbsp;";
document.getElementById("a_fax").innerHTML = "&nbsp;";
}
}

else if (document.forms[0].Select.value == "Telephone me with an answer to my enquiry")
{
if(browser == "Internet Explorer")
{
document.all.a_email.innerHTML = "&nbsp;";
document.all.a_telephone.innerHTML = "&nbsp;*";
document.all.a_fax.innerHTML = "&nbsp;";
}

if ((browser == "Netscape Navigator") && (version >= "5"))
{
document.getElementById("a_email").innerHTML = "&nbsp;";
document.getElementById("a_telephone").innerHTML = "&nbsp;*";
document.getElementById("a_fax").innerHTML = "&nbsp;";
}
}

else if (document.forms[0].Select.value == "Fax me with an answer to my enquiry")
{
if(browser == "Internet Explorer")
{
document.all.a_email.innerHTML = "&nbsp;";
document.all.a_telephone.innerHTML = "&nbsp;";
document.all.a_fax.innerHTML = "&nbsp;*";
}

if ((browser == "Netscape Navigator") && (version >= "5"))
{
document.getElementById("a_email").innerHTML = "&nbsp;";
document.getElementById("a_telephone").innerHTML = "&nbsp;";
document.getElementById("a_fax").innerHTML = "&nbsp;*";
}
}

}

function products(country,width,height)
{

if (OS == "Mac")
{
height= parseInt(height) - 20
}

else
{
height= parseInt(height) + 30
}

URL = country + "_products.htm";
option = "width=" + width;
option += ",height=" + height;
option += "";
window.open(URL, "", option);
}

function checkemail()
{
// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = document.forms[0].Email.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
var error = "";

for (i = 0;i < checkStr.length;i++)
{
ch = checkStr.charAt(i);

for (j = 0;j < checkEmail.length;j++)
{

if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;

if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;

if (EmailAt && EmailPeriod)
break;

if (j == checkEmail.length)
break;
}

// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
EmailValid = true
break;
error = "";
}

}

if (!EmailValid)
{
error = " - Email must contain an \"@\" and a \".\"\n";
}

return error;
}

function check_forms()
{

var alertsay = ""; 

if ((document.forms[0].Email.value > "") && (document.forms[0].Select.value != "Email me with an answer to my enquiry"))
{
alertsay += checkemail();
}

// Compulsary Values
if (document.forms[0].Name.value == "")
{
alertsay += "- You must enter your Name\n";
}

if (document.forms[0].Organisation.value == "")
{
alertsay += "- You must enter a Organisation\n";
}

if (document.forms[0].Address1.value == "")
{
alertsay += "- You must enter a Address\n";
}

// Drop Down Select
if (document.forms[0].Select.value == "Email me with an answer to my enquiry")
{

if (document.forms[0].Email.value == "")
{
alertsay += "- You must enter a Email Address\n";
}

else
{
alertsay += checkemail();

}

}

else if (document.forms[0].Select.value == "Telephone me with an answer to my enquiry")
{

if (document.forms[0].Telephone.value == "")
{
alertsay += "- You must enter a Telephone Number\n";
}

}

else if (document.forms[0].Select.value == "Fax me with an answer to my enquiry")
{

if (document.forms[0].Fax.value == "")
{
alertsay += "- You must enter a Fax Number\n";
}

}

if (alertsay)
{
alert("The following error(s) occurred:\n" + alertsay.substring(alertsay,alertsay.length-1) + "\n\nForm would not be processed");
return false;
}

else
{

//alert("No errors occurred:\n" + "\n\nForm would be processed");

return true;
}

}