function submitForm(){
	document.forms[0].submit();
}

//Text required, numeric required
function textRequiredChk(entered) {
	with (entered){
		if (value == null || value == "") {
			return false;
		}
		return true;
	}
}

//Text min length
function textMinChk(field, min) {
	//If the field is empty - return
	if(!textRequiredChk(field)){
		return true;
	}
	if ( field.value.length < min ){
		return false;
	}
	return true;
}

//Text max length
function textMaxChk(field, max) {
	//If the field is empty - return
	if(!textRequiredChk(field)){
		return true;
	}
	if ( max !='' && field.value.length > max ){
		return false;
	}
	return true;
}

//Text email
function textEmailChk(field) {
	//If the field is empty - return
	if(!textRequiredChk(field)){
		return true;
	}
	if ( field.value.length < 5 || field.value.indexOf("@") < 1 || field.value.indexOf(".") < 1) {
		return false;
	}
	return true;
}


//Text date
function textDateChk(field, pattern) {
	if(!textRequiredChk(field)){
		return true;
	}
	with (field) {
		var ok = buildDate(field.value, pattern);
		if (!ok) {
			return false;
		}
	}
	return true;
}


//Text regular expression ( + contains)
//For more infor about regExp: http://www.webreference.com/js/column5/index.html
function textRegExpChk(field, pattern) {
	//If the field is empty - return
	if(!textRequiredChk(field)){
		return true;
	}
	var regexp = new RegExp(pattern);
	var ok = regexp.test(field.value);
	if(!ok){
		return false;
	}
	return true;
}


// Rating required
function radioRequiredChk(fieldName) {
	var optionSelected = -1;
	for (i = 0; i < fieldName.length; i++) {
		if (fieldName[i].checked) {
			optionSelected = fieldName[i].value;
		}
	}
	if (optionSelected < 0) {
		return false;
	}
	return true;
}

//Dropdown required
function dropdownRequiredChk(entered) {
	with (entered) {
		if (value == "") {
			return false;
		}
		return true;
	}
}

//Dropdown min choice
function dropdownMinChk(entered, minSelected) {
	var selectedCounter = 0;
	var length = entered.length;
	for(i = 0; i < length; i++) {
		opt = entered.options[i];
		if(i == 0 && (opt.value == "") ){
		}else if (opt.selected){
			selectedCounter++;
		}
	}
	if (selectedCounter < minSelected){
		return false;
	}
	return true;
}

//Dropdown max choice
function dropdownMaxChk(entered, maxSelected) {
	var selectedCounter = 0;
	var length = entered.length;
	for(i = 0; i < length; i++) {
		opt = entered.options[i];
		if(i == 0 && (opt.value == "") ){
		}else if (opt.selected){
			selectedCounter++;
		}
	}
	if (selectedCounter > maxSelected){
		return false;
	}
	return true;
}

//Numeric required
function numericChk(entered, datatype) {
	//If the field is empty - return
	if(!textRequiredChk(entered)){
		return true;
	}
	with (entered) {
		var checkvalue = parseFloat(value);
		if (datatype.charAt(0)=="i"){
			checkvalue = parseInt(value);
			if (isNaN(checkvalue)){
				return false;
			}
		}
		if(value != checkvalue){
			return false;
		}
	}
	return true;
}

//Numeric minimum value
function numericMinChk(entered, datatype, minValue) {
	//If the field is empty - return
	if(!textRequiredChk(entered)){
		return true;
	}
	with (entered) {
		checkvalue = parseFloat(value);
		min = parseFloat(minValue);
		if (datatype.charAt(0)=="i"){
			checkvalue = parseInt(value);
			if (isNaN(checkvalue)){
				return true;
			}
		}
		if(value != checkvalue){
			return true;
		}
		if (checkvalue < min) {
			return false;
		}
	}
	return true;
}

//Numeric maximum value
function numericMaxChk(entered, datatype, maxValue) {
	//If the field is empty - return
	if(!textRequiredChk(entered)){
		return true;
	}
	with (entered) {
		checkvalue = parseFloat(value);
		max = parseFloat(maxValue);
		if (datatype.charAt(0)=="i"){
			checkvalue = parseInt(value);
			if (isNaN(checkvalue)){
				return true;
			}
		}
		if(value != checkvalue){
			return true;
		}
		if (checkvalue > max) {
			return false;
		}
	}
	return true;
}

