/*
* ProductHandler
* 
* @brief: misc product related functions
*/
function ProductHandler( imageName ) {
	this.imageName = imageName;
	this.trailW = 1;
	this.trailH = 1;
}

/*
* ProductHandler.initTrail
* 
* @brief: write pic's hidden div to document
* @args:	-
* @return:	-
*
*/
ProductHandler.prototype.initTrail = function() {
	if( document.getElementById || document.all ) {
//		document.write( '<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:-1000px;width:1px;height:1px;border:1px solid #888888;background:#DDDDDD;z-index:1000;"><img id="ttimg" src="site/img/spacer.gif" /></div>' );
		document.write( '<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:-1000px;width:1px;height:1px;border:1px solid #888888;background:#DDDDDD;z-index:1000;"><img id="ttimg" class="spacerGif" alt="" /></div>' );
	}
}

/*
* ProductHandler.getTrailObj
* 
* @brief: gets pic div's dom
* @args:	-
* @return:	-
*
*/
ProductHandler.prototype.getTrailObj = function() {
	if( document.getElementById ) {
		return document.getElementById( "trailimageid" ).style;
	} else if( document.all ) {
		return document.all.trailimageid.style;
	}
}

/*
* ProductHandler.trueBody
* 
* @brief: determine root dom node depends on browsertype
* @args:	-
* @return:	obj of root dom
*
*/
ProductHandler.prototype.trueBody = function() {
	return ( !window.opera && document.compatMode && document.compatMode != "BackCompat" ) ? document.documentElement : document.body;
}

/*
* ProductHandler.hideTrail
* 
* @brief: hide pic's div
* @args:	-
* @return:	-
*
*/
ProductHandler.prototype.hideTrail = function() {
	document.onmousemove = "";
//	document.getElementById( 'ttimg' ).src = 'site/img/spacer.gif';
	document.getElementById( 'ttimg' ).className = 'spacerGif';
	this.getTrailObj().visibility = "hidden";
	this.getTrailObj().left = -1000;
	this.getTrailObj().top = 0;
}

/*
* ProductHandler.showTrail
* 
* @brief: show pic's div
* @args:	width:Int - width of the div
*			height:Int - height of the div
*			file:String - file name with path
* @return:	-
*
*/
ProductHandler.prototype.showTrail = function( width , height , file ) {
	if( navigator.userAgent.toLowerCase().indexOf( 'opera' ) == -1 ) {
		this.trailW = width;
		this.trailH = height;

		this.getTrailObj().visibility = "visible";
		this.getTrailObj().width = this.trailW + "px";
		this.getTrailObj().height = this.trailH + "px";

		document.getElementById( 'ttimg' ).src = file;
		document.getElementById( 'ttimg' ).width = width;
		document.getElementById( 'ttimg' ).height = height;
		document.onmousemove = this.followMouse;
	}
}

/*
* ProductHandler.followMouse
* 
* @brief: event handler, override the original one
* @args:	e:Event
* @return:	-
*
*/
ProductHandler.prototype.followMouse = function( e ) {
	if( navigator.userAgent.toLowerCase().indexOf( 'opera' ) == -1 ) {
		var xcoord = 20;
		var ycoord = 20;

		if( typeof e != "undefined" ) {
			xcoord += e.pageX;
			ycoord += e.pageY;
		} else if( typeof window.event != "undefined" ) {
			xcoord += ws.wsProduct.trueBody().scrollLeft + event.clientX;
			ycoord += ws.wsProduct.trueBody().scrollTop + event.clientY;
		}

		var docwidth = document.all ? ws.wsProduct.trueBody().scrollLeft + ws.wsProduct.trueBody().clientWidth : pageXOffset + window.innerWidth - 15;
		var docheight = document.all ? Math.max( ws.wsProduct.trueBody().scrollHeight , ws.wsProduct.trueBody().clientHeight ) : Math.max( document.body.offsetHeight , window.innerHeight );

		if( xcoord + ws.wsProduct.trailW + 3 > docwidth ) {
			xcoord = xcoord - ws.wsProduct.trailW - ( 20 * 2 );
		}
		
		if( ycoord - ws.wsProduct.trueBody().scrollTop + ws.wsProduct.trailH > ws.wsProduct.trueBody().clientHeight ) {
			ycoord = ycoord - ws.wsProduct.trailH - 20;
		}
		
		ws.wsProduct.getTrailObj().left = xcoord + "px";
		ws.wsProduct.getTrailObj().top = ycoord + "px";
	}
}



