/*
* WebShopForm
* 
* @brief: form handling for webshop
*/
function WebShopForm() {
	this.typeEmail = '^[A-Za-z0-9-_]+([.][A-Za-z0-9-_]+){0,3}@[A-Za-z0-9-_]{2,}([.][A-Za-z0-9-_]+){0,3}[.][A-Za-z]{2,4}$';
	this.typeChars = '^[a-zA-Z]xxx$';
	this.typeCharsAndNumbers = '^[a-zA-Z0-9]xxx$';
	this.typeNumbersDecimal = '^[0-9]xxx$';
	this.typeNumbersFloat = '^([0-9]+(.|,)[0-9]*)xxx$';
	this.regexps = {
		cikkszam: '^[a-zA-Z0-9-][a-zA-Z0-9- ]{0,19}$', 
		deliveryname: '^[a-zA-Z0-9- \\u00C0-\\u024F]{1,29}$',  
		deliveryamount: '^[0-9]{1,5}$', 
		cikkrovidleiras: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{0,139}$', 
		cikkbullet: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{1,50}$', 
		tag: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{3,30}$', 
		supplier: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{3,30}$', 
		categoryname: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{1,30}$', 
		brandname: '^[a-zA-Z0-9- \\u0022\\u00C0-\\u024F]{1,30}$', 
		packagename: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{1,50}$', 
		newstitle: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{3,100}$', 
		newscontent: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{3,250}$', 
		validname: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{1,9000}$',
//		cikkleiras: '^[a-zA-Z0-9- ;,/%:&\'\\u00B5\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\n\r]{0,9000}$', 
		cikkleiras: '[^$]|^$', 
//		cikkar: '^[0-9]{1,8}([.]{1}[0-9]{1,3}){0,1}$', 
		cikkar: '^[0-9\.]{1,30}$', 
		productdeliveryprice: '^$|^[0-9\.]{1,30}$',
		cikkparamar: '^[0-9]{1,8}([.]{1}[0-9]{1,3}){0,1}$', 
		cikkparamardist: '^[0-9]{1,8}([.]{1}[0-9]{1,3}){0,1}$', 
		elerhetosegideje: '^[a-zA-Z0-9-\\u00C0-\\u024F]{2,30}$', 
		elerhetosegidejereg: '(^$)|(^[a-zA-Z0-9-\\u00C0-\\u024F]{2,30}$)', 
		cegnev: '^[a-zA-Z0-9- ,.&+\\u00C0-\\u024F]{3,50}$', 
		cegnevreg: '(^$)|(^[a-zA-Z0-9- ,.&+\\u00C0-\\u024F]{3,50}$)', 
		cim: '^[a-zA-Z0-9- ,/\.\\u00C0-\\u024F]{5,100}$', 
		cikknev: '^[a-zA-Z0-9-\\u00C0-\\u024F][a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{0,139}$', 
		megjegyzes: '^[a-zA-Z0-9-\\u00C0-\\u024F][a-zA-Z0-9- ,\\u00C0-\\u024F]{0,250}$', 
		megjegyzes2: '^$|^[a-zA-Z0-9- ,.?!\r\n\\u00C0-\\u024F]{0,250}$', // rendelés megjegyzés 
		vezeteknev2: '^[a-zA-Z0-9-\\u00C0-\\u024F][a-zA-Z0-9- ,\\u00C0-\\u024F]{3,100}$', 
		multiline300: '^[a-zA-Z0-9- $:"()*_&@;€,.\+?!/%\\u00C0-\\u024F\\r\n]{0,300}$', 
		uzenet: '^[a-zA-Z0-9- $:"()*_&@;€,.\+?!/%\\u00C0-\\u024F\\r\n]{1,300}$', 
		uzenet2: '^[A-Za-z0-9\\u00C0-\\u024F][A-Za-z0-9.\\u00C0-\\u024F -.!?_\r\n]{2,200}$', // wsProduct.details
		egyseg: '^[a-zA-Z\\u00C0-\\u024F]{1,6}$', 
		varos: '^[a-zA-Z-\\u00C0-\\u024F]{2,20}$', 
		vezeteknev: '^[a-zA-Z- \\u00C0-\\u024F]{2,100}$', 
		newslettername: '^[a-zA-Z- \\u00C0-\\u024F]{7,30}$', 
		keresztnev: '^[a-zA-Z- \\u00C0-\\u024F]{3,100}$', 
		keresztnevblank: '^$|^[a-zA-Z- \\u00C0-\\u024F]{3,30}$', 
		teljesnev: '^[A-Za-z\\u00C0-\\u024F][A-Za-z.\\u00C0-\\u024F -]{2,49}$', 
		adoszam: '^$|^[0-9]{8}[-][0-9][-][0-9]{2}$', 
		irszam: '^[A-Z0-9- ]{3,}$', 
		telszam: '^[+]{0,1}[0-9]{6,}$', 
		telszamreg: '(^$)|(^[+]{0,1}[0-9]{6,}$)', 
		telszamregnoblank: '(^[+]{0,1}[0-9]{6,}$)',
		email: '^[A-Za-z0-9-_]+([.][A-Za-z0-9-_]+){0,3}@[A-Za-z0-9-_]{2,}([.][A-Za-z0-9-_]+){0,3}[.][A-Za-z]{2,4}$', 
		password: '^[a-zA-Z0-9]{4,9}$', 
		kedvezmeny: '^$|^[1-9]{1}[0-9.]{0,2}[0-9]{0,2}$', 
		targy: '^[0-9A-Za-z\\u00C0-\\u024F][0-9A-Za-z\\u00C0-\\u024F -.,?!;()%*\'"]{0,100}$', 
		targy2: '^[0-9A-Za-z\\u00C0-\\u024F][0-9A-Za-z\\u00C0-\\u024F -.,?!;()%*\'"]{2,49}$', 
		forgalom: '^[1-9][0-9]{0,7}$', 
		szazalek: '^[1-9]{1}[0-9.]{0,2}[0-9]{0,2}$', 
		darabszam: '^[0-9-][0-9- ]{0,19}$', 
		date2010_22_03: '^$|^20[1-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) (0[012]|2[23]):([0-5][0-9])$', 
		datetime: '^20[1-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) ([012][0-9]):([0-5][0-9]):([0-5][0-9])$', 
		datetimeblank: '^$|^20[1-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) ([012][0-9]):([0-5][0-9]):([0-5][0-9])$', 
		dateblank: '^$|^20[1-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$', 
		datebest_before: '^0000-00-00|^20[1-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$', 
		birthblank: '^$|^19[0-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])|^20[0-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$', 
		namedayblank: '^$|^(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$', 
		date: '^20[1-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$', 
		akcio_mertek: '^[1-9]{1}[0-9]{0,7}$', 
		akcio_szazalek: '^[1-9]{1}[0-9.]{0,2}[0-9]{0,2}$', 
		newslettertitle: '^[a-zA-Z0-9- ,/\.\\u00C0-\\u024F]{5,50}$', 
		newsletterbody: '^[a-zA-Z0-9- \'\"+!%=()-_:?&#,/\.\\u00C0-\\u024F]{5,500}$', 
		beszcikkszam: '^$|^[a-zA-Z0-9-][a-zA-Z0-9- ]{0,19}$', 
		beszazon: '^$|^[a-zA-Z0-9-][a-zA-Z0-9- ]{0,19}$', 
		answertext: '^$|^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{1,9000}$', 
		answertitle: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{1,100}$',
		answerquestion: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{1,200}$',
		topictitle: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{1,100}$',
		baskettname: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{1,100}$',
		pagesadmininput: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F\\\r\n]{1,100}$',
		deliveryprice: '^$|^[0-9]{1,8}$|^[0-9]+[\\.,][0-9]+$', 
		detailedratingcomment: '^$|^[a-zA-Z0-9- ;,?.\\\'\"+!%/=()\r\n\\u00C0-\\u024F]{0,150}$',
		nonblank: '[^$]',
		jovairas_huf: '^[1-9]{1}[0-9]{0,9}$',
		jovairas_point: '^[0-9]{1,10}$',
		bevaltas_point: '^[0-9]{0,10}$',
		kuponnapok: '^[0-9]{0,3}$',
		kuponertek: '^[0-9]{1,8}([.]{1}[0-9]{1,3}){0,1}$',
		cikkleiras: '[^$]|^$',
		product_option: '^[a-zA-Z0-9-\\u00C0-\\u024F][a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{2,199}$',
		event_title: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{3,100}$',
		event_from: '(^[1-2][0-9][0-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$)|(^[1-2][0-9][0-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) ((([0-1][0-9])|(2[0-3])):[0-5][0-9])$)',
		event_to: '(^$)|(^[1-2][0-9][0-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$)|(^[1-2][0-9][0-9][0-9]-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) ((([0-1][0-9])|(2[0-3])):[0-5][0-9])$)',
		event_location: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{0,100}$',
		event_description: '^[a-zA-Z0-9- ;,/%:&\'\\u0022\\*\\\\?!\.\+()\\u00C0-\\u024F]{0,255}$',
		barcode: '(^$)|(^[a-zA-Z0-9-][a-zA-Z0-9- ]{0,200})$',
		prodcode: '(^$)|(^[a-zA-Z0-9-][a-zA-Z0-9- ]{0,19})$',
		loyaltypoints: '(^$)|(0)|(^[0-9]{0,8})$',
		cardcode: '(^$)|(^[a-zA-Z0-9- ._]{0,50})$',
		seoprodname: '(^$)|(^[a-zA-Z][a-zA-Z0-9-_]{0,140})$',
		seocatname: '(^$)|(^[a-z0-9-_]{0,30})$',
		seobrandname: '(^$)|(^[a-z0-9-_]{0,30})$',
		seoforumtopicname: '(^$)|(^[a-z0-9-_]{0,100})$',
		seotagname: '(^$)|(^[a-z0-9-_]{0,30})$',
		seopagename: '(^$)|(^[a-z0-9-_]{0,100})$',
		prodsize: '(^$)|(^[0-9\.x]{0,20})$',
		prodweight: '(^$)|(^[0-9\.]{0,5})$',
		piecesofpackage: '(^$)|(^[0-9\.]{0,5})$',
		url: '^http:\/\/[A-Za-z0-9-.]{3,}$', 
		urlblank: '(^$)|^http:\/\/[A-Za-z0-9-./_-&=]{3,}$', 
		blank: '^$',
		deliveryname2: '^[a-zA-Z0-9-_() \\u00C0-\\u024F]{1,100}$',
		deliveryfree: '(^$)||(^[0-9\.]{1,20}$)',
		manufacturer: '^[a-zA-Z0-9- ,/\.\\u00C0-\\u024F]{0,250}$',
		raw_material: '^$|^[a-zA-Z0-9- ,.?!\r\n\\u00C0-\\u024F]{0,255}$',
		event_location_name: '^[a-zA-Z0-9- ,/\.\\u00C0-\\u024F]{0,255}$',
		event_location_address: '^[a-zA-Z0-9- ,/\.\\u00C0-\\u024F]{0,255}$',
		event_location_time: '^[0-2][0-9]:[0-5][0-9]$',
		event_location_cellintervall: '^([5])|([9][0])|([1,2,3,4,5,6,7,8][0,5])$',
		event_location_day: '^[0-2][0-9][0-9][0-9]-(([0][1-9])|([1][0,1,2]))-(([0][1-9])|([1,2][0-9])|([3][0,1]))$'
	}
}

