/* publikus oldali scriptek */

function makeSwfString( sString ) {
	var aSwf = sString.split( ',' ); /* a tömb elemei sorrendben: url, id, width, height, version */
    var sSwfString = '<div id="' + aSwf[1] + '">'
      + '</div>'
      + '<script type="text/javascript">'
      + '/*<![CDATA[*/'
      + '  var so = new SWFObject("' + aSwf[0] + '", "' + aSwf[1] + '_name", "' + aSwf[2] + '", "' + aSwf[3] + '", "' + aSwf[4] + '", "");'
      + '  so.addParam("quality", "medium");'
      + '  so.write("' + aSwf[1] + '");'
      + '/* ]]>*/'
      + '</script>';
	return sSwfString;
}

function selectRandomBanner( aItems ) {
	var sString = aItems[Math.floor( Math.random()*aItems.length )];
	if ( /\.swf/.test( sString ) ) {
		return makeSwfString( sString );
	}
	else {
		return  sString || '';
	}
}

addEvent( window, 'load', function() {
	if ( hasClass( document.body, 'contact-us' ) ) {
		proform.config.submitError = 'Missing data!';
		proform.initForm( 'contact_form' );
		proform.addGroup( { id : 'contact_data', 
		                    elements : [ 'name', 'company_name', 'email', 'message' ],
		                    validate : true,
		                    processor : function ( oT ) {
								var aReturn = [];
								aReturn.push( proform.condition.required( oT.name.value == '', [oT.name] ) );
								aReturn.push( proform.condition.required( oT.email.value == '', [oT.email] ) );
								aReturn.push( proform.condition.warning( oT.email.value != '' && !proform.condition.checkFormat( 'email', oT.email.value ), [oT.email], ['Wrong email format.'] ) );
								aReturn.push( proform.condition.required( oT.message.value == '', [oT.message] ) );
								return proform.condition.totalize(aReturn);
							}
		                  } );
		proform.init();
	
	}
});

addEvent( window, 'load', function() {
	if ( hasClass( document.body, 'nodepo' ) ) {
		proform.config.submitError = 'Missing data!';
		proform.initForm( 'nodepo_form' );
		proform.addGroup( { id : 'nodepo_data', 
		                    elements : [ 'name', 'nickname1', 'nickname2', 'email', 'notification' ],
		                    validate : true,
		                    processor : function ( oT ) {
								var aReturn = [];
								aReturn.push( proform.condition.required( oT.name.value == '', [oT.name] ) );
								aReturn.push( proform.condition.required( oT.nickname1.value == '', [oT.nickname1] ) );
								aReturn.push( proform.condition.required( oT.nickname2.value == '', [oT.nickname2] ) );
								aReturn.push( proform.condition.required( oT.email.value == '', [oT.email] ) );
								aReturn.push( proform.condition.warning( oT.email.value != '' && !proform.condition.checkFormat( 'email', oT.email.value ), [oT.email], ['Wrong email format.'] ) );
								aReturn.push( proform.condition.required( oT.notification.checked == '', [oT.notification] ) );
								return proform.condition.totalize(aReturn);
							}
		                  } );
		proform.init();
	
	}
});