//Multiple choice required
function multChoiceRequiredChk(fieldName) {
	var optionSelected = -1;
	for (i = 0; i < fieldName.length; i++) {
		if (fieldName[i].checked){
			optionSelected = fieldName[i].value;
		}
	}
	if (optionSelected == -1) {
		return false;
	}
	return true;
}

//Multiple choice minimum selections
function multChoiceMinChk(form, questionNo, optionCount, minSelected) {
	var selectedCounter = 0;
	for (i = 0; i < form.length; i++) {
		if (form.elements[i].type == "checkbox") {
			for (j = 0; j <= optionCount; j++) {
				if (form.elements[i].name == ("q" + questionNo + "multiple_" + j)) {
					if (form.elements[i].checked == true)
						selectedCounter++
				}
			}
		}
	}
	if (selectedCounter < minSelected){
		return false;
	}
	return true;
}

//Multiple choice maximum selections
function multChoiceMaxChk(form, questionNo, optionCount, maxSelected) {
	var selectedCounter = 0;
	for (i = 0; i < form.length; i++) {
		if (form.elements[i].type == "checkbox") {
			for (j = 0; j <= optionCount; j++) {
				if (form.elements[i].name == ("q" + questionNo + "multiple_" + j)) {
					if (form.elements[i].checked == true)
						selectedCounter++
				}
			}
		}
	}
	if (selectedCounter > maxSelected){
		return false;
	}
	return true;
}


function matrixGroupRequiredChk(form, fieldName, fra, to, reqSel){
	var log = "";
	var searchPos = 0;
	var name_;
	var selectedCounter = 0;
	for (p = fra; p <= to; p++) {
		name_ = fieldName + "_" + p;
		for (i = searchPos; i < form.length; i++) {
			if (form.elements[i].name == name_){
				searchPos = i;
				if(form.elements[i].checked == true){
					log = log + "selected " +
					selectedCounter++;
				}
			}
		}
		if(selectedCounter == reqSel){
			return true;
		}
	}
	return false;
}

function matrixRating(form, fieldName, fromRow, toRow, colCount){
	var name_;
	var checkedCount = 0;
	var i = 0;
	for (var p = fromRow; p <= toRow; p++) {
		checkedCount = 0;
		name_ = fieldName + "_" + p;
		i = getIndex(form, i, name_);
		if(i >= 0){
			for (var col = 0; col < colCount; col++) {
				if(form.elements[i].checked == true){
					checkedCount++;
				}
				i++;
			}
			if(checkedCount == 0){
				return false;
			}
		}
	}
	return true;
}

function checkRankingGroup(fieldName, fromCol, fromRow, toCol, toRow, form){
	var i = 0;
	var name_;
	var disabledColumns = new Array(toCol - fromCol);
	var disabledRows = new Array(toRow - fromRow);
	var rowFromCol;
	var checkName;


	for(p = fromRow; p <= toRow; p++) {
		rowFromCol = fromCol;
		i = findFirstRowCell(form, fieldName + rowFromCol, p, i);
		while(i < 0 && rowFromCol <  toCol){
			rowFromCol++;
			i++;
			i = findFirstRowCell(form, fieldName + rowFromCol, p, i);
		}
		if(i >= 0){
			for(col = rowFromCol; col <= toCol; col++) {
				var element = form.elements[i];
				checkName = fieldName + col + "_" + p;
				if(checkName == element.name){
					element.disabled = false;
					if(element.type == "checkbox" && element.checked == true){
						disabledColumns[col] = true;
						disabledRows[p] = true;
					}
					i++;
				}
			}
		}
	}

	i = 0;
	for(p = fromRow; p <= toRow; p++) {
		rowFromCol = fromCol;
		i = findFirstRowCell(form, fieldName + rowFromCol, p, i);
		while(i < 0 && rowFromCol <  toCol){
			rowFromCol++;
			i++;
			i = findFirstRowCell(form, fieldName + rowFromCol, p, i);
		}
		if(i >= 0){
			for(col = rowFromCol; col <= toCol; col++) {
				checkName = fieldName + col + "_" + p;
				var element = form.elements[i];

				if(element.name == checkName){
					if(disabledColumns[col] == true){
						if(!(element.type == "checkbox" && element.checked == true)){
							element.disabled = true;
						}
					}
					if(disabledRows[p] == true){
						if(!(element.type == "checkbox" && element.checked == true)){
							element.disabled = true;
						}
					}
					i++;
				}
			}
		}
	}
}