/*
* WebShopForm.validate
* 
* @brief: validates form elements based on checkContent
* @args:	obj:Obj - form obj
*			command:String - javascript command to execute upon success validation
*			divName:String - name of the div element, to fill with error message
*			errorStr:String - custom error message (optional)
* @return:	boolean, result of the validation
*
*/
WebShopForm.prototype.validate = function( obj , command , divName , errorStr ) {
	if( core.checkform( obj ) ) {
		eval( command.replace( /this/ , 'obj' ) );	// execute command
		return true
	} else {
		if( divName != null ) {
			if( get( divName ) != null ) {				// div létezik
				if( typeof( errorStr ) == 'string' ) {
					get( divName ).innerHTML = errorStr;
				} else {
					var notValidMsg = get( "phrase_form_not_filled_properly" ) ? get( "phrase_form_not_filled_properly" ).value : "Az űrlap mezői nem megfelelően vannak kitöltve!";
					get( divName ).innerHTML = notValidMsg;
				}
			}
		}
	}
	return false
}

/*
* WebShopForm.checkContent
* 
* @brief: sets fiorm element validation regexp
* @args:	obj:Obj - formelement obj
*			type:String - validation type, concrate type defined in this class or regexp to execute
*			exactLen:String - if concrate type has exact length var (optional)
*			lenMin:String - if concrate type has min length var (optional)
*			lenMax:String - if concrate type has max length var (optional)
* @return:	boolean, result of the validation
*
*/
WebShopForm.prototype.checkContent = function( obj , type , exactLen , lenMin , lenMax ) {
	var lenStr = '';
	
	if( typeof( exactLen ) == 'string' ) {		// builds regexp with length
		lenStr = '{' + exactLen + '}';
	} else {
		if( ( typeof( lenMin ) == 'string' ) && ( typeof( lenMax ) == 'string' ) ) {
			lenStr = '{' + lenMin + ',' + lenMax + '}';
		} else if( typeof( lenMin ) == 'string' ) {
			lenStr = '{' + lenMin + ',}';
		} else if( typeof( lenMax ) == 'string' ) {
			lenStr = '{,' + lenMax + '}';
		}
	}
	
	if( type == 'email' ) {	// exact types
		return core.checkinput( obj , this.typeEmail.replace( /xxx/ , lenStr ) );
	} else if( type == 'string' ) {
		return core.checkinput( obj , this.typeChars.replace( /xxx/ , lenStr ) );
	} else if( type == 'alphanumeric' ) {
		return core.checkinput( obj , this.typeCharsAndNumbers.replace( /xxx/ , lenStr ) );
	} else if( type == 'decimal' ) {
		return core.checkinput( obj , this.typeNumbersDecimal.replace( /xxx/ , lenStr ) );
	} else if( type == 'float' ) {
		return core.checkinput( obj , this.typeNumbersFloat.replace( /xxx/ , lenStr ) );
	} else {	// try to interpret as regexp
		if (typeof(type) == 'string' && this.regexps[type]) type = this.regexps[type]
		return core.checkinput( obj , type );
	}
}

