var Cp2 = {
	initialize: function()
	{
		Cp2.checkBoxes();
		$$('select.shalom').addEvent('change',Cp2.checkBoxes);

		if($('fileexternalcheckbox'))
		{
			$('fileexternalcheckbox').addEvent('change', function(e){
				if($('fileexternalcheckbox').get('checked'))
				{
					$('externallink').setStyle('display', 'block');
					$('fileupload').setStyle('display', 'none');
					$('fileuploadname').setStyle('display', 'none');
				}
				else
				{
					$('externallink').setStyle('display', 'none');
					$('fileupload').setStyle('display', 'block');
					$('fileuploadname').setStyle('display', 'block');
				}
			});

			if($('fileexternalcheckbox').get('checked'))
			{
				$('externallink').setStyle('display', 'block');
				$('fileupload').setStyle('display', 'none');
				$('fileuploadname').setStyle('display', 'none');
			}
			else
			{
				$('externallink').setStyle('display', 'none');
				$('fileupload').setStyle('display', 'block');
				$('fileuploadname').setStyle('display', 'block');
			}
		}

		if($$('.acchead').length > 1)
		{
			new Accordion($$('.acchead'), $$('.acccontent'));

		}

		if($$('.tooltip').length > 0)
		{
			new Tips('.tooltip');

		}

		if($$('.mochawindow').length > 0)
		{
			$$('.mochawindow').addEvent('click', function(e){
				new Event(e).stop();

				document.mochaUI.newWindow({
					loadMethod: 'xhr',
					contentURL: this.get('href'),
					height: 500,
					width: 400
				});
			});
		}

		if($('registerform'))
		{
			$('reason').addEvent('change', function(e){
				if(this.get('value') == 'Other')
				{
					$('otherreasonlabel').adopt(new Element('em', {'id': 'otherreasonlabelem','text':'*'}));
				}
				else
				{
					if($('otherreasonlabelem'))
					{
						$('otherreasonlabelem').destroy();
					}
				}

				if(this.get('value') == 'I am a customer')
				{
					$('seriallabel').adopt(new Element('em', {'id': 'seriallabelem','text':'*'}));
				}
				else
				{
					if($('seriallabelem'))
					{
						$('seriallabelem').destroy();
					}
				}
			});
		}

                if ($$('.Movie')){
		$$('.Movie').each(function(el){
			el.addEvent('click', function(e){
			new Event(e).stop();
				new MochaUI.Window({
					id: el.getProperty('html'),
					title: el.getProperty('html'),
					loadMethod: 'iframe',
					contentURL: el.getProperty('href'),
					width: 700,
					height: 525,
					resizable: true,
					scrollbars: false,
					paddingVertical: 0,
					paddingHorizontal: 0,
					bgColor: '#000'
				});
			});
		});
	}

	},

	checkBoxes: function ()
	{
	   $each($$('select.shalom'),function(select){
	       var value = select.value;
	       $each($$('select.shalom'),function(elem){
	          if (elem.getProperty('id') != select.getProperty('id'))
	          {
	              $each(elem.getChildren('option'),function(option){
	                   if (option.value != 'null')
	                   {
	                       if (option.getProperty('value') == value) option.setProperty('disabled');
	                       else option.removeProperty('disabled');
	                   }
	              });
	          }
	       });
            });
	},

	getfileinfos: function(fileid)
	{
            new MochaUI.Window({
                'id': 'Fileinfo_' + fileid,
                'title': 'Fileinfo',
                'loadMethod': 'xhr',
                'width': 300,
                'height': 150,
                'resizable': true,
                'scrollbars': false,
                'contentURL': '/support/download/getfileinfo/id/' + fileid
            });
	},

	checkserial: function()
	{
		var form = $('supportform');

		form.addEvent('submit', function(e)
		{
	var allok = true;
	//		e.stop();	gleiche wie return false;


			$('serial').setStyles({'border':''});
			$('subject').setStyles({'border':''});
			$('description').setStyles({'border':''});
			$('type').setStyles({'border':''});
			$('reason').setStyles({'border':''});

			$('alertserial').set('text', '');
			$('alertsubject').set('text', '');
			$('alertdescription').set('text', '');
			$('alerttype').set('text', '');
			$('alertreason').set('text', '');

			$('alertserial').set('class', '');
			$('alertsubject').set('class', '');
			$('alertdescription').set('class', '');
			$('alerttype').set('class', '');
			$('alertreason').set('class', '');



			if($('type').get('value') == 'PRX license upgrade, feature modules' || $('type').get('value') == 'PRX problem')
			{
				if(!($('serial').get('value') >= 100000 && $('serial').get('value') <= 999999))
				{
					$('serial').setStyles({'border':'#F00 2px solid'});
					allok = false;
					$('alertserial').set('text', 'Please provide the 6-digit serialnumber');
					$('alertserial').set('class', 'alert');
				}
			}

			if($('subject').get('value') == '')
			{
				$('subject').setStyles({'border':'#F00 2px solid'});
				allok = false;
				$('alertsubject').set('text', 'Please provide a subject.');
				$('alertsubject').set('class', 'alert');
			}

			if($('description').get('value') == '')
			{
				$('description').setStyles({'border':'#F00 2px solid'});
				allok = false;
				$('alertdescription').set('text','Please provide a Description.');
				$('alertdescription').set('class', 'alert');
			}

			if($('type').get('value') == '')
			{
				$('type').setStyles({'border':'#F00 2px solid'});
				allok = false;
				$('alerttype').set('text','Please select a type.');
				$('alerttype').set('class', 'alert');
			}

			if($('reason').get('value') == '')
			{
				$('reason').setStyles({'border':'#F00 2px solid'});
				allok = false;
				$('alertreason').set('text','Please select a reason.');
				$('alertreason').set('class', 'alert');
			}

			return allok;
		});

	}/*,

	checktype: function()
	{
		if($('type').get('value') != 'PRX license upgrade, feature modules' && $('type').get('value') != 'PRX problem')
		{
			$('serial').set('disabled', 'disabled');
			$('serial').set('value', '');
		}
		else
		{
			$('serial').removeProperty('disabled');
		}
	}
*/
};



window.addEvent('load',Cp2.initialize);