function findFirstRowCell(form, startName, colPos, from){
	var cellName = startName + "_" + colPos;
	var i = getIndex(form, from, cellName);
	return i;
}

function matrixGroupMinChk(form, fieldName, fromCol, toCol, fromRow, toRow, minSelected) {
	var name_;
	var checkedCount = 0;
	var i = 0;
	for(p = fromRow; p <= toRow; p++) {
		name_ = fieldName + fromCol + "_" + p;
		i = getIndex(form, i, name_);
		if(i >= 0){
			for(col = fromCol; col <= toCol; col++) {
				var element = form.elements[i];
				if(element.type == "checkbox" && element.checked == true){
					checkedCount++;
				}
				i++;
			}
		}
	}
	if(checkedCount < minSelected){
		return false;
	}
	return true;
}

function matrixGroupMaxChk(form, fieldName, fromCol, toCol, fromRow, toRow, maxSelected) {
	var name_;
	var checkedCount = 0;
	var i = 0;
	for(p = fromRow; p <= toRow; p++) {
		name_ = fieldName + fromCol + "_" + p;
		i = getIndex(form, i, name_);
		if(i >= 0){
			for(col = fromCol; col <= toCol; col++) {
				var element = form.elements[i];
				if(element.type == "checkbox" && element.checked == true){
					checkedCount++;
				}
				i++;
			}
		}
	}
	if(checkedCount > maxSelected){
		return false;
	}
	return true;
}


//************************************** Date validering *********************************
// http://javascript.internet.com/forms/validation-universal-date.html (with some changes)
/* Here's the list of tokens we support:
   m (or M) : month number, one or two digits.
   mm (or MM) : month number, strictly two digits (i.e. April is 04).
   d (or D) : day number, one or two digits.
   dd (or DD) : day number, strictly two digits.
   y (or Y) : year, two or four digits.
   yy (or YY) : year, strictly two digits.
   yyyy (or YYYY) : year, strictly four digits.
   mon : abbreviated month name (April is apr, Apr, APR, etc.)
   Mon : abbreviated month name, mixed-case (i.e. April is Apr only).
   MON : abbreviated month name, all upper-case (i.e. April is APR only).
   mon_strict : abbreviated month name, all lower-case (i.e. April is apr
		 only).
   month : full month name (April is april, April, APRIL, etc.)
   Month : full month name, mixed-case (i.e. April only).
   MONTH: full month name, all upper-case (i.e. APRIL only).
   month_strict : full month name, all lower-case (i.e. april only).
   h (or H) : hour, one or two digits.
   hh (or HH) : hour, strictly two digits.
   min (or MIN): minutes, one or two digits.
   mins (or MINS) : minutes, strictly two digits.
   s (or S) : seconds, one or two digits.
   ss (or SS) : seconds, strictly two digits.
   ampm (or AMPM) : am/pm setting.  Valid values to match this token are
		 am, pm, AM, PM, a.m., p.m., A.M., P.M.
*/
// Be careful with this pattern.  Longer tokens should be placed before shorter
// tokens to disambiguate them.  For example, parsing "mon_strict" should
// result in one token "mon_strict" and not two tokens "mon" and a literal
// "_strict".

var delimPat = /(-|\.|\/|:| )/i;
var tokPat = new RegExp("^month_strict|month|Month|MONTH|yyyy|YYYY|mins|MINS|mon_strict|ampm|AMPM|mon|Mon|MON|min|MIN|dd|DD|mm|MM|yy|YY|hh|HH|ss|SS|m|M|d|D|y|Y|h|H|s|S");

// lowerMonArr is used to map months to their numeric values.

var lowerMonArr={jan:1, feb:2, mar:3, apr:4, may:5, jun:6, jul:7, aug:8, sep:9, oct:10, nov:11, dec:12}

// monPatArr contains regular expressions used for matching abbreviated months
// in a date string.

var monPatArr=new Array();
monPatArr['mon_strict']=new RegExp(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/);
monPatArr['Mon']=new RegExp(/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/);
monPatArr['MON']=new RegExp(/JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC/);
monPatArr['mon']=new RegExp("jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",'i');

