function change_fontSize(font) {

	document.body.style.fontSize=font;
}


function jLaunchWindow( sURL, sWidth, sHeight ){
	sParams = "'directories=no,height=300,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,width=" + sWidth + ",height=" + sHeight + ",toolbar=no'"
	 newWin = window.open( sURL,'Help', sParams);
}

function jfIsValid( sValue, strValidChars  ) {
	var isValid = new Boolean()
	isValid=true
	var myChar=""
	var myInt=0

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=strValidChars.indexOf(myChar)

			if (myInt == -1) {
				isValid=false
				break;
			}
		}
	}
	else {
		isValid=false
	}

	return isValid
}

function jfIsDate(data,datename)
{

// function created : 31.12.03
// created by 		: Farrakh Aslam
// input paramaters : data     - the formname
//datename - the fieldname specified when calling the vbscript date box function
// description      : Can be used to validate any of the vbscript date box functions
data = "document." + data + "."

var day   = eval( data + datename + "_d.value")
var month = eval( data + datename + "_m.value")
var year  = eval( data + datename + "_y.value")

var calcYear = (year % 4 == 0)
if (!calcYear)
	{
	leapDays = 28
	}
else
	{
	leapDays = 29
	}

if (month == 02)
	{
	if (day > leapDays)
	   {
	   return false;
	   }


	}
else if (month == 04 || month == 06 || month == 09 || month == 11)
	{
	if (day > 30)
	   {
	   return false;
	   }

	}
return true;
}

function jfIsEmail(incoming) {

	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
		// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
		// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
		// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
		// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));

	var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/
		// index of -1 means "not found"
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) &&
		(email_regex.test(emailstring)) ) {
		  return true;
	} 
	else {
			return false;
	}
}

function jfIsPhoneNum( sValue ) {

	var isPhoneNum = new Boolean()
	isPhoneNum=true
	var myChar=""
	var myInt=0
	var strValidChars = "0123456789 ";

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=strValidChars.indexOf(myChar)

			if (myInt == -1) {
				isPhoneNum=false
			}
		}

	} else {
		isPhoneNum=false
	}
	
	return isPhoneNum
}

function jfIsInt( sValue ) {
	var isInteger = new Boolean()
	isInteger=true
	var myChar=""
	var myInt=0

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=parseInt(myChar)

			if (isNaN(myInt)) {
				isInteger=false
			}
		}

	} else {
		isInteger=false
	}

	return isInteger
}


function jcharacterlimit( iMax ){
	frm = document.frmComment
	if( frm.txtComment.value.length > iMax ){
		alert("The comment can not be greater than " + iMax + " charcters in length.")
	}
}

function jsumbitcomment( iMax ){
	frm = document.frmComment
	if( frm.txtComment.value.length > iMax ){
		alert("The comment can not be greater than " + iMax + " charcters in length.")
	}
	else{
		frm.submit()
	}
}

function jsubmitnews(){
	frm = document.frmNews
	frm.action = "news.asp"
	frm.submit()

}

/* FOR SUPPORT SYSTEMS */
function jmoreinfo(){

	t=document.getElementById("moreinfo");
	tbl=document.getElementById("tblmoreinfo");

	if ( tbl.style.display!="none" ){
		tbl.style.display="none";
		t.src='http://www.eroms.co.uk/images/down.png';
	}
	else{
		tbl.style.display="";
		t.src='http://www.eroms.co.uk/images/up.png';
	}

}

/*function jsOpenMenu( iOrder, iTotal ){

	for (i=1;i<=iTotal;i++) {
		
		o=document.getElementById("tab_" + i);
		//d=document.getElementById("div_" + i);
		t=document.getElementById("t_" + i);
				
		if ( iOrder == i){		
			o.className = "selectedMenu"
			//d.className = "selectedMenu"
			t.style.visibility="";
		}
		else{
			o.className = "menu1"
			//d.className = "menutab"
			t.style.visibility="hidden";
		}
				
	}

}*/

