myForms = Array();

function gebi(id)
{
	return document.getElementById(id);
}

function addSection()
{
	valdate = validateCv();
	if(valdate=='')
	{
		cForm = gebi('currentForm').value;
		if(cForm == '')
		{
			myForms.push(new myform(myForms.length));
			myformObj = myForms[myForms.length-1];
		}
		else
		{
			myformObj = myForms[cForm];
		}
		
		myformObj.field1 = gebi('txt_cvcompany').value;
		myformObj.field2 = gebi('txt_cvwww').value;
		myformObj.field3 = gebi('txt_cvproject').value;
		myformObj.field4 = gebi('txt_cvart').value;
		myformObj.field5 = gebi('cvfyear').value;
		myformObj.field6 = gebi('cvfmonth').value;
		myformObj.field7 = gebi('cvtyear').value;
		myformObj.field8 = gebi('cvtmonth').value;
		myformObj.field10 = gebi('cvdesc').value;
		myformObj.field9 = gebi('txt_cvposition').value;
		
		renderAll();
		
		emptyForm();
	}
	else
	{
		//alert(valdate);
		//gebi('currentForm').innerHTML = valdate;
	}
}
function emptyForm()
{
	gebi('currentForm').value = '';
	gebi('txt_cvcompany').value = '';
	gebi('txt_cvwww').value = '';
	gebi('txt_cvproject').value = '';
	gebi('txt_cvart').value = '';
	gebi('cvfyear').value = '';
	gebi('cvfmonth').value = '';
	gebi('cvtyear').value = '';
	gebi('cvtmonth').value = '';
	gebi('cvdesc').value = '';
	gebi('txt_cvposition').value = '';
}
function renderAll(){
	html='';
	for(i=0; i< myForms.length; i++)
	{
		myformObj = myForms[i];
		html += myformObj.render();
	}
	gebi('formContainer').innerHTML = html;
	emptyForm();
	test();
}
function editForm(formId){

	myFormObj = myForms[formId];
	gebi('txt_cvcompany').value=myFormObj.field1;
	gebi('txt_cvposition').value=myFormObj.field9;
	gebi('txt_cvwww').value=myFormObj.field2;
	gebi('txt_cvproject').value=myFormObj.field3;
	gebi('txt_cvart').value=myFormObj.field4;
	gebi('cvfyear').value=myFormObj.field5;
	gebi('cvfmonth').value=myFormObj.field6;
	gebi('cvtyear').value=myFormObj.field7;
	gebi('cvtmonth').value=myFormObj.field8;
	gebi('cvdesc').value=myFormObj.field10;
	gebi('currentForm').value=myFormObj.id;
}
function delForm(formId){

	myForms.splice(formId,1);	
	for(i=0; i< myForms.length; i++)
	{
		myformObj = myForms[i];
		myformObj.id = i;
	}
	renderAll();
}
function myform(count)
{
	this.id=count
	this.dbID=0;
	this.sortId = this.id;
	this.field1='';
	this.field2='';
	this.field3='';
	this.html='';
	
	var upBtn = '';
	var downBtn = '';
	var up = 'up';
	var down = 'down';
	
	this.render=function(){
		//alert("count = " + myForms.length + " id => " + this.id);

		if(this.id > 0){
			upBtn = '<a href="javascript:sortSection('+this.id+',\''+up+'\');"><img src="fileadmin/templates/images/move-up.gif"  alt=""/></a>';
		}
		else
		{
			upBtn = '';
		}
		
		if((myForms.length -1) > this.id){
			downBtn = '<a href="javascript:sortSection('+this.id+',\''+down+'\');""><img src="fileadmin/templates/images/move-down.gif"  alt=""/></a>';
		}
		else
		{
			downBtn = '';
		}
		if(this.field2!='')
		{
			var strLink = this.field2.split('http://');	
			var sLnk = '';
			if(strLink[0]=='')
			{
				strLink[0] = '';
				sLnk = '';				
			}
			else
			{
				sLnk = 'http://'+strLink[0];				
			}
		}
		this.html = '';	
		this.html += '<div id="' + this.id +  '">';
			this.html += '<div class="innerContent">';
				this.html += '<div class="UserProject">';
					this.html += '<div class="ProjectTools"> <a href="javascript:editForm('+this.id+')"><img src="fileadmin/templates/images/icon-edit.gif"  alt=""/></a> <a href="javascript:delForm('+this.id+')"><img src="fileadmin/templates/images/icon-delete.gif"  alt=""/></a> </div>';
						this.html += '<div class="ProjectDis">';
							this.html += '<ul class="ProjectList">';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Firma: </div>';
									this.html += '<div class="ProjectDetail"><a href="'+ sLnk +'" target="_blank"><strong>' + this.field1 +'</strong></a></div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Projekt: </div>';
									this.html += '<div class="ProjectDetail">' + this.field3 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Position: </div>';
									this.html += '<div class="ProjectDetail">' + this.field9 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Art: </div>';
									this.html += '<div class="ProjectDetail">' + this.field4 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Dauer: </div>';
									this.html += '<div class="ProjectDetail"><div class="ProjectDetail">von '+ this.field6 +' / '+ this.field5 +' bis '+ this.field8 +' / '+ this.field7 +'</div></div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Beschreibung: </div>';
									this.html += '<div class="ProjectDetail">' + this.field10 +'</div>';
								this.html += '</li> ';
		this.html += '</ul><div class="clr"></div></div><div class="MoveAction"> '+upBtn+' '+downBtn+' </div></div></div><div class="sptr5"></div></div>';
		
		return this.html;
	}
}
function test()
{
	html = '';
	for(i=0; i< myForms.length; i++)
	{
		myformObj = myForms[i];
		
		html += '<input type ="hidden" name="secforms['+i+'][field1]" value ="'+myformObj.field1+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field2]" value ="'+myformObj.field2+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field3]" value ="'+myformObj.field3+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field4]" value ="'+myformObj.field4+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field5]" value ="'+myformObj.field5+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field6]" value ="'+myformObj.field6+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field7]" value ="'+myformObj.field7+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field8]" value ="'+myformObj.field8+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field9]" value ="'+myformObj.field9+'">';
		html += '<input type ="hidden" name="secforms['+i+'][field10]" value ="'+myformObj.field10+'">';		
		html += '<input type ="hidden" name="secforms['+i+'][dbID]" value ="'+myformObj.dbID+'">';
		html += '<input type ="hidden" name="secforms['+i+'][id]" value ="'+myformObj.id+'">';
		html += '<input type ="hidden" name="secforms['+i+'][sortId]" value ="'+myformObj.sortId+'">';
		
	}
	gebi('myhidden').innerHTML = html;
}
function sortSection(formid,option){

	if(option=='down')
	{
		
		var next = formid + 1;
		
		tempObj = myForms[next];
		
		myForms[next] = myForms[formid];
		myForms[next].id = next;
		//alert(myForms[next].id);
		
		myForms[formid] = tempObj;
		myForms[formid].id = formid;
		
		//alert(myForms[formid].id);
		
		renderAll();	
	}
	else if(option=='up')
	{
		var prev = formid - 1;
		
		tempObj = myForms[prev];
		
		myForms[prev] = myForms[formid];
		myForms[prev].id = prev;
		//alert(myForms[next].id);
		
		myForms[formid] = tempObj;
		myForms[formid].id = formid;
		
		//alert(myForms[formid].id);
		
		renderAll();	
	}
}
function validateCv()
{
	company = gebi('txt_cvcompany').value;
	company = textTrim(company, '');
	project = gebi('txt_cvproject').value;
	project = textTrim(project, '');	
	fyear = gebi('cvfyear').value;
	fmonth = gebi('cvfmonth').value;
	tyear = gebi('cvtyear').value;
	tmonth = gebi('cvtmonth').value;
	var msg = '';
	if(company == '')
	{
		msg += 'Please add company name \n';	
	}
	if(project == '')
	{
		msg += 'Please add project name \n';	
	}
	if((fyear != '' && fmonth == '') || (fyear == '' && fmonth != ''))
	{
		msg += 'Please select from date \n';	
	}
	if((tyear != '' && tmonth == '') || (tyear == '' && tmonth != ''))
	{
		msg += 'Please select todate \n';	
	}
	if((tyear != '' && fyear != '') && (fyear > tyear))
	{
		msg += 'To date should be greater than from date \n';	
	}
	if((tyear == fyear) && (fmonth > tmonth))
	{
		msg += 'To date should be greater than from date \n';	
	}
	return msg;	
}
//////////////////////////////////////////////////////////////////////////////////
///////---------------------Edit Profile Experience-----------------------////////
//////////////////////////////////////////////////////////////////////////////////