/*
* WebShop
* 
* @brief: main class for webshop, init all others, except product category handler
* @args:	needSiteSpecific:Boolean - need to init site specific things (optional)
*/
function WebShop( needSiteSpecific , jsMenuResizable ) {
	this.wsProduct = new ProductHandler( '' );				// create product obj
	this.wsProduct.initTrail();								// init product
	
}

/*
* WebShop.setAdmin
* 
* @brief: sets admin flag
* @args:	value:Boolean - true or false depends on call from admin (optional)
* @return:	-
*
*/
WebShop.prototype.setAdmin = function( value ) {
	if( typeof( value ) != 'undefined' ) {
		this.isAdmin = value;
	}
}

/*
* WebShop.getAdmin
* 
* @brief: gets admin flag
* @args:	-
* @return:	boolean, the value of the flag
*
*/
WebShop.prototype.getAdmin = function() {
	return this.isAdmin;
}

/*
* WebShop.getWSUtil
* 
* @brief: gets util obj
* @args:	-
* @return:	obj of util
*
*/
WebShop.prototype.getWSUtil = function() {
	return this.wsUtil;
}

/*
* WebShop.getWSSite
* 
* @brief: gets site obj
* @args:	-
* @return:	obj of site
*
*/
WebShop.prototype.getWSSite = function() {
	return this.wsSite;
}

/*
* WebShop.getWSCat
* 
* @brief: gets category obj
* @args:	-
* @return:	obj of categories
*
*/
WebShop.prototype.getWSCat = function() {
	return this.wsProductCat;
}

/*
* WebShop.getWSForm
* 
* @brief: gets form obj
* @args:	-
* @return:	obj of form validation
*
*/
WebShop.prototype.getWSForm = function() {
	return this.wsForm;
}

/*
* WebShop.getWSProduct
* 
* @brief: gets product obj
* @args:	-
* @return:	obj of products
*
*/
WebShop.prototype.getWSProduct = function() {
	return this.wsProduct;
}

WebShop.prototype.getWSAnswer = function() {
	return this.wsAnswer;
}

ws = new WebShop( true , false );	// init webshop