/*
* WebShopForm.checkMatch
* 
* @brief: checks two form element's equality based on a regexp
* @args:	el1:Obj - formelement obj
*			el2:Obj - validation type, concrate type defined in this class or regexp to execute
*			regexp:String - if concrate type has exact length var (optional)
*			lenMin:String - if concrate type has min length var (optional)
*			lenMax:String - if concrate type has max length var (optional)
* @return:	boolean, result of the validation
*
*/
WebShopForm.prototype.checkMatch = function( el1 , el2 , regexp ) {
	if( ws.wsUtil.isAdmin ) {
		return this.checkMatchAdmin( el1 , el2 , regexp );
	}
	
	if( !el1.onkeyup ) {
		this.checkContent( el1 , regexp );
		this.checkContent( el2 , regexp );
	} else {
		core.oninput( el1 );
		core.oninput( el2 );
	}
	
	if( el1.value != el2.value ) {
		core.addclass( el1 , 'invalid' );
		core.addclass( el2 , 'invalid' );
	}
	return true;
}

// check_match admin tplben
WebShopForm.prototype.checkMatchAdmin = function( el1 , el2 , allowempty ) {
	if( el1.value == el2.value ) {
		core.delclass( el1 , 'invalid' );
		core.delclass( el2 , 'invalid' );
		match = true;
	} else {
		core.addclass( el1 , 'invalid' );
		core.addclass( el2 , 'invalid' );
		match = false;
	}
	
	return match;
}


// select_onchange
WebShopForm.prototype.selectOnChange = function( el , field , skip ) {
	if( field.custom == undefined ) this.checkContent( field , '^$' );
	if (field.name == 'datumtol' || field.name == 'datumig') { 
		
		switch( el.selectedIndex ) {
			case 1: 
			case 2: 
				if (get('datumtol').value != '' || get('datumig').value != '') {
					if (get('datumig').custom != undefined) get('datumig').custom.regexp = new RegExp( this.regexps.date ); 
					if (get('datumtol').custom != undefined) get('datumtol').custom.regexp = new RegExp( this.regexps.date ); 
				}
				if (get('datumtol').value == '' && get('datumig').value == '') {
					if (get('datumig').custom != undefined)	get('datumig').custom.regexp = new RegExp( this.regexps.blank ); 
					if (get('datumtol').custom != undefined) get('datumtol').custom.regexp = new RegExp( this.regexps.blank ); 
				}
			break;
			default: field.custom.regexp = new RegExp( this.regexps.blank ); break;
		}
	}
	else {
		switch( el.selectedIndex ) {
			case 1: field.custom.regexp = new RegExp( this.regexps.akcio_mertek ); break;
			case 2: field.custom.regexp = new RegExp( this.regexps.akcio_szazalek ); break;
			default: field.custom.regexp = new RegExp( this.regexps.blank ); break;
		}
	}
	
	if( !skip ) field.onkeyup();
}

WebShopForm.prototype.checkSearchForm = function( frm ) {
	inp = frm.elements[ 0 ];
	if( inp.value.length < 4 ) {
		return false;
	}
	
	frm.submit();
	
	return true;
}

WebShopForm.prototype.disableEnterKey = function( e ) {
	var key;

	if( window.event ) key = window.event.keyCode;     //IE
	else key = e.which;     //firefox

	if( key == 13 ) return false;
	else return true;
}

WebShopForm.prototype.enablerOnChkBox = function( chkboxObj , defaultValue , inputIds ) {
	var inputs = new Array();
	var tempFormElement = null;
	inputs = inputIds.split( ',' );
	
	for( i = 0 ; i < inputs.length ; i++ ) {
		tempFormElement = get( inputs[ i ] );
		if( chkboxObj.checked ) {
			tempFormElement.enable();
		} else {
			tempFormElement.value = defaultValue;
			tempFormElement.disable();
		}
	}
}

WebShopForm.prototype.disablerOnChkBox = function( chkboxObj , defaultValue , inputIds ) {
	var inputs = new Array();
	var tempFormElement = null;
	inputs = inputIds.split( ',' );

	for( i = 0 ; i < inputs.length ; i++ ) {
		tempFormElement = get( inputs[ i ] );
		if( !chkboxObj.checked ) {
//			tempFormElement.enable();
			tempFormElement.disabled = false;
		} else {
			tempFormElement.value = defaultValue;
//			tempFormElement.disable();
			tempFormElement.disabled = true;
		}
	}
}


WebShopForm.prototype.nextImageCounter = function(i) {
	var i;
	return this.imageCounter == undefined ? (this.imageCounter = 1) : ++this.imageCounter + i; 
	
}

WebShopForm.prototype.nextMiscFileCounter = function( i ) {
	var i;
	return this.miscFileCounter == undefined ? ( this.miscFileCounter = 1 ) : ++this.miscFileCounter + i; 
}