function addSectionExp()
{
	valdate = validateExp();
	if(valdate=='')
	{
		cForm = gebi('currentExpForm').value;
		if(cForm == '')
		{
			myExpForms.push(new expForm(myExpForms.length));
			myformObj = myExpForms[myExpForms.length-1];
		}
		else
		{
			myformObj = myExpForms[cForm];
		}
		
		myformObj.field1 = gebi('exp_title').value;
		myformObj.field2 = gebi('exp_study').value;
		myformObj.field3 = gebi('exp_focus').value;
		myformObj.field4 = gebi('exp_final').value;
		myformObj.field5 = gebi('exp_note').value;
		myformObj.field6 = gebi('expfmonth').value;
		myformObj.field7 = gebi('expfyear').value;
		myformObj.field8 = gebi('exptmonth').value;
		myformObj.field9 = gebi('exptyear').value;
	
		renderExpAll();
		
		emptyExpForm();
	}
	else
	{
		//alert(valdate);
	}
}
function emptyExpForm()
{
	gebi('exp_title').value = '';
	gebi('exp_study').value = '';
	gebi('exp_focus').value = '';
	gebi('exp_final').value = '';
	gebi('exp_note').value = '';
	gebi('expfmonth').value = '';
	gebi('expfyear').value = '';
	gebi('exptmonth').value = '';
	gebi('exptyear').value = '';
	gebi('currentExpForm').value = '';
}
function renderExpAll(){
	html='';
	for(i=0; i< myExpForms.length; i++)
	{
		myformObj = myExpForms[i];
		html += myformObj.render();
	}
	gebi('formContainerExp').innerHTML = html;
	emptyExpForm();
	expHidden();
}
function editExpForm(formId){

	myFormObj = myExpForms[formId];
	gebi('exp_title').value=myFormObj.field1;
	gebi('exp_study').value=myFormObj.field2;
	gebi('exp_focus').value=myFormObj.field3;
	gebi('exp_final').value=myFormObj.field4;
	gebi('exp_note').value=myFormObj.field5;
	gebi('expfmonth').value=myFormObj.field6;
	gebi('expfyear').value=myFormObj.field7;
	gebi('exptmonth').value=myFormObj.field8;
	gebi('exptyear').value=myFormObj.field9;
	gebi('currentExpForm').value=myFormObj.id;
}
function expForm(count)
{
	this.id=count
	this.dbID=0;
	this.sortId = this.id;
	this.field1='';
	this.field2='';
	this.field3='';
	this.html='';
	
	var upBtn = '';
	var downBtn = '';
	var up = 'up';
	var down = 'down';
	
	this.render=function(){
		//alert("count = " + myForms.length + " id => " + this.id);

		if(this.id > 0){
			upBtn = '<a href="javascript:sortExpSection('+this.id+',\''+up+'\');"><img src="fileadmin/templates/images/move-up.gif"  alt=""/></a>';
		}
		else
		{
			upBtn = '';
		}
		
		if((myExpForms.length -1) > this.id){
			downBtn = '<a href="javascript:sortExpSection('+this.id+',\''+down+'\');""><img src="fileadmin/templates/images/move-down.gif"  alt=""/></a>';
		}
		else
		{
			downBtn = '';
		}

		this.html = '';	
		this.html += '<div id="' + this.id +  '">';
			this.html += '<div class="innerContent">';
				this.html += '<div class="UserProject">';
					this.html += '<div class="ProjectTools"> <a href="javascript:editExpForm('+this.id+')"><img src="fileadmin/templates/images/icon-edit.gif"  alt=""/></a> <a href="javascript:delExpForm('+this.id+')"><img src="fileadmin/templates/images/icon-delete.gif"  alt=""/></a> </div>';
						this.html += '<div class="ProjectDis">';
							this.html += '<ul class="ProjectList">';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Hochschulen: </div>';
									this.html += '<div class="ProjectDetail">' + this.field1 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Studiengang: </div>';
									this.html += '<div class="ProjectDetail">' + this.field2 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Schwerpunkt: </div>';
									this.html += '<div class="ProjectDetail">' + this.field3 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Abschluss: </div>';
									this.html += '<div class="ProjectDetail">' + this.field4 +', ' + this.field5 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Dauer: </div>';
									this.html += '<div class="ProjectDetail"><div class="ProjectDetail">von '+ this.field6 +' / '+ this.field7 +' bis '+ this.field8 +' / '+ this.field9 +'</div></div>';
								this.html += '</li> ';
		this.html += '</ul><div class="clr"></div></div><div class="MoveAction"> '+upBtn+' '+downBtn+' </div></div></div><div class="sptr5"></div></div>';
		
		return this.html;
	}
}
function expHidden()
{
	html = '';
	for(i=0; i< myExpForms.length; i++)
	{
		myformObj = myExpForms[i];
		
		html += '<input type ="hidden" name="secExpForms['+i+'][field1]" value ="'+myformObj.field1+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][field2]" value ="'+myformObj.field2+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][field3]" value ="'+myformObj.field3+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][field4]" value ="'+myformObj.field4+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][field5]" value ="'+myformObj.field5+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][field6]" value ="'+myformObj.field6+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][field7]" value ="'+myformObj.field7+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][field8]" value ="'+myformObj.field8+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][field9]" value ="'+myformObj.field9+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][dbID]" value ="'+myformObj.dbID+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][id]" value ="'+myformObj.id+'">';
		html += '<input type ="hidden" name="secExpForms['+i+'][sortId]" value ="'+myformObj.sortId+'">';
		
	}
	gebi('myExpHidden').innerHTML = html;
	
}
function delExpForm(formId){

	myExpForms.splice(formId,1);
	for(i=0; i< myExpForms.length; i++)
	{
		myformObj = myExpForms[i];
		myformObj.id = i;
	}
	
	renderExpAll();
}
function sortExpSection(formid,option){

	if(option=='down')
	{
		
		var next = formid + 1;
		
		tempObj = myExpForms[next];
		
		myExpForms[next] = myExpForms[formid];
		myExpForms[next].id = next;
		//alert(myForms[next].id);
		
		myExpForms[formid] = tempObj;
		myExpForms[formid].id = formid;
		
		//alert(myForms[formid].id);
		
		renderExpAll();	
	}
	else if(option=='up')
	{
		var prev = formid - 1;
		
		tempObj = myExpForms[prev];
		
		myExpForms[prev] = myExpForms[formid];
		myExpForms[prev].id = prev;
		//alert(myForms[next].id);
		
		myExpForms[formid] = tempObj;
		myExpForms[formid].id = formid;
		
		//alert(myForms[formid].id);
		
		renderExpAll();	
	}
}
function validateExp()
{
	title = gebi('exp_title').value;
	title = textTrim(title, '');	
	study = gebi('exp_study').value;
	study = textTrim(study, '');	
	fcus = gebi('exp_focus').value;
	fcus = textTrim(fcus, '');		
	final = gebi('exp_final').value;
	final = textTrim(final, '');		
	note = gebi('exp_note').value;	
	note = textTrim(note, '');			
	fyear = gebi('expfyear').value;
	fmonth = gebi('expfmonth').value;
	tyear = gebi('exptyear').value;
	tmonth = gebi('exptmonth').value;
	var msg = '';
	if(title == '')
	{
		msg += 'Please add Hochschulen \n';	
	}
	if(study == '')
	{
		msg += 'Please add Studiengang \n';	
	}
	if(fcus == '')
	{
		msg += 'Please add Schwerpunkt \n';	
	}
	if(final == '')
	{
		msg += 'Please add Abschluss \n';	
	}
	if(note == '')
	{
		msg += 'Please add Note \n';	
	}	
	if((fyear != '' && fmonth == '') || (fyear == '' && fmonth != ''))
	{
		msg += 'Please select from date \n';	
	}
	if((tyear != '' && tmonth == '') || (tyear == '' && tmonth != ''))
	{
		msg += 'Please select todate \n';	
	}
	if((tyear != '' && fyear != '') && (fyear > tyear))
	{
		msg += 'To date should be greater than from date \n';	
	}
	if((tyear == fyear) && (fmonth > tmonth))
	{
		msg += 'To date should be greater than from date \n';	
	}
	return msg;	
}
//////////////////////////////////////////////////////////////////////////////////
///////---------------------Edit Profile Competition----------------------////////
//////////////////////////////////////////////////////////////////////////////////