/*
* 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}$', 
		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}$', 
		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-\\u00C0-\\u024F][a-zA-Z0-9- ,\\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,29}$', 
		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])$', 
		dateblank: '^$|^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}$', 
		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})$',
		blank: '^$'
	}
}

/*
* 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 urlap mezoi nem megfeleloen 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 ) {
	var noOfElement = parseInt( document.getElementById( inputId ).value );
	if( isNaN( noOfElement ) ) {
		noOfElement = 1;
	} else {
		if( dir == 1 ) noOfElement++;
		else if( dir == -1 ) {
			if( noOfElement > 0 ) noOfElement--;
		}
	}
	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 elozo feltétel miatt itt már biztos hogy van _
				if( isNaN( parseInt( id ) ) ) continue;		// ha nem értelmezheto, 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üggoen, hogy hány plusz paramétert kell kiszedni
	var newValues02 = '';			// egyéb dolgok átadására, newValuesxx formában, attól függoen, 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 elozo feltétel miatt itt már biztos hogy van _
				if( isNaN( parseInt( id ) ) ) continue;		// ha nem értelmezheto, akkor hanyagoljuk
				ids += id + ',';		// összefuzzü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' ) {
		ajax.load( 'admin/orders/modifystatus/' + id , { 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 egyenlosé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 megfelelo 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' ) {		// selectrol 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.beszallitoOnOff = function() {
	switch( get( 'beszallitoi_id' ).selectedIndex ) {
		case 0: 
			get( 'beszallitoi_azonosito' ).disabled = true;
			get( 'beszallitoi_cikkszam' ).disabled = true;
			break;
		default:
			get( 'beszallitoi_azonosito' ).disabled = false;
			get( 'beszallitoi_cikkszam' ).disabled = false;
			break;
	}
}
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 ) {
	// husé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) {
	get( 'price_header' ).innerHTML = defaulttext; 
	get( 'price_header' ).className = 'menu close'; 
	get( 'menu_ul_price' ).style.display = 'none';
	get( 'price' ).value = '0';
	
	get( 'category_header' ).innerHTML = defaulttext; 
	get( 'category_header' ).className = 'menu close'; 
	get( 'menu_ul_category' ).style.display = 'none';
	get( 'category' ).value = '0';

	get( 'nem_header' ).innerHTML = defaulttext; 
	get( 'nem_header' ).className = 'menu close'; 
	get( 'menu_ul_nem' ).style.display = 'none';
	get( 'nem' ).value = '0';

	get( 'brand_header' ).innerHTML = defaulttext; 
	get( 'brand_header' ).className = 'menu close'; 
	get( 'menu_ul_brand' ).style.display = 'none';
	get( 'brand' ).value = '0';

	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 = '';
	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;
}


function ProductCategoryHandler( max_fokat ) {
	this.lenyitva = 0;
	this.activeSubMenuItem = 0;
	this.max_fokat = max_fokat;
}

ProductCategoryHandler.prototype.osszesKatBezar = function( doNotCloseParam ) {
	if( ws.selectedSkin != 'black.skin' ) {
		var doNotClose = false;
		if( ( typeof( doNotCloseParam ) != 'undefined' ) && ( doNotCloseParam == true ) ) doNotClose = true;
		
		wsInputs = document.getElementsByTagName( 'div' );		// beszedjük az összes a-t
		for( var j = 0 ; j < wsInputs.length ; j++ ) {
			if( wsInputs[ j ].getAttribute( 'id' ) != null ) {
				if( wsInputs[ j ].getAttribute( 'id' ) != '' ) {
					if( wsInputs[ j ].getAttribute( 'id' ).substring( 0 , 11 ) == 'fokategoria' ) {		// ez egy fokategória
						if( get( 'alkat' + wsInputs[ j ].getAttribute( 'id' ).substring( 11 ) ) != null ) {		// van alkategóriája
							if( !doNotClose ) get( 'alkat' + wsInputs[ j ].getAttribute( 'id' ).substring( 11 ) ).style.display = 'none';		// alkategóriákat eltuntetjük
//							if( !doNotClose ) get( 'fokat' + wsInputs[ j ].getAttribute( 'id' ).substring( 11 ) ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categMiniArrow.gif) no-repeat scroll 76px 3px transparent';		// lenyíló nyilat eltuntetjük
							if( !doNotClose ) get( 'fokat' + wsInputs[ j ].getAttribute( 'id' ).substring( 11 ) ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/arrowMaincateg.gif) no-repeat scroll 76px 3px transparent';		// lenyíló nyilat eltuntetjük
							wsSubCats = get( 'alkat' + wsInputs[ j ].getAttribute( 'id' ).substring( 11 ) ).getElementsByTagName( 'div' );
							for( var i = 0 ; i < wsSubCats.length ; i++ ) {
								if( wsSubCats[ i ].getAttribute( 'id' ) != null ) {
									if( wsSubCats[ i ].getAttribute( 'id' ) != '' ) {
										if( wsSubCats[ i ].getAttribute( 'id' ).substring( 0 , 11 ) == 'alkategoria' ) {		// ez egy alkategória megnevezés div
											get( 'alkategoria' + wsSubCats[ i ].getAttribute( 'id' ).substring( 11 ) ).style.background = '';		// mutató nyilat eltuntetjük az alkategóriáknál
										}
									}
								}
							}
							get( 'fokategoria' + wsInputs[ j ].getAttribute( 'id' ).substring( 11 ) ).style.background = '';		// mutató nyilat eltuntetjük a fokategóriánál
						} else {
							get( 'fokategoria' + wsInputs[ j ].getAttribute( 'id' ).substring( 11 ) ).style.background = '';		// csak a mutató nyilat kell etuntetni
						}
					}
				}
			}
		}
	}
	this.lenyitva = 0;		// nincs lenyitva semmi
}

ProductCategoryHandler.prototype.alKatLenyit = function( kat , seoname , doNotGo ) {
	this.osszesKatBezar( true );
//	if (ws.selectedSkin != 'black.skin') get( 'alkategoria' + kat ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categArrow.jpg) no-repeat 43px -1px';		// lenyíló nyilra cseréljük
	if (ws.selectedSkin != 'black.skin') get( 'alkategoria' + kat ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categArrow.png) no-repeat 43px -1px';		// lenyíló nyilra cseréljük
	if( this.activeSubMenuItem != kat ) {
		this.activeSubMenuItem = kat;
		if( ( typeof( doNotGo ) == 'boolean' ) && ( doNotGo === true ) ) {}
		else {
			if( typeof( seoname ) == 'undefined' ) ajax.go( 'public/products/category/' + kat );
			else ajax.go( 'public/products/category/' + seoname );
			ws.wsUtil.toTop();
		}
	}
}

ProductCategoryHandler.prototype.foKatLenyit = function( fokat , alkatvan , also , seoname , doNotGo ) {
	var fokatnev = "fokat" + fokat;
	var fokategorianev = "fokategoria" + fokat;
	var alkatnev = "alkat" + fokat;
	this.activeSubMenuItem = 0;

	if( this.lenyitva != fokat ) {
		this.osszesKatBezar();
		this.lenyitva = fokat;
		if( also == 1 ) {
			get( fokatnev ).style.border = 'none';
		}

		if( alkatvan == 1 ) {
/*			if( also == 1 ) {
				ws.wsUtil.changeCSSClass( fokatnev , 'alsofokatalkattallenyitva' );
			} else {
				ws.wsUtil.changeCSSClass( fokatnev , 'fokatalkattallenyitva' );
			} */
