function swopOut(){
for (i=1; i<5; i++){
	var obj = document.getElementById('A'+i);
	if(obj){
	obj.src = eval('swopperimgout'+i).src;
	}
} 
for (i=1; i<5; i++){
	var obj = document.getElementById('B'+i);
	if(obj){
	obj.src = eval('swopperimgout'+(i+3)).src;
	}
} 
for (i=1; i<5; i++){
	var obj = document.getElementById('C'+i);
	if(obj){
	obj.src = eval('swopperimgout'+(i+5)).src;
	}
} 
}

var emailregexp = /^[\w\-\.]+@([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)*[a-zA-Z0-9]+-{0,1}[a-zA-Z0-9]+(-{0,1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,4}$/;
var daysInMonth = new Array();
	daysInMonth[1] = 31;
	daysInMonth[2] = 29;   // must programmatically check this
	daysInMonth[3] = 31;
	daysInMonth[4] = 30;
	daysInMonth[5] = 31;
	daysInMonth[6] = 30;
	daysInMonth[7] = 31;
	daysInMonth[8] = 31;
	daysInMonth[9] = 30;
	daysInMonth[10] = 31;
	daysInMonth[11] = 30;
	daysInMonth[12] = 31;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;


function chkForm(frmname,lang) {
	return checkForm(frmname);
}

var messages = new Array();
messages[0]="Bitte geben Sie Ihren Vornamen ein!"
messages[1]="Bitte geben Sie Ihren Nachnamen ein!"
messages[2]="Bitte geben Sie eine gültige E-Mail Adresse ein!"
messages[3]="Bitte geben Sie ein Passwort ein!"
messages[4]="Bitte geben Sie die Passwortwiederholung ein!"
messages[5]="Das Passwort und die Passwortwiederholung stimmen nicht überein!"
messages[6]="Ihr Passwort muss mindestens 5 Zeichen enthalten.\nVersuchen Sie es noch einmal!"

function checkForm(frmname){
	var frm = eval('document.forms[\''+frmname+'\']');

	if(frm["tx-srfeuserregister-pi1-email"]){
		if (frm["tx-srfeuserregister-pi1-email"].value == "" || !frm["tx-srfeuserregister-pi1-email"].value.match(emailregexp)) {
			alert(messages[2]);
			highlight(frm["tx-srfeuserregister-pi1-email"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-email"]);
	}
	if(frm["tx-srfeuserregister-pi1-password"]){
		if (frm["tx-srfeuserregister-pi1-password"].value == "") {
			alert(messages[3]);
			highlight(frm["tx-srfeuserregister-pi1-password"]);
			return false;
		}else{
			if(frm["tx-srfeuserregister-pi1-password"].value.length < 5){
			alert(messages[6]);
			highlight(frm["tx-srfeuserregister-pi1-password"]);
			return false;			
			}
			else removeHighlight(frm["tx-srfeuserregister-pi1-password"]);
		}
	}
	if(frm["tx-srfeuserregister-pi1-password_again"]){
		if (frm["tx-srfeuserregister-pi1-password_again"].value == "") {
			alert(messages[4]);
			highlight(frm["tx-srfeuserregister-pi1-password_again"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-password_again"]);
		if (frm["tx-srfeuserregister-pi1-password_again"].value != frm["tx-srfeuserregister-pi1-password"].value) {
			alert(messages[5]);
			highlight(frm["tx-srfeuserregister-pi1-password_again"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-password_again"]);
	}
	if(frm["tx-srfeuserregister-pi1-first_name"]){
		if (frm["tx-srfeuserregister-pi1-first_name"].value == "") {
			alert(messages[0]);
			highlight(frm["tx-srfeuserregister-pi1-first_name"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-first_name"]);
	}
	if(frm["tx-srfeuserregister-pi1-last_name"]){
		if (frm["tx-srfeuserregister-pi1-last_name"].value == "") {
			alert(messages[1]);
			highlight(frm["tx-srfeuserregister-pi1-last_name"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-last_name"]);
	}

/*	if(frm["tx-srfeuserregister-pi1-company"]){
		if (frm["tx-srfeuserregister-pi1-company"].value == "") {
			alert(messages[6]);
			highlight(frm["tx-srfeuserregister-pi1-company"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-password"]);
	}
	if(frm["tx-srfeuserregister-pi1-address"]){
		if (frm["tx-srfeuserregister-pi1-address"].value == "") {
			alert(messages[7]);
			highlight(frm["tx-srfeuserregister-pi1-address"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-address"]);
	}
	if(frm["tx-srfeuserregister-pi1-zip"]){
		if (frm["tx-srfeuserregister-pi1-zip"].value == "") {
			alert(messages[8]);
			highlight(frm["tx-srfeuserregister-pi1-zip"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-zip"]);
	}
	if(frm["tx-srfeuserregister-pi1-city"]){
		if (frm["tx-srfeuserregister-pi1-city"].value == "") {
			alert(messages[9]);
			highlight(frm["tx-srfeuserregister-pi1-city"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-city"]);
	}
	if(frm["tx-srfeuserregister-pi1-static_info_country"]){
		if (frm["tx-srfeuserregister-pi1-static_info_country"].value == "") {
			alert(messages[10]);
			highlight(frm["tx-srfeuserregister-pi1-static_info_country"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-static_info_country"]);
	}
	if(frm["tx-srfeuserregister-pi1-telephone"]){
		if (frm["tx-srfeuserregister-pi1-telephone"].value == "") {
			alert(messages[11]);
			highlight(frm["tx-srfeuserregister-pi1-telephone"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-telephone"]);
	}
	if(frm["tx-srfeuserregister-pi1-language"]){
		if (frm["tx-srfeuserregister-pi1-language"].value == "") {
			alert(messages[12]);
			highlight(frm["tx-srfeuserregister-pi1-language"]);
			return false;
		}else removeHighlight(frm["tx-srfeuserregister-pi1-language"]);
	}*/
//	if(frmname=='tx-srfeuserregister-pi1-fe_users_form') enc_form(frm);
	return true;
}

 
function removeHighlight(el){
	el.style.background = '#ffffff';
	el.style.color = '#000000';
//	if(isIE) el.style.border = '1px solid #7F9DB9';
	if(document.getElementById('p'+el.name))
	document.getElementById('p'+el.name).style.color = '#000000';
}
function highlight(el){
	el.focus();
	el.style.background = '#D20F27';
	el.style.color = '#ffffff';
	if(document.getElementById('p'+el.name))
	document.getElementById('p'+el.name).style.color = '#ffffff';
}

function checkFinder(){
	var frm = document.forms["productFinderForm"];
	if(frm.attach.value ==''){
		alert('Please select the material you want to attach');
		return false;
	}
	if(frm.to.value ==''){
		alert('Please select the material you want to attach');
		return false;
	}
	return true;
}
//##########################################
// Additional validation functions
//##########################################
function isNumber(val){
if (val == "") return false;
  for (var i = 0; i< val.length; i++) {
    if (val.charAt(i) < "0" || val.charAt(i) > "9")
      return false;
  }    
  return true;
}

//##########################################
function isIntegerInRange (intVar, intLow, intHigh){
    return ((intVar >= intLow) && (intVar <= intHigh));
}
//##########################################
function isDay (intDay){
	return isIntegerInRange (intDay, 1, 31);
}

function isMonth (intMonth){
	return isIntegerInRange (intMonth, 1, 12);
}

function isYear (intYear){
    return isIntegerInRange (intYear, 1900, 2009);
}

function daysInFebruary (intYear){		// February has 29 days in any year evenly divisible by four,
    								// EXCEPT for centurial years which are not also divisible by 400.
    return (  ((intYear % 4 == 0) && ( (!(intYear % 100 == 0)) || (intYear % 400 == 0) ) ) ? 29 : 28 );
}


//##########################################
function isDate (intYear, intMonth, intDay){
    if (! (isYear(intYear) && isMonth(intMonth) && isDay(intDay))) return false;

    // catch invalid days, except for February
    if (intDay > daysInMonth[intMonth]) return false; 

    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;

    return true;
}
//##########################################
function IsValidDate(strDate){
	var blnIsDate = false;
	
	var objRegExp = /^(\d{2})\.(\d{2})\.(\d{4})$/;
	blnIsDateFormat = objRegExp.test(strDate);
	if (blnIsDateFormat){
		objRegExp.exec(strDate);
		intDay 		= parseInt(RegExp.$1, 10);
		intMonth 	= parseInt(RegExp.$2, 10);
		
		if (RegExp.$3.length == 2){
			intYear = parseInt("19"+ RegExp.$3, 10);
		}
		else if(RegExp.$3.length == 4){
			intYear		= parseInt(RegExp.$3, 10);
		}
		else {
			return false;
		}
		blnIsDate = isDate(intYear,intMonth,intDay);
	}
	return blnIsDate;
}