WebShopForm.prototype.changeDefaultImage = function(el, val) {
	if (!el || !el.form || !val) return;
	var prev = 0
	if (el.form.default_product_image.value && (prev = el.form["default_image_" + el.form.default_product_image.value]))
		core.delclass(prev, "image_submit_active")
	el.form.default_product_image.value = val;
	core.addclass(el, "image_submit_active")
}

WebShopForm.prototype.toggleDeleteImage = function(el, val) {
	if (!el || !el.form || !val) return;
	if (this.delete_images == undefined) this.delete_images = { }
	if (this.delete_images[val]) delete this.delete_images[val]
	else this.delete_images[val] = val
	if (this.delete_images[val]) core.addclass(el, "image_submit_active")
	else core.delclass(el, "image_submit_active")
}

WebShopForm.prototype.toggleDeleteFile = function( el , id ) {
	core.addclass( el , 'file_delete_inactive' );
	get( 'miscfile_delete_' + id ).value = 'del';
}


WebShopForm.prototype.updateImages = function(form) {
	if (!form || !form.delete_product_images) return
	if (this.delete_images == undefined) this.delete_images = { }
	form.delete_product_images.value = core.values(this.delete_images).join(",")
	this.delete_images = { }
	this.imageCounter = 0
}

WebShopForm.prototype.refreshBasketWithNo = function( inputId , dir , pieces) {
	var noOfElement = parseInt( document.getElementById( inputId ).value );
	if( isNaN( noOfElement ) ) {
		noOfElement = pieces;
	} else {
		if( dir == 1 ) noOfElement = noOfElement + pieces;
		else if( dir == -1 ) {
			if( noOfElement > 0 ) noOfElement = noOfElement + pieces;
		}
	}
	document.getElementById( inputId ).value = noOfElement;
	document.getElementById( 'lastupdated' ).value = inputId;
	ajax.load( 'public/basket/refreshbasket' , get( 'kosarform' ) );
}

WebShopForm.prototype.setChkBoxes = function( prefix , toCheck , alternateObj ) {
	var inputs = document.getElementsByTagName( 'input' );
	for( var i = 0 ; i < inputs.length ; i++ ) {
		if( inputs[ i ].type == 'checkbox' ) {
			if( inputs[ i ].id.indexOf( prefix + '_' ) != -1 ) {	// jó a kezdete az idnek
				var id = inputs[ i ].id.substring( inputs[ i ].id.lastIndexOf( '_' ) + 1 );		// az előző feltétel miatt itt már biztos hogy van _
				if( isNaN( parseInt( id ) ) ) continue;		// ha nem értelmezhető, akkor hanyagoljuk
				inputs[ i ].checked = toCheck;
			}
		}
	}
	
	if( typeof( alternateObj ) == 'string' ) {
		var objs = alternateObj.split( ',' );
		for( var j = 0 ; j < objs.length ; j++ ) {
			if( get( objs[ j ] ) != null ) get( objs[ j ] ).checked = toCheck;
		}
	}
}

WebShopForm.prototype.doMultipleProcess = function( prefix , modul , functionName, extraParams ) {
	if( functionName == 0 ) return false;
	var inputs = document.getElementsByTagName( 'input' );
	var ids = '';
	var values = '';
	var newValues01 = '';			// egyéb dolgok átadására, newValuesxx formában, attól függően, hogy hány plusz paramétert kell kiszedni
	var newValues02 = '';			// egyéb dolgok átadására, newValuesxx formában, attól függően, hogy hány plusz paramétert kell kiszedni
	var newValues03 = '';
	for( var i = 0 ; i < inputs.length ; i++ ) {
		if( inputs[ i ].type == 'checkbox' ) {
			if( inputs[ i ].id.indexOf( prefix + '_' ) != -1 ) {	// jó a kezdete az idnek
				var id = inputs[ i ].id.substring( inputs[ i ].id.lastIndexOf( '_' ) + 1 );		// az előző feltétel miatt itt már biztos hogy van _
				if( isNaN( parseInt( id ) ) ) continue;		// ha nem értelmezhető, akkor hanyagoljuk
				ids += id + ',';		// összefűzzük az idket
				values += inputs[ i ].checked + ',';
				if( functionName == 'setvisibleall' ) {
				} else if( functionName == 'deleteall' ) {
				} else if( functionName == 'modifyall' ) {
					if( modul == 'orders' ){
						newValues01 += get( 'stateNew_' + id ).value + ',';
						newValues02 += ( get( 'deliveryprice_' + id ) != null && get( 'deliveryprice_' + id ).value != '' ? get( 'deliveryprice_' + id ).value : 0 ) + ',';
						newValues03 += ( get( 'deliverydate_' + id ) != null && get( 'deliverydate_' + id ).value ? get( 'deliverydate_' + id ).value : 0 ) + ',';
					}
					else if( modul == 'coupon' ) newValues01 += get( 'priceNew_' + id ).value + ',';
					else if( modul == 'products/options' ) newValues01 += get( 'label_' + id ).value + '#';
					else if( modul == 'clients/clientgroups' ) {
						if( inputs[ i ].checked ) {
							var selectBox = get( 'clientgroup_' + id );
							var selectedItems = new Array();
							for( var j = 0 ; j < selectBox.options.length ; j++ ) {
								if( selectBox.options[ j ].selected ) selectedItems.push( selectBox.options[ j ].value );
							}
							newValues01 += selectedItems.join( '#' ) + ',';
						} else {
							newValues01 += ',';
						}
					}
				} else if( functionName == 'sendmailall' ) {
					if( modul == 'orders' ) newValues01 += get( 'stateNew_' + id ).value + ',';
					else if( modul == 'coupon' ) newValues01 += get( 'priceNew_' + id ).value + ',';
				} else if( functionName == 'tobasketall' ) {
					newValues01 += get( 'mennyiseg' + id ).value + ',';
					if( get( 'parameterId' + id ) != null ) {
//						alert( get( 'parameterId' + id ).value );
						var selectBox = get( 'parameterId' + id );
						var selectedItems = new Array();
						for( var j = 0 ; j < selectBox.options.length ; j++ ) {
							if( selectBox.options[ j ].selected ) newValues02 += selectBox.options[ j ].value + ',';
						}
					} else newValues02 += ',';
				}
			}
		}
	}

	if( ids.lastIndexOf( ',' ) == ( ids.length - 1 ) ) ids = ids.substr( 0 , ids.length - 1 );
	if( values.lastIndexOf( ',' ) == ( values.length - 1 ) ) values = values.substr( 0 , values.length - 1 );
	if( newValues01.lastIndexOf( ',' ) == ( newValues01.length - 1 ) ) newValues01 = newValues01.substr( 0 , newValues01.length - 1 );
	if( newValues01.lastIndexOf( '#' ) == ( newValues01.length - 1 ) ) newValues01 = newValues01.substr( 0 , newValues01.length - 1 );
	if( newValues02.lastIndexOf( ',' ) == ( newValues02.length - 1 ) ) newValues02 = newValues02.substr( 0 , newValues02.length - 1 );
	if( newValues03.lastIndexOf( ',' ) == ( newValues03.length - 1 ) ) newValues03 = newValues03.substr( 0 , newValues03.length - 1 );

	if( modul == 'orders' ) ajax.load( 'admin/' + modul + '/' + functionName , { id: ids , value: values , newstate: newValues01, newdeliveryprice: newValues02, newdeliverydate: newValues03 } );
	else if( modul == 'coupon' ) ajax.load( 'admin/' + modul + '/' + functionName , { id: ids , value: values , newstate: newValues01 } );
	else if( modul == 'clients/clientgroups' ) ajax.load( 'admin/clients/' + functionName , { id: ids , value: values , newgroups: newValues01 } );
	else if( modul == 'distributors' ) ajax.load( 'public/basket/' + functionName , { id: ids , value: values , amount: newValues01 , param: newValues02 } );
	else if( ( modul == 'products/options' ) && ( functionName == 'deleteall' ) ) ajax.load( 'admin/products/deletealloptions' , { id: ids , value: values } );
	else if( ( modul == 'products/options' ) && ( functionName == 'modifyall' ) ) ajax.load( 'admin/products/modifyalloptions' , { id: ids , value: values , newText: newValues01 } );
	else ajax.load( 'admin/' + modul + '/' + functionName , { id: ids , value: values } );

	return false;
}