//			get( fokatnev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categMiniArrowDown.gif) no-repeat scroll 80px 0 transparent';		// lenyíló nyilra cseréljük
			get( fokatnev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/arrowMaincategOver.gif) no-repeat scroll 80px 0 transparent';		// lenyíló nyilra cseréljük
			get( alkatnev ).style.display = "block";		// alktegóriát mutatunk
		}

//		get( fokategorianev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categArrow.jpg) no-repeat 43px -1px';		// mutató nyilat otthagyjuk
		get( fokategorianev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categArrow.png) no-repeat 43px -1px';		// mutató nyilat otthagyjuk
		get( fokategorianev ).style.color = '#ffffff';
		if( ( typeof( doNotGo ) == 'boolean' ) && ( doNotGo === true ) ) {}
		else {
			if( typeof( seoname ) == 'undefined' ) ajax.go( 'public/products/category/' + fokat );
			else ajax.go( 'public/products/category/' + seoname );
			ws.wsUtil.toTop();
		}
/*	} else {
		this.lenyitva = 0;
		if( also == 1 ) {
			get( fokatnev ).style.borderBottom = '0px';
		}
		if( alkatvan == 1 ) {
			get( alkatnev ).style.display = "none";
			get( fokatnev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categMiniArrow.gif) no-repeat scroll 76px 3px transparent';		// visszarakjuk sima nyílra, nem lenyílóra
		}
//		get( fokategorianev ).style.backgroundImage = '';
		get( fokategorianev ).style.color = '#ffffff';
		ws.wsUtil.preload( 'kozepkozep' , 150 );
		ajax.go( 'public/products/highlighted' );
		ws.wsUtil.toTop(); */
	}
}

ProductCategoryHandler.prototype.foKategerBe = function( fokat_id ) {
	var nev = "fokategoria" + fokat_id;
	if( fokat_id == this.lenyitva ) {
		return true;
	}
//	get( nev ).style.background = '';
//	if( ws.selectedSkin != 'black.skin' ) get( nev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categArrow.jpg) no-repeat 43px -1px';
	if( ws.selectedSkin != 'black.skin' ) get( nev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categArrow.png) no-repeat 43px -1px';
	get( nev ).style.color = '#ffffff';
}

ProductCategoryHandler.prototype.foKategerKi = function( fokat_id ) {
	var nev = "fokategoria" + fokat_id;
	if( fokat_id == this.lenyitva ) {
		return true;
	}
	get( nev ).style.background = 'none';
	get( nev ).style.color = '#ffffff';
}