function addSectionComp()
{
	valdate = validateComp();
	if(valdate=='')
	{
		cForm = gebi('currentCompForm').value;
		if(cForm == '')
		{
			myCompForms.push(new compForm(myCompForms.length));
			myformObj = myCompForms[myCompForms.length-1];
		}
		else
		{
			myformObj = myCompForms[cForm];
		}
		
		myformObj.field1 = gebi('comp_name').value;
		myformObj.field2 = gebi('comp_place').value;
		myformObj.field3 = gebi('comp_link').value;
		myformObj.field4 = gebi('comp_participate1').value;
		myformObj.field5 = gebi('comp_participate2').value;
		myformObj.field6 = gebi('comp_desc').value;
	
		renderCompAll();
		
		emptyCompForm();
	}
	else
	{
		//alert(valdate);	
	}
}
function emptyCompForm()
{
	gebi('comp_name').value = '';
	gebi('comp_place').value = '';
	gebi('comp_link').value = '';
	gebi('comp_participate1').value = '';
	gebi('comp_participate2').value = '';
	gebi('comp_desc').value = '';
	gebi('currentCompForm').value = '';
}
function renderCompAll(){
	html='';
	for(i=0; i< myCompForms.length; i++)
	{
		myformObj = myCompForms[i];
		html += myformObj.render();
	}
	gebi('formContainerComp').innerHTML = html;
	emptyCompForm();
	compHidden();
}
function editCompForm(formId){

	myFormObj = myCompForms[formId];
	gebi('comp_name').value=myFormObj.field1;
	gebi('comp_place').value=myFormObj.field2;
	gebi('comp_link').value=myFormObj.field3;
	gebi('comp_participate1').value=myFormObj.field4;
	gebi('comp_participate2').value=myFormObj.field5;
	gebi('comp_desc').value=myFormObj.field6;
	gebi('currentCompForm').value=myFormObj.id;
}
function compForm(count)
{
	this.id=count
	this.dbID=0;
	this.sortId = this.id;
	this.field1='';
	this.field2='';
	this.field3='';
	this.html='';
	
	var upBtn = '';
	var downBtn = '';
	var up = 'up';
	var down = 'down';
	
	this.render=function(){
		//alert("count = " + myForms.length + " id => " + this.id);

		if(this.id > 0){
			upBtn = '<a href="javascript:sortCompSection('+this.id+',\''+up+'\');"><img src="fileadmin/templates/images/move-up.gif"  alt=""/></a>';
		}
		else
		{
			upBtn = '';
		}
		
		if((myCompForms.length -1) > this.id){
			downBtn = '<a href="javascript:sortCompSection('+this.id+',\''+down+'\');""><img src="fileadmin/templates/images/move-down.gif"  alt=""/></a>';
		}
		else
		{
			downBtn = '';
		}
		if(this.field2!='')
		{
			var urlLink = this.field3.split('http://');	
			var uLnk = '';
			if(urlLink[0]=='')
			{
				urlLink[0] = '';
				uLnk = '';				
			}
			else
			{
				uLnk = 'http://'+urlLink[0];				
			}
		}
		this.html = '';	
		this.html += '<div id="' + this.id +  '">';
			this.html += '<div class="innerContent">';
				this.html += '<div class="UserProject">';
					this.html += '<div class="ProjectTools"> <a href="javascript:editCompForm('+this.id+')"><img src="fileadmin/templates/images/icon-edit.gif"  alt=""/></a> <a href="javascript:delCompForm('+this.id+')"><img src="fileadmin/templates/images/icon-delete.gif"  alt=""/></a> </div>';
						this.html += '<div class="ProjectDis">';
							this.html += '<ul class="ProjectList">';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Name: </div>';
									this.html += '<div class="ProjectDetail">' + this.field1 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Platzierung: </div>';
									this.html += '<div class="ProjectDetail">' + this.field2 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Link: </div>';
									this.html += '<div class="ProjectDetail"><a href="' + uLnk +'">' + this.field3 +'</a></div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Teilnahme: </div>';
									this.html += '<div class="ProjectDetail">' + this.field4 +' / ' + this.field5 +'</div>';
								this.html += '</li> ';
								this.html += '<li>';
									this.html += '<div class="Projectlabel">Beschreibung: </div>';
									this.html += '<div class="ProjectDetail">'+ this.field6 +'</div></div>';
								this.html += '</li> ';
		this.html += '</ul><div class="clr"></div><div class="MoveAction"> '+upBtn+' '+downBtn+' </div></div></div></div><div class="sptr5"></div></div>';
		
		return this.html;
	}
}
function compHidden()
{
	html = '';
	for(i=0; i< myCompForms.length; i++)
	{
		myformObj = myCompForms[i];
		
		html += '<input type ="hidden" name="secCompForms['+i+'][field1]" value ="'+myformObj.field1+'">';
		html += '<input type ="hidden" name="secCompForms['+i+'][field2]" value ="'+myformObj.field2+'">';
		html += '<input type ="hidden" name="secCompForms['+i+'][field3]" value ="'+myformObj.field3+'">';
		html += '<input type ="hidden" name="secCompForms['+i+'][field4]" value ="'+myformObj.field4+'">';
		html += '<input type ="hidden" name="secCompForms['+i+'][field5]" value ="'+myformObj.field5+'">';
		html += '<input type ="hidden" name="secCompForms['+i+'][field6]" value ="'+myformObj.field6+'">';
		html += '<input type ="hidden" name="secCompForms['+i+'][dbID]" value ="'+myformObj.dbID+'">';
		html += '<input type ="hidden" name="secCompForms['+i+'][id]" value ="'+myformObj.id+'">';
		html += '<input type ="hidden" name="secCompForms['+i+'][sortId]" value ="'+myformObj.sortId+'">';
		
	}
	gebi('myCompHidden').innerHTML = html;
	
}
function delCompForm(formId){

	myCompForms.splice(formId,1);
	for(i=0; i< myCompForms.length; i++)
	{
		myformObj = myCompForms[i];
		myformObj.id = i;
	}
	
	renderCompAll();
}
function sortCompSection(formid,option){

	if(option=='down')
	{
		
		var next = formid + 1;
		
		tempObj = myCompForms[next];
		
		myCompForms[next] = myCompForms[formid];
		myCompForms[next].id = next;
		//alert(myForms[next].id);
		
		myCompForms[formid] = tempObj;
		myCompForms[formid].id = formid;
		
		//alert(myForms[formid].id);
		
		renderCompAll();	
	}
	else if(option=='up')
	{
		var prev = formid - 1;
		
		tempObj = myCompForms[prev];
		
		myCompForms[prev] = myCompForms[formid];
		myCompForms[prev].id = prev;
		//alert(myForms[next].id);
		
		myCompForms[formid] = tempObj;
		myCompForms[formid].id = formid;
		
		//alert(myForms[formid].id);
		
		renderCompAll();	
	}
}
function validateComp()
{
	name = gebi('comp_name').value;
	place = gebi('comp_place').value;
	part1 = gebi('comp_participate1').value;
	part2 = gebi('comp_participate2').value;

	var msg = '';
	if(name == '')
	{
		msg += 'Please add name \n';	
	}
	if(place == '')
	{
		msg += 'Please add placement \n';	
	}
	if((part1 != '' && part2 == '') || (part1 == '' && part2 != ''))
	{
		msg += 'Please select Teilnahme \n';	
	}
	
	return msg;	
}

function fill_subcategory_combo(Language)
{
	// get category id
	category_id = document.frm_addcont.cmb_article_categories.value;

	purl = "index.php"; 
	param  = "?eID=ajax_subcategory_combo&category_id="+category_id+"&L="+Language+"&rand="+ Math.floor(Math.random() * 1000000);
	target = "subcategory_combobox"; // span or div id, where the value will be returned
	
	ajax_url = purl + param;
			
	//myAjax = new Ajax.Updater(target,url,{method: 'get',parameters: param, asynchronous:true, evalScripts:true});
	
	// Make the ajax call, replace text
	var req = new Request.HTML({
		method: 'get',
		url: ajax_url,
		update: $(target)
	}).send();
}
function textTrim(str, chars) {
	return ltextTrim(rtextTtrim(str, chars), chars);
}
 
function ltextTrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtextTtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}