WebShopForm.prototype.saveModifications = function( modul , id ) {
	if( modul == 'orders' ) {
		if( ws.wsForm.validate( get( 'orderform' ), '' , 'ordererrormsg' ) ) {
			var deliveryPrice = 0;
			var deliveryDate = '0000-00-00';
			if (get('deliveryprice_' + id)) deliveryPrice = get('deliveryprice_' + id).value; 
			if (get('deliverydate_' + id)) deliveryDate = get('deliverydate_' + id).value; 
			ajax.load( 'admin/orders/modifystatus/' + id , { newstate: get( 'stateNew_' + id ).value, deliveryprice: deliveryPrice, deliverydate: deliveryDate } );
		}
	} 
	else if( modul == 'orders2' ) {
		var is_public = '';
		ajax.load( 'admin/orders/modifystatus/' + id , { comment: get('comment').value,is_public: get('is_public').checked,newstate: get( 'stateNew_' + id ).value } );
	} else if( modul == 'clients/clientgroups' ) {
		var selectBox = get( 'clientgroup_' + id );
		var selectedItems = new Array();
		for( var i = 0 ; i < selectBox.options.length ; i++ ) {
			if( selectBox.options[ i ].selected ) selectedItems.push( selectBox.options[ i ].value );
		}
		ajax.load( 'admin/clients/clientgroupsave/' + id , { newgroups: selectedItems.join( ',' ) } );
		ws.wsUtil.toTop();
	} else if( modul == 'coupon' ) {
		var newPrice = 0;
		if( get( 'priceNew_' + id ) ) newPrice = get( 'priceNew_' + id ).value;
		if( newPrice != 0 ) {
			ajax.load( 'admin/coupon/savenewprice/' + id , { newprice: get( 'priceNew_' + id ).value } );
		}
	} else if( modul == 'products/options' ) {
		var newText = '';
		if( get( 'label_' + id ) ) newText = get( 'label_' + id ).value;
		if( newText != '' ) {
			ajax.load( 'admin/products/saveoptiontext/' + id , { newText: get( 'label_' + id ).value } );
		}
	}
	
}

WebShopForm.prototype.sendMail = function( modul , id ) {
	if( modul == 'orders' ) {
		ajax.load( 'admin/orders/sendmailforstatuschange/' + id , { newstate: get( 'stateNew_' + id ).value } );
	} else if( modul == 'coupon' ) {
		ajax.load( 'admin/coupon/sendmail/' + id , { newprice: get( 'priceNew_' + id ).value } );
	}
}

WebShopForm.prototype.adminTableEnableButton = function( id , inputPrefixForOldValue , inputPrefixForNewValue , tableCellPrefix , inactiveClass , activeClass ) {
	if( ( get( inputPrefixForOldValue + id ) == null ) || ( get( inputPrefixForNewValue + id ) == null ) || ( get( tableCellPrefix + id ) == null ) ) return false;
	if( get( inputPrefixForOldValue + id ).value != get( inputPrefixForNewValue + id ).value ) {
		get( tableCellPrefix + id ).className = activeClass;
	} else {
		get( tableCellPrefix + id ).className = inactiveClass;
	}
}

