Beanstock = {}
Beanstock.VERSION		= '1.0-20091214';
Beanstock.REQUIRED_PROTOTYPE	= '1.6.0.3';
Beanstock.IE			= (document.all) ? true : false;
Beanstock.LOADED		= false;
Beanstock.DEFAULT_COLOR		= '#f1eab5';
Beanstock.ERROR_COLOR		= '#ff9999';
Beanstock.SUCCESS_COLOR		= '#99cc99';
Beanstock.requireJS = function(libraryName) {
	document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
}
Beanstock.start = function () {
	function convertVersionString(versionString) {
		var v = versionString.replace(/_.*|\./g, '');
		v = parseInt(v + '0'.times(4-v.length));
		return versionString.indexOf('_') > -1 ? v-1 : v;
	}
	if((typeof Prototype=='undefined') ||
	  (typeof Element == 'undefined') ||
	  (typeof Element.Methods=='undefined') ||
	  (convertVersionString(Prototype.Version) <
	   convertVersionString(Beanstock.REQUIRED_PROTOTYPE)))
		throw("Beanstock requires Prototype JavaScript framework >= " + Beanstock.REQUIRED_PROTOTYPE);
	var js = /common\.js(\?.*)?$/;
	$$('head script[src]').findAll(function(s) {
		return s.src.match(js);
	}).each(function(s) {
		var path = s.src.replace(js, ''),
		includes = s.src.match(/\?.*load=([a-z,]*)/);
		//----- DEFAULT INCLUDES BELOW -----
		(includes ? includes[1] : 'effects,validate,swfobject').split(',').each(
			function(include) { Beanstock.requireJS(path+'library/'+include+'.js') });
	});
	Beanstock.LOADED = true;
}
Beanstock.loadLibrary = function (libName) {
	Beanstock.requireJS('/js/library/'+libName+'.js');
}
Beanstock.signalUser = function (el,testResult) {
	if(testResult)
		new Effect.Highlight(el,{
			startcolor: Beanstock.SUCCESS_COLOR,
			restorecolor: Beanstock.DEFAULT_COLOR
		});
	else
		new Effect.Highlight(el,{
			startcolor: Beanstock.ERROR_COLOR,
			restorecolor: Beanstock.DEFAULT_COLOR
		});		
}
Beanstock.is_array = function(testObject){   
    return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';
}
Beanstock.is_valid = function(filter,testEl){
	if(!filter.test(testEl))
		return false;
	return true;
}
Beanstock.is_email = function(testEl){	 
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	return Beanstock.is_valid(filter,testEl);	
}
Beanstock.is_name = function(testEl){	 
	var filter = /^[A-Za-z-'`\s]+$/;
	return Beanstock.is_valid(filter,testEl);	
}
Beanstock.is_not_blank = function(testEl){	 
	var filter = /\S/;
	return Beanstock.is_valid(filter,testEl);	
}
Beanstock.is_whole_number = function(testEl){	 
	var filter = /^\s*\d+\s*$/;
	return Beanstock.is_valid(filter,testEl);	
}
Beanstock.is_integer = function(testEl){	 
	var filter = /^\s*(\+|-)?\d+\s*$/;
	return Beanstock.is_valid(filter,testEl);	
}
Beanstock.is_decimal = function(testEl){	 
	var filter = /^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/;
	return Beanstock.is_valid(filter,testEl);	
}
Beanstock.is_currency = function(testEl){	 
	var filter = /^\s*(\+|-)?((\d+(\.\d\d)?)|(\.\d\d))\s*$/;
	return Beanstock.is_valid(filter,testEl);	
}
Beanstock.is_alpha = function(testEl){
	//TODO
}
Beanstock.is_phone = function(testEl){
	var filter = /^(\+|-|\(|\)|\d|\s|x)*$/;
	return Beanstock.is_valid(filter,testEl);
}
Beanstock.is_url = function(testEl){
	var filter = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;
	return Beanstock.is_valid(filter,testEl);
}


Beanstock.start();


/*
upload_number = 2;	
function newRowPlease(){
	newRow = document.getElementById("paydetails1").cloneNode(true);
	mycel = newRow.getElementsByTagName("td");
	mycel[0].innerHTML = 'Choice '+upload_number+':';
	blendTable = document.getElementById('insertPaymentTable').tBodies[0];
	blendTable.appendChild(newRow);
	upload_number++;
}
*/




upload_number = 2;	
function newRowPlease(){
	newRow = document.getElementById("paydetails1").cloneNode(true);
	mycel = newRow.getElementsByTagName("td");
	mycel[0].innerHTML = 'Choice '+upload_number+':';
	newRow.setAttribute('id','paydetails'+upload_number);
	blendTable = document.getElementById('insertPaymentTable').tBodies[0];
	blendTable.appendChild(newRow);
	upload_number++;
}


function rem(rows){

	var _row = rows.parentNode.parentNode;
	if(!(_row.id == 'paydetails1'))
		document.getElementById('insertPaymentTable').deleteRow(_row.rowIndex);
		
	upload_number--;

}