ProductCategoryHandler.prototype.alKategerBe = function( alkat_id ) {
	var nev = "alkategoria" + alkat_id;
	if( alkat_id == this.activeSubMenuItem ) return true;
//	if( ws.selectedSkin != 'black.skin' ) get( nev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categArrow.jpg) no-repeat 43px -1px';
	if( ws.selectedSkin != 'black.skin' ) get( nev ).style.background = 'url(site/webshop/' + ws.selectedSkin + '/img/categArrow.png) no-repeat 43px -1px';
	get( nev ).style.color = '#ffffff';
}

ProductCategoryHandler.prototype.alKategerKi = function( alkat_id ) {
	var nev = "alkategoria" + alkat_id;
	
	if( alkat_id == this.activeSubMenuItem ) return true;
	
	get( nev ).style.background = 'none';
	get( nev ).style.color = '#ffffff';
}

/*
* WebShopUtil
* 
* @brief: misc utilities for webshop
*/
function WebShopUtil() {
	this.browserType = '';
	this.browserVer = '';
	this.aktivcsillag = 0;
	this.szallitasicim = 0;
	this.atvetelitipus = '';
	this.szamlazasicim = 0;

	this.setBrowser();
}

/*
* WebShopUtil.getBrowser
* 
* @brief: get browser datas
* @args:	neededData:String (optional) - type/version/platform/short for browsername/browser version/opsys/brief desc like ie7, ff2
* @return:	strig with required data or null
*
*/
WebShopUtil.prototype.getBrowser = function( neededData ) {
	switch( neededData ) {
		case 'type':
			return this.browserType;
			break;
		case 'version':
			return this.browserVer;
			break;
		case 'short':
			return this.browserType + this.browserVer;
			break;
		default:
			return null;
	}
}

/*
* WebShopUtil.setBrowser
* 
* @brief: set browser datas
* @args:	-
* @return:	-
*
*/
WebShopUtil.prototype.setBrowser = function() {
	var agentInfo = navigator.userAgent.toLowerCase();

	if( agentInfo.indexOf( "msie" ) > -1 ) {	// ie
		this.browserType = 'ie';
		this.browserVer = parseFloat( agentInfo.substring( agentInfo.indexOf( 'msie' ) + 'msie'.length + 1 ) );
	} else if( agentInfo.indexOf( "firefox" ) > -1 ) {	// ff
		this.browserType = 'ff';
		this.browserVer = parseFloat( agentInfo.substring( agentInfo.indexOf( 'firefox' ) + 'firefox'.length + 1 ) );
	} else if( agentInfo.indexOf( "chrome" ) > -1 ) {	// chrome
		this.browserType = 'chrome';
		this.browserVer = parseFloat( agentInfo.substring( agentInfo.indexOf( 'chrome' ) + 'chrome'.length + 1 ) );
	} else if( agentInfo.indexOf( "safari" ) > -1 ) {	// safari
		this.browserType = 'safari';
		this.browserVer = parseFloat( agentInfo.substring( agentInfo.indexOf( 'version' ) + 'version'.length + 1 ) );
	} else if( agentInfo.indexOf( "opera" ) > -1 ) {	// opera
		this.browserType = 'opera';
		this.browserVer = parseFloat( agentInfo.substring( agentInfo.indexOf( 'opera' ) + 'opera'.length + 1 ) );
	}
}

/*
* WebShopUtil.changeCSSStyle
* 
* @brief: change given obj's given style param
* @args:	dom:obj - obj of dom
*			cssStyleTag:String - name of the css tag in javascript
*			cssStyleValue:String - new value
* @return:	-
*
*/
WebShopUtil.prototype.changeCSSStyle = function( dom , cssStyleTag , cssStyleValue ) {
	if( typeof( dom ) == 'string' ) {
		eval( "get( '" + dom + "' ).style." + cssStyleTag + " = '" + cssStyleValue + "';" );
	} else if( typeof( dom ) == 'object' ) {
		eval( "dom.style." + cssStyleTag + " = '" + cssStyleValue + "';" );
	}
}