function jsOpenMenu( iOrder, iTotal ){

	for (i=1;i<=iTotal;i++) {
		
		o=document.getElementById("tab_" + i);
		d=document.getElementById("div_" + i);
		t=document.getElementById("t_" + i);
				
		if ( iOrder == i){
			o.className = "menu-tab-s"
			d.className = "menutab-s"
			t.style.display="block";
		}
		else{
			o.className = "menu-tab"
			d.className = "menutab"
			t.style.display="none";
		}
				
	}

}

function jsNewsLetter(){

	frm = document.frmNewsLetter

	// Name //
	if ( frm.txtName.value == ""){
		frm.txtName.focus()
		alert("Please enter your name.")
		return;
	}
	
	// Email Address //
	if ( frm.txtEmail.value == ""){
		frm.txtEmail.focus()
		alert("Please enter a valid email address.")
		return;
	}
	else if ( jfIsEmail(frm.txtEmail.value) == false){
		frm.txtEmail.focus()
		alert("Please enter a valid email address.")
		return;
	}

	frm.submit();

}

// MENU

function jmenu(sLink){

	frm = document.frmMenu
	frm.action = sLink
	frm.submit()

}

function jmenu_event_search(){
	frm = document.frmMenu
	frm.txtMode.value = 2
	frm.action = "event.asp"
	frm.submit()
}


// LAUNCH WINDOW

function jLaunchWindow( sURL, sWidth, sHeight ){
	sParams = "'directories=no,height=300,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,width=" + sWidth + ",height=" + sHeight + ",toolbar=no'"
     newWin = window.open( sURL,'Help', sParams);
}

// DATE FUNCTIONS

function jfIsDate(data,datename)
{

// function created : 31.12.03
// created by 		: Farrakh Aslam
// input paramaters : data     - the formname
//					  datename - the fieldname specified when calling the vbscript date box function
// description      : Can be used to validate any of the vbscript date box functions

var day   = eval("data." + datename + "_d.value")
var month = eval("data." + datename + "_m.value")
var year  = eval("data." + datename + "_y.value")


var calcYear = (year % 4 == 0)
if (!calcYear)
	{
	leapDays = 28
	}
else
	{
	leapDays = 29
	}

if (month == 02)
	{
	if (day > leapDays)
	   {
	   return false;
	   }
	}
else if (month == 04 || month == 06 || month == 09 || month == 11)
	{
	if (day > 30)
	   {
	   return false;
	   }

	}
return true;
}

// SERVICES