// monthPatArr contains regular expressions used for matching full months
// in a date string.

var monthPatArr=new Array();
monthPatArr['month']=new RegExp(/^january|february|march|april|may|june|july|august|september|october|november|december/i);
monthPatArr['Month']=new RegExp(/^January|February|March|April|May|June|July|August|September|October|November|December/);
monthPatArr['MONTH']=new RegExp(/^JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER/);
monthPatArr['month_strict']=new RegExp(/^january|february|march|april|may|june|july|august|september|october|november|december/);


// cutoffYear is the cut-off for assigning "19" or "20" as century.  Any
// two-digit year >= cutoffYear will get a century of "19", and everything
// else gets a century of "20".

var cutoffYear=50;

/* buildDate does all the real work.It takes a date string and format string,
 tries to match the two up, and returns a Date object (with the supplied date
 string value).If a date string doesn't contain all the fields that a Date
 object contains (for example, a date string with just the month), all
 unprovided fields are defaulted to those characteristics of the current
 date. Time fields that aren't provided default to 0.Thus, a date string
 like "3/30/2000" in "%mm/%dd/%yyyy" format results in a Date object for that
 date at midnight.formatStr is a free-form string that indicates special
 tokens via the % character.Here are some examples that will return a Date
 object:

 buildDate('3/30/2000','%mm/%dd/%y') // March 30, 2000
 buildDate('March 30, 2000','%Mon %d, %y') // Same as above.
 buildDate('Here is the date: 30-3-00','Here is the date: %dd-%m-%yy')

 If the format string does not match the string provided, an error message
 (i.e. String object) is returned.Thus, to see if buildDate succeeded, the
 caller can use the "typeof" command on the return value.For example,
 here's the dateCheck function, which returns true if a given date is
 valid,and false otherwise (and reports an error in the false case):

 function dateCheck(dateStr, formatStr) {
	var myObj = buildDate(dateStr,formatStr);
	if (typeof myObj=="object") {
		// We got a Date object, so good.
		return true;
	} else {
		// We got an error string.
		alert(myObj);
		return false;
	}
 }

*/
function buildDate(dateStr,formatStr) {
	// parse the format string first.
	var tokArr=parseFormatString(formatStr);
	var strInd=0;
	var tokInd=0;
	var intMonth;
	var intDay;
	var intYear;
	var intHour;
	var intMin;
	var intSec;
	var ampm="";
	var strOffset;

	// Create a date object with the current date so that if the user only
	// gives a month or day string, we can still return a valid date.

	var curdate=new Date();
	intMonth=curdate.getMonth()+1;
	intDay=curdate.getDate();
	intYear=curdate.getFullYear();

	// Default time to midnight, so that if given just date info, we return
	// a Date object for that date at midnight.

	intHour=0;
	intMin=0;
	intSec=0;

	// Walk across dateStr, matching the parsed formatStr until we find a
	// mismatch or succeed.

	while (strInd < dateStr.length && tokInd < tokArr.length) {
	// Start with the easy case of matching a literal.
		if (tokArr[tokInd].type=="literal") {
			if (dateStr.indexOf(tokArr[tokInd].token, strInd) == strInd) {
				// The current position in the string does match the format pattern.
				strInd+=tokArr[tokInd++].token.length;
				continue;
			} else {
				// ACK! There was a mismatch; return error.
				return false;
			}
		}

		// If we get here, we're matching to a symbolic token.
		switch (tokArr[tokInd].token) {
			case 'm':
			case 'M':
			case 'd':
			case 'D':
			case 'h':
			case 'H':
			case 'min':
			case 'MIN':
			case 's':
			case 'S':
				// Extract one or two characters from the date-time string and if
				// it's a number, save it as the month, day, hour, or minute, as
				// appropriate.

				curChar=dateStr.charAt(strInd);
				nextChar=dateStr.charAt(strInd+1);
				matchArr=dateStr.substr(strInd).match(/^\d{1,2}/);
				if (matchArr==null) {
					// First character isn't a number; there's a mismatch between
					// the pattern and date string, so return error.

					switch (tokArr[tokInd].token.toLowerCase()) {
						case 'd': var unit="day";
							break;
						case 'm': var unit="month"; break;
						case 'h': var unit="hour"; break;
						case 'min': var unit="minute"; break;
						case 's': var unit="second"; break;
					}
					return false;
				}
				strOffset=matchArr[0].length;
				switch (tokArr[tokInd].token.toLowerCase()) {
					case 'd': intDay=parseInt(matchArr[0],10); break;
					case 'm': intMonth=parseInt(matchArr[0],10); break;
					case 'h': intHour=parseInt(matchArr[0],10); break;
					case 'min': intMin=parseInt(matchArr[0],10); break;
					case 's': intSec=parseInt(matchArr[0],10); break;
				}
				break;
			case 'mm':
			case 'MM':
			case 'dd':
			case 'DD':
			case 'hh':
			case 'HH':
			case 'mins':
			case 'MINS':
			case 'ss':
			case 'SS':
				// Extract two characters from the date string and if it's a
				// number, save it as the month, day, or hour, as appropriate.
				strOffset=2;
				matchArr=dateStr.substr(strInd).match(/^\d{2}/);
				if (matchArr==null) {
					// The two characters aren't a number; there's a mismatch
					// between the pattern and date string, so return an error
					// message.
					return false;
				}
				switch (tokArr[tokInd].token.toLowerCase()) {
					case 'dd': intDay=parseInt(matchArr[0],10);break;
					case 'mm': intMonth=parseInt(matchArr[0],10);break;
					case 'hh': intHour=parseInt(matchArr[0],10); break;
					case 'mins': intMin=parseInt(matchArr[0],10); break;
					case 'ss': intSec=parseInt(matchArr[0],10); break;
				}
				break;
			case 'y':
			case 'Y':
				// Extract two or four characters from the date string and if it's
				// a number, save it as the year.Convert two-digit years to four
				// digit years by assigning a century of '19' if the year is >=
				// cutoffYear, and '20' otherwise.
				if (dateStr.substr(strInd,4).search(/\d{4}/) != -1) {
					// Four digit year.
					intYear=parseInt(dateStr.substr(strInd,4),10);
					strOffset=4;
				} else {
					if (dateStr.substr(strInd,2).search(/\d{2}/) != -1) {
						// Two digit year.
						intYear=parseInt(dateStr.substr(strInd,2),10);
						if (intYear>=cutoffYear) {
							intYear+=1900;
						}
						else {
							intYear+=2000;
						}
						strOffset=2;
					} else {
						// Bad year; return error.
						return false;
					}
				}
				break;
			case 'yy':
			case 'YY':
				// Extract two characters from the date string and if it's a
				// number, save it as the year.Convert two-digit years to four
				// digit years by assigning a century of '19' if the year is >=
				// cutoffYear, and '20' otherwise.
				if (dateStr.substr(strInd,2).search(/\d{2}/) != -1) {
					// Two digit year.
					intYear=parseInt(dateStr.substr(strInd,2),10);
					if (intYear>=cutoffYear) {
						intYear+=1900;
					}
					else {
						intYear+=2000;
					}
					strOffset=2;
				} else {
					// Bad year; return error
					return false;
				}
				break;
			case 'yyyy':
			case 'YYYY':
				// Extract four characters from the date string and if it's a
				// number, save it as the year.
				if (dateStr.substr(strInd,4).search(/\d{4}/) != -1) {
					// Four digit year.
					intYear=parseInt(dateStr.substr(strInd,4),10);
					strOffset=4;
				} else {
					// Bad year; return error.
					return false;
				}
				break;
			case 'mon':
			case 'Mon':
			case 'MON':
			case 'mon_strict':
				// Extract three characters from dateStr and parse them as
				// lower-case, mixed-case, or upper-case abbreviated months,
				// as appropriate.
				monPat=monPatArr[tokArr[tokInd].token];
				if (dateStr.substr(strInd,3).search(monPat) != -1) {
					intMonth=lowerMonArr[dateStr.substr(strInd,3).toLowerCase()];
				} else {
					// Bad month, return error.
					return false;
				}
				strOffset=3;
				break;
			case 'month':
			case 'Month':
			case 'MONTH':
			case 'month_strict':
				// Extract a full month name at strInd from dateStr if possible.
				monPat=monthPatArr[tokArr[tokInd].token];
				matchArray=dateStr.substr(strInd).match(monPat);
				if (matchArray==null) {
					// Bad month, return error.
					return false;
				}
				// It's a good month.
				intMonth=lowerMonArr[matchArray[0].substr(0,3).toLowerCase()];
				strOffset=matchArray[0].length;
				break;
			case 'ampm':
			case 'AMPM':
				matchArr=dateStr.substr(strInd).match(/^(am|pm|AM|PM|a\.m\.|p\.m\.|A\.M\.|P\.M\.)/);
				if (matchArr==null) {
					// There's no am/pm in the string.Return error msg.
					return false;
				}
				// Store am/pm value for later (as just am or pm, to make things
				// easier later).
				if (matchArr[0].substr(0,1).toLowerCase() == "a") {
					// This is am.
					ampm = "am";
				}
				else {
					ampm = "pm";
				}
				strOffset = matchArr[0].length;
				break;
			default:
				break;
		}
		strInd += strOffset;
		tokInd++;
	}
	if (tokInd != tokArr.length || strInd != dateStr.length) {
		/* We got through the whole date string or format string, but there's
		more data in the other, so there's a mismatch. */
		return false;
	}
	// Make sure all components are in the right ranges.
	if (intMonth < 1 || intMonth > 12) {
		return false;
	}
	if (intDay < 1 || intDay > 31) {
		return false;
	}
	// Make sure user doesn't put 31 for a month that only has 30 days

	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && intDay == 31) {
		return false;
	}
	// Check for February date validity (including leap years)
	if (intMonth == 2) {
		// figure out if "year" is a leap year; don't forget that
		// century years are only leap years if divisible by 400
		var isleap=(intYear%4==0 && (intYear%100!=0 || intYear%400==0));
		if (intDay > 29 || (intDay == 29 && !isleap)) {
			return false;
		}
	}
	// Check that if am/pm is not provided, hours are between 0 and 23.

	if (ampm == "") {
		if (intHour < 0 || intHour > 23) {
			return false;
		}
	} else {
		// non-military time, so make sure it's between 1 and 12.
		if (intHour < 1|| intHour > 12) {
			return false;
		}
	}
	// If user specified amor pm, convert intHour to military.

	if (ampm=="am" && intHour==12) {
		intHour=0;
	}
	if (ampm=="pm" && intHour < 12) {
		intHour += 12;
	}
	if (intMin < 0 || intMin > 59) {
		return false;
	}
	if (intSec < 0 || intSec > 59) {
		return false;
	}
	return true;
}