WebShopForm.prototype.saveInputDatas = function() {
	ws.wsUtil.setCookie( 'wvshop_wamode_changed' , 'yes' , 1 );

	wsInputs = document.getElementsByTagName( 'input' );		// beszedjük az összes a-t
	for( var j = 0 ; j < wsInputs.length ; j++ ) {		// végigmegyünk az a-kon
		if( wsInputs[ j ].getAttribute( 'id' ) != null ) {		// ha van id tagje
			if( wsInputs[ j ].getAttribute( 'id' ) != '' ) {
				if( ( wsInputs[ j ].getAttribute( 'type' ) == 'hidden' ) || ( wsInputs[ j ].getAttribute( 'type' ) == 'text' ) ) {
					if( typeof( get( wsInputs[ j ].getAttribute( 'id' ) ).value ) != 'undefined' ) {
						ws.wsUtil.setCookie( 'wvshop_' + wsInputs[ j ].getAttribute( 'id' ) , ws.wsUtil.encodeUTF8( get( wsInputs[ j ].getAttribute( 'id' ) ).value ) , 1 );
					} else {
						ws.wsUtil.setCookie( 'wvshop_' + wsInputs[ j ].getAttribute( 'id' ) , '' , 1 );
					}
				} else if( wsInputs[ j ].getAttribute( 'type' ) == 'checkbox' ) {
					if( wsInputs[ j ].checked == true ) {
						ws.wsUtil.setCookie( 'wvshop_' + wsInputs[ j ].getAttribute( 'id' ) , 'true' , 1 );
					} else {
						ws.wsUtil.setCookie( 'wvshop_' + wsInputs[ j ].getAttribute( 'id' ) , 'false' , 1 );
					}
				} else if( wsInputs[ j ].getAttribute( 'type' ) == 'radio' ) {
				}
			}
		} else if( wsInputs[ j ].getAttribute( 'type' ) == 'radio' ) {
			var radioGroupName = wsInputs[ j ].getAttribute( 'name' );
			var radioGroup = document.getElementsByName( radioGroupName );
			for( var i = 0 ; i < radioGroup.length ; i++ ) {
				if( radioGroup[ i ].checked ) {
					ws.wsUtil.setCookie( 'wvshopradio_' + radioGroupName , i , 1 );
				}
			}
		}
	}
	
	wsInputs = document.getElementsByTagName( 'textarea' );		// beszedjük az összes a-t
	for( var j = 0 ; j < wsInputs.length ; j++ ) {		// végigmegyünk az a-kon
		if( wsInputs[ j ].getAttribute( 'id' ) != null ) {		// ha van id tagje
			ws.wsUtil.setCookie( 'wvshop_' + wsInputs[ j ].getAttribute( 'id' ) , ws.wsUtil.encodeUTF8( get( wsInputs[ j ].getAttribute( 'id' ) ).value ) , 1 );
		}
	}

	wsInputs = document.getElementsByTagName( 'select' );		// beszedjük az összes a-t
	for( var j = 0 ; j < wsInputs.length ; j++ ) {		// végigmegyünk az a-kon
		if( wsInputs[ j ].getAttribute( 'id' ) != null ) {		// ha van id tagje
			ws.wsUtil.setCookie( 'wvshop_' + wsInputs[ j ].getAttribute( 'id' ) , wsInputs[ j ].selectedIndex , 1 );
		}
	}
}

WebShopForm.prototype.restoreInputDatas = function() {
	var cookies = document.cookie.split( ';' );
	var c = cookieName = cookieValue = inputName = null;
	var changed = false;
	for( var i = 0 ; i < cookies.length ; i++ ) {
		var c = cookies[ i ];
		if( c.indexOf( '=' ) != -1 ) {		// van benne egyenlőségjel (értékpár)
			cookieName = c.substring( 0 , c.indexOf( '=' ) );		// a cookie neve
			cookieValue = c.substring( c.indexOf( '=' ) + 1 );
			if( ( cookieName.length > 7 ) && ( cookieName.indexOf( "wvshop_" ) == 1 ) ) {		// ha a neve megfelelő hosszúságú, és a miénk
				inputId = cookieName.substring( 8 );
				if( get( inputId ) != null ) {			// van ilyen inputunk, betöltjük a tartalmat
					if( get( inputId ).tagName.toLowerCase() == 'select' ) {		// selectről van szó
						get( inputId ).selectedIndex = cookieValue;
					} else if( get( inputId ).tagName.toLowerCase() == 'textarea' ) {
						get( inputId ).value = decodeURI( cookieValue );
						if( get( inputId ).getAttribute( 'onfocus' ) != null ) {		// van onfocus, lefutattjuk
							try {
								get( inputId ).focus();
							} catch( er ) {
							}

						}
					} else if( get( inputId ).tagName.toLowerCase() == 'input' ) {
						if( ( get( inputId ).getAttribute( 'type' ) == 'text' ) || ( get( inputId ).getAttribute( 'type' ) == 'hidden' ) ) {
							get( inputId ).value = decodeURI( cookieValue );

							if( get( inputId ).getAttribute( 'onfocus' ) != null ) {		// van onfocus, lefutattjuk
								try {
									get( inputId ).focus();
								} catch( er ) {
								}
							}
						} else if( get( inputId ).getAttribute( 'type' ) == 'checkbox' ) {
							if( cookieValue == 'true' ) {
								get( inputId ).checked = true;
							} else {
								get( inputId ).checked = false;
							}
						} else if( get( inputId ).getAttribute( 'type' ) == 'radio' ) {
						}
					}
				}
				
				ws.wsUtil.deleteCookie( cookieName );
			} else if( ( cookieName.length > 7 ) && ( cookieName.indexOf( "wvshopradio_" ) == 1 ) ) {
				var radioGroupName = cookieName.substring( 13 );
				var radioGroup = document.getElementsByName( radioGroupName );

				if( radioGroup.length > 0 ) {
					for( var j = 0 ; j < radioGroup.length ; j++ ) {
						radioGroup[ j ].checked = false;
						if( j == cookieValue ) {
							radioGroup[ j ].checked = true;
						}
					}
				}
				ws.wsUtil.deleteCookie( cookieName );
			}
		}
	}
	ws.wsUtil.deleteCookie( 'wvshop_wamode_changed' );
	ws.wsUtil.toTop();
	return null;
}

WebShopForm.prototype.getMultipleSelected = function( obj ) {
	var selectedValues = '';
	for( var i = 0 ; i < obj.options.length ; i++ ) {
		if( obj.options[ i ].selected == true ) {
			selectedValues += obj.options[ i ].value + ',';
		}
	}

	if( selectedValues.lastIndexOf( ',' ) == ( selectedValues.length - 1 ) ) selectedValues = selectedValues.substr( 0 , selectedValues.length - 1 );
	return selectedValues;
}

WebShopForm.prototype.getDistParams = function( prodId ) {
	if( get( 'parameterId' + prodId ) != null ) return get( 'parameterId' + prodId ).value;
	else return 0;
}

WebShopForm.prototype.saveLoyaltyPoints = function( userId ) {
	return ajax.load( 'admin/loyaltyprogram/savepoints/' + userId );
}

WebShopForm.prototype.getCoupons = function() {
	var coupons = document.getElementsByName( 'coupons' );
	if( coupons.length == 0 ) {
		return 0;
	} else if( coupons.length == 1 ) {		// csak 1 van (chkbox)
		if( coupons[ 0 ].checked ) return coupons[ 0 ].value;
		else return 0;
	} else {		// több van (radio)
		for( var i = 0 ; i < coupons.length ; i++ ) {
			if( coupons[ i ].checked ) {
				return coupons[ i ].value;
			}
		}
		return 0;
	}
}