function jrollover( iImage, sImage ){

	var swapImage = document.getElementById(sImage);
	sImage = "images/" + sImage + "-" + iImage + ".gif";
	//alert(sImage)
	swapImage.src = sImage

}


	function jsubmit(){
		frm = document.frmContactUs
		var iError = -1
		cssNormal = "text-sml"
		cssRequired =  'text-red'
		cssInvalid =  'text-blue'

		sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- '()"


		// First Name //
		if (frm.txtName.value ==""){
			if ( iError == -1 ){ frm.txtName.focus()}
			iError = 1
			document.getElementById( 'tr_1' ).className = cssRequired
			alert("Please enter your name.")
			return;
		}
		else if (frm.txtName.value.length < 3){
			if ( iError == -1 ){ frm.txtName.focus()}
			iError = 1
			document.getElementById( 'tr_1' ).className = cssInvalid
			alert("Your name must be greater than 3 characters in length.")
			return;
		}
		else if (jfIsValid (frm.txtName.value, sAlpha) == false){
			if ( iError == -1 ){frm.txtName.focus()}
			iError = 1
			document.getElementById( 'tr_1' ).className = cssInvalid
			alert("Your name must contain alphabetic characters only.")
			return;
		}
		else {
			document.getElementById( 'tr_1' ).className = cssNormal
		}

	// Home Tel //
		if ( frm.txtHomeTel.value.length < 11 ){
			if ( iError == -1 ){ frm.txtHomeTel.focus()}
			iError = 9
			document.getElementById( 'tr_2' ).className = cssRequired
			alert("Please enter a valid home phone number.")
			return;
		}
		else if ( jfIsPhoneNum(frm.txtHomeTel.value) == false){
			if ( iError == -1 ){ frm.txtHomeTel.focus()}
			iError = 9
			document.getElementById( 'tr_2' ).className = cssInvalid
			alert("Please enter a valid home phone number.")
			return;
		}
		else {
			document.getElementById( 'tr_2' ).className = cssNormal
		}

		// Email Address //
		if ( frm.txtEmail.value == ""){
			if ( iError == -1 ){ frm.txtEmail.focus()}
			iError = 8
			document.getElementById( 'tr_4' ).className = cssRequired
			alert("Please enter your email address.")
			return;
		}
		else if ( jfIsEmail(frm.txtEmail.value) == false){
			if ( iError == -1 ){ frm.txtEmail.focus()}
			iError = 8
			document.getElementById( 'tr_4' ).className = cssInvalid
			alert("Please enter a valid email address.")
			return;
		}
		else {
			document.getElementById( 'tr_4' ).className = cssNormal
		}

	//===Submit form if no errors found ===/

		if ( iError == -1 ){
			frm.submit();
		}

	}


	function jrollover( iImage, sImage ){

		var swapImage = document.getElementById(sImage);
		sImage = "images/" + sImage + "-" + iImage + ".gif";
		//alert(sImage)
		swapImage.src = sImage

	}
	
  
  
  	function switch_style (style) {
      
      		document.getElementById('css').href=style;
  
	}


	// LOGIN


	function jsubmitlogin(){
		frm=document.frmLogin
		frm.submit()
		}

	function jlogin(){
		frm=document.frmLogin
		frm.txtMode.value = 2
		frm.action='SUPPORT/index.asp'
		frm.submit()
		}


	//mode 2
	function jsearch(){

		frm = document.frmSupport
		frm.action = "index.asp"
		frm.submit()
	}

	function jonclickgraph(iClient,iType,iStatus){

		frm = document.frmSupport
		frm.optClient.value = iClient
		frm.optType.value = iType
		frm.optStatus.value = iStatus
		frm.action = "event.asp"
		frm.submit()
	}
	
	// CONTACT
	
	function jContact(){
		frm = document.frmContactUs
		var iError = -1
		cssNormal = "text-sml"
		cssRequired =  'text-red'
		cssInvalid =  'text-blue'

		sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- '()"


		// First Name //
		if (frm.txtName.value ==""){
			if ( iError == -1 ){ frm.txtName.focus()}
			iError = 1
			alert("Please enter your name.")
			return;
		}
		else if (frm.txtName.value.length < 3){
			if ( iError == -1 ){ frm.txtName.focus()}
			iError = 1
			alert("Your name must be greater than 3 characters in length.")
			return;
		}
		else if (jfIsValid (frm.txtName.value, sAlpha) == false){
			if ( iError == -1 ){frm.txtName.focus()}
			iError = 1
			alert("Your name must contain alphabetic characters only.")
			return;
		}


	// Home Tel //
		if ( frm.txtHomeTel.value.length < 11 ){
			if ( iError == -1 ){ frm.txtHomeTel.focus()}
			iError = 9
			alert("Please enter a valid home phone number.")
			return;
		}
		else if ( jfIsPhoneNum(frm.txtHomeTel.value) == false){
			if ( iError == -1 ){ frm.txtHomeTel.focus()}
			iError = 9
			alert("Please enter a valid home phone number.")
			return;
		}


		// Email Address //
		if ( frm.txtEmail.value == ""){
			if ( iError == -1 ){ frm.txtEmail.focus()}
			iError = 8
			alert("Please enter your email address.")
			return;
		}
		else if ( jfIsEmail(frm.txtEmail.value) == false){
			if ( iError == -1 ){ frm.txtEmail.focus()}
			iError = 8
			alert("Please enter a valid email address.")
			return;
		}

	//===Submit form if no errors found ===/

		if ( iError == -1 ){
			frm.submit();
		}

	}	