// FormatToken is a datatype we use for storing extracted tokens from the
// format string.

function FormatToken (token, type) {
	this.token=token;
	this.type=type;
}

function parseFormatString (formatStr) {
	var tokArr=new Array;
	var tokInd=0;
	var strInd=0;
	var foundTok=0;
	while (strInd < formatStr.length) {
		var charAtpos = formatStr.charAt(strInd);
		if( charAtpos.match(delimPat) ){
			tokArr[tokInd++] = new FormatToken(charAtpos, "literal");
			strInd += 1;
		}else if ((matchArray=formatStr.substr(strInd).match(tokPat)) != null) {
				strInd += matchArray[0].length;
				tokArr[tokInd++] = new FormatToken(matchArray[0], "symbolic");
		}
	}
	return tokArr;
}

function getIndex(what, from, which) {
	for (var i = from; i < what.elements.length; i++){
		if (what.elements[i] != null && what.elements[i].name == which){
			return i;
		}
	}
	return -1;
}

function reloadSurveyWindow(){
	document.location.reload();
}

// detect Netscape 4 function
function isNetscape4(){
	var browserName = navigator.appName.toLowerCase();
	if (browserName.indexOf('netscape') > (-1) && parseInt(navigator.appVersion) < 5 ){
		return true;
	} else {
		return false;
	}
}

function uploadFile(systemurl, form, formName, freeTextField){
	if(form.s == null || form.r == null){
		return false;
	}
	var name = "upload_w";
	var uploadUrl = systemurl + "/rupload?sId=" + form.s.value + "&rId=" + form.r.value + "&en=" + form.enc.value;
	uploadUrl = uploadUrl + "&ticket=" + form.ticket.value + "&fn=" + formName +"&tan=" + freeTextField + "&lang=" + form.lang.value;
	var features ="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=1,resizable=1,width="+500+",height="+300;
	window.open(uploadUrl, name, features);
}