WebShopForm.prototype.inputCheck = function( searchtype ,defaulttext ,alerttext) {
	isSet = [0,0,0,0,0,0,0,0,0,0,0,0];
	var i = isSend = 0;
	if( ( get( 'price' ) != null ) && ( get( 'price' ).value > 0 ) ) isSet[0] = '1';
	if( ( get( 'category' ) != null ) && ( get( 'category' ).value > 0 ) ) isSet[1] = '1';
	if( ( get( 'nem' ) != null ) && ( get( 'nem' ).value > 0 ) ) isSet[2] = '1';
	if( ( get( 'brand' ) != null ) && ( get( 'brand' ).value > 0 ) ) isSet[3] = '1';
	if( ( get( 'stock' ) != null ) && ( get( 'stock' ).value > 0 ) ) isSet[4] = '1';
	if( ( get( 'tags3' ) != null ) && ( get( 'tags3' ).checked ) ) isSet[5] = '1';
	if( ( get( 'tags4' ) != null ) && ( get( 'tags4' ).checked ) ) isSet[6] = '1';
	if( ( get( 'tags5' ) != null ) && ( get( 'tags5' ).checked ) ) isSet[7] = '1';
	if( ( get( 'tags6' ) != null ) && ( get( 'tags6' ).checked ) ) isSet[8] = '1';
	if( ( get( 'tags7' ) != null ) && ( get( 'tags7' ).checked ) ) isSet[9] = '1';
	if( ( get( 'tags8' ) != null ) && ( get( 'tags8' ).checked ) ) isSet[10] = '1';
	if( ( get( 'tags9' ) != null ) && ( get( 'tags9' ).checked ) ) isSet[11] = '1';
	
	for ( var i = 0 ; i < isSet.length ; i++ ) {
		if (isSet[i] == 1) isSend++;
	}
	
	if( typeof( searchtype ) == 'undefined' || searchtype == 'normal' ) {		// nincs megadva, összetetett keresés
		if ( get( 'szoveg' ).value.length < 3 && isSend < 2 ) { 
			alert( alerttext ); 
			return false; 
		}
	} else if( ( typeof( searchtype ) == 'string' ) && ( searchtype == 'easy' ) ) {
		if ( get( 'szoveg' ).value.length < 3 ) { 
			alert( alerttext ); 
			return false; 
		}
	}
	ajax.go( '#public/search/search' , get( 'searchform' ) );
	ws.wsForm.clearSearchParams(defaulttext);
}

WebShopForm.prototype.discountEnabler = function( radioValue ) {
	// hűségpontok
	if( get( 'loyaltypoints' ) != null ) {		// van ilyen
		if( radioValue == 'loyalty' ) get( 'loyaltypoints' ).disabled = false;
		else {
			get( 'loyaltypoints' ).value = '0';
			get( 'loyaltypoints' ).disabled = true;
		}
	}

	// kuponok
	var coupons = document.getElementsByName( 'coupons' );
	
	if( coupons.length == 1 ) {		// csak 1 van (chkbox)
		if( radioValue == 'coupon' ) coupons[ 0 ].disabled = false;
		else {
			coupons[ 0 ].checked = false;
			coupons[ 0 ].disabled = true;
		}
	} else if( coupons.length > 1 ) {		// több van (radio)
		for( var i = 0 ; i < coupons.length ; i++ ) {
			if( radioValue == 'coupon' ) coupons[ i ].disabled = false;
			else {
				if( coupons[ i ].id == 'coupon_0' ) coupons[ i ].checked = true;
				else coupons[ i ].checked = false;
				coupons[ i ].disabled = true;
			}
		}
	}

	// egyéb kuponok
	if( get( 'otherCouponCode' ) != null ) {		// van ilyen
		if( radioValue == 'othercoupon' ) get( 'otherCouponCode' ).disabled = false;
		else {
			get( 'otherCouponCode' ).value = '';
			get( 'otherCouponCode' ).disabled = true;
		}
	}
}

WebShopForm.prototype.catTreeChange = function() {
	ajax.go( '#admin/productcategories/list/' + get( 'catTreeSelect' ).value );
//	alert( get( 'catTreeSelect' ).value );
}

WebShopForm.prototype.searchMenuClose = function(defaulttext) {
	get('price_header').className = 'menu close'; 
	get('menu_ul_price').style.display = 'none';
	get('category_header').className = 'menu close'; 
	get('menu_ul_category').style.display = 'none';
	get('nem_header').className = 'menu close'; 
	get('menu_ul_nem').style.display = 'none';
	get('brand_header').className = 'menu close'; 
	get('menu_ul_brand').style.display = 'none';
	get('stock_header').className = 'menu close'; 
	get('menu_ul_stock').style.display = 'none';
}

WebShopForm.prototype.checkCatTree = function() {
	var catSelects = document.getElementsByName( 'cikkkategoria_id[]' );
	
	for( var i = 0 ; i < catSelects.length ; i++ ) {
		var actualSelect = get( catSelects[ i ].id );
		if( get( catSelects[ i ].id ).value == '-1' ) {
			alert( 'Hibás kategória!' );
			return false;
		}
	}

	return true;
}
WebShopForm.prototype.clearSearchParams = function(defaulttext) {
	if( get( 'price_header' ) != null ) {
		get( 'price_header' ).innerHTML = defaulttext; 
		get( 'price_header' ).className = 'menu close'; 
		get( 'menu_ul_price' ).style.display = 'none';
		get( 'price' ).value = '0';
	}

	if( get( 'price_header' ) != null ) {
		get( 'category_header' ).innerHTML = defaulttext; 
		get( 'category_header' ).className = 'menu close'; 
		get( 'menu_ul_category' ).style.display = 'none';
		get( 'category' ).value = '0';
	}

	if( get( 'price_header' ) != null ) {
		get( 'nem_header' ).innerHTML = defaulttext; 
		get( 'nem_header' ).className = 'menu close'; 
		get( 'menu_ul_nem' ).style.display = 'none';
		get( 'nem' ).value = '0';
	}

	if( get( 'price_header' ) != null ) {
		get( 'brand_header' ).innerHTML = defaulttext; 
		get( 'brand_header' ).className = 'menu close'; 
		get( 'menu_ul_brand' ).style.display = 'none';
		get( 'brand' ).value = '0';
	}

	if( get( 'price_header' ) != null ) {
		get( 'stock_header' ).innerHTML = defaulttext; 
		get( 'stock_header' ).className = 'menu close'; 
		get( 'menu_ul_stock' ).style.display = 'none';
		get( 'stock' ).value = '0';
	}
	
	get( 'szoveg' ).value = '';

	if( get( 'price_header' ) != null ) {
		get( 'tags3' ).checked = false;
		get( 'tags4' ).checked = false;
		get( 'tags5' ).checked = false;
		get( 'tags6' ).checked = false;
		get( 'tags7' ).checked = false;
		get( 'tags8' ).checked = false;
		get( 'tags9' ).checked = false;
	}
}