/*
* WebShopUtil.changeCSSClass
* 
* @brief: change given obj's class to given class
* @args:	dom:obj - obj of dom
*			className:String - name of the css class
* @return:	-
*
*/
WebShopUtil.prototype.changeCSSClass = function( dom , className ) {
	if( typeof( dom ) == 'string' ) {
		eval( "get( '" + dom + "' ).className = '" + className + "';" );
	} else if( typeof( dom ) == 'object' ) {
		eval( "dom.className = '" + className + "';" );
	}
}
/*
* WebShopUtil.toTop
* 
* @brief: scroll to top
* @args:	-
* @return:	-
*
*/
WebShopUtil.prototype.toTop = function() {
	self.scrollTo( 0 , 0 );
}

/*
* WebShopUtil.capitalize
* 
* @brief: capitalize given str
* @args:	inStr:String - str to capitalize
* @return:	String with theresult
*
*/
WebShopUtil.prototype.capitalize = function( inStr ) {
	return inStr.replace(/\w+/g, function( inStr ) {
		return inStr.charAt( 0 ).toUpperCase() + inStr.substr( 1 ).toLowerCase();
	} );
};

/*
* WebShopUtil.ltrim
* 
* @brief: trim left whitespaces
* @args:	str:String - str to left trim
* @return:	String with the result
*
*/
WebShopUtil.prototype.ltrim = function( str ) {
	return str.replace( new RegExp( "^[\\s]+" , "g" ) , "" );
}

/*
* WebShopUtil.rtrim
* 
* @brief: trim right whitespaces
* @args:	str:String - str to right trim
* @return:	String with the result
*
*/
WebShopUtil.prototype.rtrim = function( str ) {
	return str.replace( new RegExp( "[\\s]+$" , "g" ) , "" );
}


/*
* WebShopUtil.trim
* 
* @brief: trim whitespaces
* @args:	str:String - str to trim
* @return:	String with the result
*
*/
WebShopUtil.prototype.trim = function( str ) {
	return this.ltrim( this.rtrim( str ) );
}

/*
* WebShopUtil.preload
* 
* @brief: show preloader
* @args:	ojjektum:String - dom's name to change content
*			felsomargo:String - margin-top value
* @return:	-
*
*/

/*
* WebShopUtil.preload_grey
* 
* @brief: show alternate preloader
* @args:	ojjektum:String - dom's name to change content
*			felsomargo:String - margin-top value
* @return:	-
*
*/
WebShopUtil.prototype.preload_grey = function( ojjektum , felsomargo ) {
	return ws.wsUtil.preload(ojjektum, felsomargo)
}

WebShopUtil.prototype.csillagszinez = function( id ) {
	for( i = 1 ; i <= 5 ; i++ ) {
		nev = 'csillag' + i;
		if( i <= id ) {
			get( nev ).className = 'telecsillaglink';
		} else {
			get( nev ).className = 'urescsillaglink';
		}
	}
}


WebShopUtil.prototype.tovabbaktiv = function( id , tipus , atvetelitipus ) {
	var storetype = '';
	if( typeof( atvetelitipus ) == 'string' ) storetype = atvetelitipus;

	switch( tipus ) {
		case 1:
			this.szallitasicim = id;
			this.atvetelitipus = storetype;
			this.setCookie( 'szallitasi' , id , 1 );
			this.setCookie( 'atvetelitipus' , storetype , 1 );
			break;
		case 2:
			this.szamlazasicim = id;
			this.setCookie( 'szamlazasi' , id , 1 );
			break;
		case 3:
//			this.szallitasicim = -1;
			this.szamlazasicim = id;
			this.setCookie( 'szamlazasi' , id , 1 );
			break;
	}
	
	var szallitasicimopcio = document.getElementsByName( 'szallitasicimopcio' );
	var szamlazasicimopcio = document.getElementsByName( 'szamlazasicimopcio' );
	var takeoveraddressoption = document.getElementsByName( 'takeoveraddressoption' );

	var hasAll = 0;
	
	for( var j = 0 ; j < szallitasicimopcio.length ; j++ ) {
		if( szallitasicimopcio[ j ].checked ) {
			hasAll++;
			break;
		}
	}

	for( var j = 0 ; j < szamlazasicimopcio.length ; j++ ) {
		if( szamlazasicimopcio[ j ].checked ) {
			hasAll++;
			break;
		}
	}

	for( var j = 0 ; j < takeoveraddressoption.length ; j++ ) {
		if( takeoveraddressoption[ j ].checked ) {
			hasAll++;
			break;
		}
	}
	
	if( ( this.szallitasicim != 0 ) && ( this.szamlazasicim != 0 ) ) {
		ajax.load( 'public/order/pagesubmitvisible' );
	} else if( hasAll >= 2 ) {
		ajax.load( 'public/order/pagesubmitvisible' );
	} else {
		get( 'cassaaddresssubmit' ).innerHTML = '';
	}
}
		