WebShopForm.prototype.changeTranslatedTab = function( mode ) {
	if( mode == 'data' ) {
		core.addclass( document.getElementById( 'adminDatasFormDiv' ) , 'hiddenDiv' );
		core.addclass( document.getElementById( 'adminTranslateFormDiv' ) , 'hiddenDiv' );
		core.delclass( document.getElementById( 'adminDatasFormDiv' ) , 'hiddenDiv' );

		core.delclass( document.getElementById( 'divTranslateTabData' ) , 'translateTabOn' );
		core.delclass( document.getElementById( 'divTranslateTabTrans' ) , 'translateTabOn' );
		core.addclass( document.getElementById( 'divTranslateTabData' ) , 'translateTabOn' );

		ajax.load( 'admin/translate/savesession' , { mode: 'datas' } );
	} else {
		core.addclass( document.getElementById( 'adminDatasFormDiv' ) , 'hiddenDiv' );
		core.addclass( document.getElementById( 'adminTranslateFormDiv' ) , 'hiddenDiv' );
		core.delclass( document.getElementById( 'adminTranslateFormDiv' ) , 'hiddenDiv' );
		
		core.delclass( document.getElementById( 'divTranslateTabData' ) , 'translateTabOn' );
		core.delclass( document.getElementById( 'divTranslateTabTrans' ) , 'translateTabOn' );
		core.addclass( document.getElementById( 'divTranslateTabTrans' ) , 'translateTabOn' );

		ajax.load( 'admin/translate/savesession' , { mode: 'translate' } );
	}
}

WebShopForm.prototype.getBank = function() {
	var inputs = document.getElementsByTagName( 'input' );
	for( var i = 0 ; i < inputs.length ; i++ ) {
		if( inputs[ i ].type == 'radio' ) {
			if( inputs[ i ].id.indexOf( 'paymentmethod_' ) != -1 ) {	// jó a kezdete az idnek
				if( get( inputs[ i ].id ).checked ) {
					return inputs[ i ].value;
				}
			}
		}
	}
}

WebShopForm.prototype.changeUniqueEvent = function( radioId ) {
	idParts = radioId.split( '_' );
	id = idParts[ idParts.length - 1 ];
	if( get( 'unique_month_select_' + id ) != null ) get( 'unique_month_select_' + id ).disabled = true;
	if( get( 'unique_week_select_' + id ) != null ) get( 'unique_week_select_' + id ).disabled = true;
	if( get( 'unique_day_text_' + id ) != null ) {
		core.delclass( get( 'unique_day_text_' + id ) , 'invalid' );
		get( 'unique_day_text_' + id ).disabled = true;
	}
	if( get( 'unique_daytime_text_' + id ) != null ) {
		core.delclass( get( 'unique_daytime_text_' + id ) , 'invalid' );
		get( 'unique_daytime_text_' + id ).disabled = true;
	}
	if( get( 'unique_daytimestart_text_' + id ) != null ) {
		core.delclass( get( 'unique_daytimestart_text_' + id ) , 'invalid' );
		get( 'unique_daytimestart_text_' + id ).disabled = true;
	}
	if( get( 'unique_daytimeend_text_' + id ) != null ) {
		core.delclass( get( 'unique_daytimeend_text_' + id ) , 'invalid' );
		get( 'unique_daytimeend_text_' + id ).disabled = true;
	}
	if( get( 'unique_weektime_select_' + id ) != null ) get( 'unique_weektime_select_' + id ).disabled = true;

	if( get( 'unique_weektimestart_text_' + id ) != null ) {
		core.delclass( get( 'unique_weektimestart_text_' + id ) , 'invalid' );
		get( 'unique_weektimestart_text_' + id ).disabled = true;
	}
	if( get( 'unique_weektimeend_text_' + id ) != null ) {
		core.delclass( get( 'unique_weektimeend_text_' + id ) , 'invalid' );
		get( 'unique_weektimeend_text_' + id ).disabled = true;
	}

	switch( idParts[ 1 ] ) {
		case 'month':
			if( get( 'unique_month_select_' + id ) != null ) get( 'unique_month_select_' + id ).disabled = false;
			break;
		case 'week':
			if( get( 'unique_week_select_' + id ) != null ) get( 'unique_week_select_' + id ).disabled = false;
			break;
		case 'day':
			if( get( 'unique_day_text_' + id ) != null ) get( 'unique_day_text_' + id ).disabled = false;
			break;
		case 'daytime':
			if( get( 'unique_daytime_text_' + id ) != null ) get( 'unique_daytime_text_' + id ).disabled = false;
			if( get( 'unique_daytimestart_text_' + id ) != null ) get( 'unique_daytimestart_text_' + id ).disabled = false;
			if( get( 'unique_daytimeend_text_' + id ) != null ) get( 'unique_daytimeend_text_' + id ).disabled = false;
			break;
		case 'weektime':
			if( get( 'unique_weektime_select_' + id ) != null ) get( 'unique_weektime_select_' + id ).disabled = false;
			if( get( 'unique_weektimestart_text_' + id ) != null ) get( 'unique_weektimestart_text_' + id ).disabled = false;
			if( get( 'unique_weektimeend_text_' + id ) != null ) get( 'unique_weektimeend_text_' + id ).disabled = false;
			break;
	}
	
	if( get( 'unique_selected_mode_' + id ) != null ) get( 'unique_selected_mode_' + id ).value = idParts[ 1 ];
}

WebShopForm.prototype.delUniqueEvent = function( uniqueEventId ) {
	if( get( 'adminEventLocationDatasFormDiv' ) != null ) {
		if( get( 'unique_time_div_' + uniqueEventId ) != null ) {
			if( get( 'unique_deleted_' + uniqueEventId ) != null ) {
				get( 'unique_deleted_' + uniqueEventId ).value = 'deleted';
				get( 'container_unique_time_div_' + uniqueEventId ).removeChild( get( 'unique_time_div_' + uniqueEventId ) );
			}
		}
	}
}

WebShopForm.prototype.addUniqueEvent = function() {
	var lastId = 0;
	if( get( 'lastNewUniqueCounter' ) != null ) {
		lastId = get( 'lastNewUniqueCounter' ).value;
		lastId++;
		get( 'lastNewUniqueCounter' ).value = lastId;
	} else {
		alert( 'hiba lépett fel, ilyen már létezik' );
		return false;
	}

	ajax.post( 'admin/events/location/addnewunique' , { newId: lastId } );
}