WebShopUtil.prototype.tovabbaktivreset = function() {
	this.szallitasicim = 0;
	this.szamlazasicim = 0;
}

WebShopUtil.prototype.sortsearchresult = function( change ) {
	var sortclass = get( 'sortarrow' ).className;
	
	if( change ) {
		if( sortclass == 'sort_asc' ) {
			get( 'sortarrow' ).className = 'sort_desc';
		} else {
			get( 'sortarrow' ).className = 'sort_asc';
		}
	}
	return get( 'sortarrow' ).className.substring( 5 );
}

/*
* WebShopUtil.timer
* 
* @brief:	timer function
* @args:	jsCommand:string - javascript command to run
*			secs:int - secumdums to wait
* @return:	-
*
*/
WebShopUtil.prototype.timer = function( jsCommand , secs ) {
	var timer = setTimeout( jsCommand , secs * 1000 );
}

/*
* WebShopUtil.hideMsgDiv
* 
* @brief:	div hider for hide error msgs
* @args:	divId:string - id of the div
*			divDefaultContent:string - default content of the div, which should be restored
* @return:	-
*
*/
WebShopUtil.prototype.hideMsgDiv = function( divId , divDefaultContent ) {
	if( get( divId ) != null ) {	// has this dom
		if( this.trim( get( divId ).innerHTML.toLowerCase() ) != divDefaultContent.toLowerCase() ) {		// not empty
			get( divId ).innerHTML = divDefaultContent;
			if( this.getBrowser( 'type' ) == 'ie' ) {
				get( divId ).style.height = "0px";
			}
		}
	}
}

WebShopUtil.prototype.clearWarnings = function()
{
	if (ws.clearNeeded)
	{
		ws.clearNeeded = false;
		
		if (get( 'newslettererrdiv' )) get( 'newslettererrdiv' ).innerHTML = '';
		if (get( 'newsletterusername' )) ws.wsUtil.changeCSSClass( get( 'newsletterusername' ), '');
		if (get( 'newsletteremail' )) ws.wsUtil.changeCSSClass( get( 'newsletteremail' ), '');
	}
}

WebShopUtil.prototype.setCookie = function( cookieName , cookieValue , expireDays ) {
	var expireDate = new Date();
	if( typeof( expireDays ) == 'number' ) expireDate.setDate( expireDate.getDate() + expireDays );
	else expireDays = null;

	document.cookie = cookieName + "=" + escape( cookieValue ) + ( ( expireDays == null ) ? "" : ";expires=" + expireDate.toUTCString() );
}

WebShopUtil.prototype.deleteCookie = function( cookieName ) {
	var expireDate = new Date();
	document.cookie = cookieName + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

WebShopUtil.prototype.encodeUTF8 = function( s ) {
	if( typeof( s ) == 'undefined' ) return '';
	
	for( var c , i = -1 , l = (s = s.split( '' ) ).length , o = String.fromCharCode ; ++i < l;
		s[ i ] = ( c = s[ i ].charCodeAt( 0 ) ) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[ i ]
	);
	return s.join( '' );
}

WebShopUtil.prototype.decodeUTF8 = function( s ) {
	if( typeof( s ) == 'undefined' ) return '';

	for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
		((a = s[i][c](0)) & 0x80) &&
		(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
		o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
	);
	return s.join( "" );
}

WebShopUtil.prototype.moveDiv = function( divName , styleTag , values ) {
	var elem = get( divName );
	if( elem == null ) return;
	
	var style = null;

	if( elem.currentStyle ) style = elem.currentStyle[ styleTag ];
	else if( window.getComputedStyle ) style = document.defaultView.getComputedStyle( elem , null ).getPropertyValue( styleTag );
	
	if( style == values[ 0 ] ) this.changeCSSStyle( divName , styleTag , values[ 1 ] );
	else this.changeCSSStyle( divName , styleTag , values[ 0 ] );
}



