/*function changeIt()
{

	var element = document.getElementById('counter');
	var counter = element.value;
	var i = ++counter;
	element.value = i;
	var titlelabel = document.createElement('label');
	titlelabel.setAttribute('for','seminar_template_detail_title_' + i);
	titlelabel.innerHTML="Title:";	
	var sortlabel = document.createElement('label');
	sortlabel.setAttribute('for','seminar_template_detail_sort_' + i);
	sortlabel.innerHTML="Sort:";
	var otherdiv = document.createElement('div');
	
	var titleinput = document.createElement('input');
	titleinput.setAttribute('id','seminar_template_detail_title_' + i);	
	titleinput.setAttribute('name','seminar_template_detail[gentitle' + i +']');
	titleinput.setAttribute('type',"text");
	
	var titlediv = document.createElement('div');
	titlediv.appendChild(titlelabel);
	titlediv.appendChild(titleinput);
	titlediv.setAttribute('class','form-row');
	titlediv.setAttribute('id','title' + i);
	var link = document.createElement('a');
	//link.innerHTML = '<a onClick = "removeIt(' + i + ');" href = "#" > Remove </a>';
	link.innerHTML = 'Remove' ;
	link.setAttribute('onClick','removeIt('+ i +'); return false;');
	
	link.setAttribute('href', '#');
	titlediv.appendChild(link);
	
	var sortinput = document.createElement('input');
	sortinput.setAttribute('name','seminar_template_detail[gensort' + i +']');
	sortinput.setAttribute('type',"text");
	sortinput.setAttribute('id','seminar_template_detail_sort_' + i);
	var sortdiv = document.createElement('div');
	sortdiv.appendChild(sortlabel);
	sortdiv.appendChild(sortinput);
	sortdiv.setAttribute('class','form-row');
	sortdiv.setAttribute('id','sort' + i);
	
	
	//otherdiv.appendChild(titlediv);	
	//otherdiv.appendChild(sortdiv);
	var textlabel = document.createElement('label');
	textlabel.innerHTML="Detail:";
	var textarea = document.createElement('textarea');
	var textname='seminar_template_detail[gendetail' + i + ']';
	textarea.setAttribute('name',textname);
	textarea.setAttribute('id','seminar_template_detail_detail_' + i);
	//textarea.setAttribute('style','width:600px; height:200px;');
	textarea.setAttribute('class','seminartemplatedetail');
	//textarea.setAttribute('id',textname);
	//otherdiv.setAttribute('id',textname + 'title');
	//otherdiv.setAttribute('class','form-row');
	var newdiv = document.createElement('div');
	newdiv.appendChild(textlabel);
	newdiv.appendChild(textarea);
	newdiv.setAttribute('class','form-row');
	newdiv.setAttribute('id','detail' + i);
	var divelement = document.getElementById('extrainputdiv');
	divelement.appendChild(titlediv);
	divelement.appendChild(sortdiv);	
	divelement.appendChild(newdiv); 
	var textname = 'seminar_template_detail[' + 'mytext' + i  +']';
	tinyMCE.execCommand('mceAddControl', true, 'seminar_template_detail_detail_' + i );
	//throw ('generated' + 'seminar_template_detail_detail_' + i );
	
}
function changeItwoEditor()
{

	var element = document.getElementById('counter');
	var counter = element.value;
	var i = ++counter;
	element.value = i;
	var titlelabel = document.createElement('label');
	titlelabel.setAttribute('for','seminar_template_detail_title_' + i);
	titlelabel.innerHTML="Title:";	
	var sortlabel = document.createElement('label');
	sortlabel.setAttribute('for','seminar_template_detail_sort_' + i);
	sortlabel.innerHTML="Sort:";
	var otherdiv = document.createElement('div');
	
	var titleinput = document.createElement('input');
	titleinput.setAttribute('id','seminar_template_detail_title_' + i);	
	titleinput.setAttribute('name','seminar_template_detail[gentitle' + i +']');
	titleinput.setAttribute('type',"text");
	
	var titlediv = document.createElement('div');
	titlediv.appendChild(titlelabel);
	titlediv.appendChild(titleinput);
	titlediv.setAttribute('class','form-row');
	titlediv.setAttribute('id','title' + i);
	var link = document.createElement('a');
	//link.innerHTML = '<a onClick = "removeIt(' + i + ');" href = "#" > Remove </a>';
	link.innerHTML = 'Remove' ;
	link.setAttribute('onClick','removeIt('+ i +');');
	
	link.setAttribute('href', '#');
	titlediv.appendChild(link);
	
	var sortinput = document.createElement('input');
	sortinput.setAttribute('name','seminar_template_detail[gensort' + i +']');
	sortinput.setAttribute('type',"text");
	sortinput.setAttribute('id','seminar_template_detail_sort_' + i);
	var sortdiv = document.createElement('div');
	sortdiv.appendChild(sortlabel);
	sortdiv.appendChild(sortinput);
	sortdiv.setAttribute('class','form-row');
	sortdiv.setAttribute('id','sort' + i);
	
	
	//otherdiv.appendChild(titlediv);	
	//otherdiv.appendChild(sortdiv);
	var textlabel = document.createElement('label');
	textlabel.innerHTML="Detail:";
	var textarea = document.createElement('textarea');
	var textname='seminar_template_detail[gendetail' + i + ']';
	textarea.setAttribute('name',textname);
	textarea.setAttribute('class','mce');
	textarea.setAttribute('id','seminar_template_detail_detail_' + i);
	//textarea.setAttribute('style','width:600px; height:200px;');
	textarea.setAttribute('class','seminartemplatedetail');
	//textarea.setAttribute('id',textname);
	//otherdiv.setAttribute('id',textname + 'title');
	//otherdiv.setAttribute('class','form-row');
	var newdiv = document.createElement('div');
	newdiv.appendChild(textlabel);
	newdiv.appendChild(textarea);
	newdiv.setAttribute('class','form-row');
	newdiv.setAttribute('id','detail' + i);
	var divelement = document.getElementById('extrainputdiv');
	divelement.appendChild(titlediv);
	divelement.appendChild(sortdiv);	
	divelement.appendChild(newdiv); 
}


function removeIt(i){
	
	 var counterelement = document.getElementById('counter');
	 var counter = counterelement.value;
	 var extra = document.getElementById('extrainputdiv');
	 var titlediv = document.getElementById('title' + i);
	 var sortdiv = document.getElementById('sort' + i);
	 var detaildiv = document.getElementById('detail' + i);
	 var j=0;
	if(i<counter)
	{
	 
	 var titlearray = new Array();
	 var sortarray = new Array();
	 var detailarray = new Array();	

	 tinyMCE.execCommand('mceRemoveControl', false, 'seminar_template_detail_detail_' + i);
	 //fetch values
	 for(j=i+1;j<=counter;j++)
	  {
	  	 titlearray[j] = document.getElementById('seminar_template_detail_title_' + j).value;
	      sortarray[j]= document.getElementById('seminar_template_detail_sort_' + j).value;
	      tinyMCE.execCommand('mceRemoveControl', false, 'seminar_template_detail_detail_' + j);
	      detailarray[j]= document.getElementById('seminar_template_detail_detail_' + j).value;	
	      
	  }
	

	  //remove nodes
	var remove = 0;
	for(j=i;j<=counter;j++)
	  {
	   titlediv = document.getElementById('title' + j);
	   sortdiv = document.getElementById('sort' + j);
	   detaildiv = document.getElementById('detail' + j);	 
	   extra.removeChild(titlediv);
	   extra.removeChild(sortdiv);
	   extra.removeChild(detaildiv);
	   remove++;
	 } 
	 
	 
	  //update counter
	  counterelement.value = i-1;
	
	  //create nodes
	  var number = 0;
	  for(j=i;j<counter;j++)
	  {
	  number++;
	   changeIt();
	   //tinyMCE.execCommand('mceAddControl', true, 'seminar_template_detail_detail_' + j);
	    document.getElementById('seminar_template_detail_title_' + j).value = titlearray[j+1];
	    document.getElementById('seminar_template_detail_sort_' + j).value = sortarray[j+1];
	    document.getElementById('seminar_template_detail_detail_' + j).value = detailarray[j+1];
	    
 

	  }
	//  throw('number' +number + 'counter' + counter + 'i' + i + 'remove' + remove);
	  //fillin values
	  for(j=i;j<counterelement.value;j++)
	  {

	  
	  }
	  
	
	 }
	 else{
	   titlediv = document.getElementById('title' + i);
	   sortdiv = document.getElementById('sort' + i);
	   detaildiv = document.getElementById('detail' + i);
	
	  extra.removeChild(titlediv);
	  extra.removeChild(sortdiv);
	  extra.removeChild(detaildiv);
	  counterelement.value=--counter;
	    
	 }
 }*/
	

function initTinyMce(){
	tinyMCE.init({
		mode: 'textareas',
		language: "en", 
		plugins: "table,advimage,advlink,flash,fullscreen,inlinepopups,contextmenu,directionality", 
		theme: 'advanced', 
		theme_advanced_toolbar_location: "top", 
		theme_advanced_toolbar_align: "left", 
		theme_advanced_path_location: "bottom", 
		theme_advanced_buttons1: "justifyleft,justifycenter,justifyright,justifyfull,ltr,rtl,separator,bold,italic,strikethrough,separator,sub,sup,separator,charmap,fontselect,fontsizeselect",
		theme_advanced_buttons2: "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,separator,pastetext, pasteword,cleanup,removeformat,separator,code,forecolor",
		theme_advanced_buttons3: "tablecontrols,fullscreen", 
		extended_valid_elements: "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]", 
		relative_urls: false, 
		debug: false
	});
}

function populateCCaddress(){


	document.getElementById('seminar_registration_billing_first_name').value = document.getElementById('attendee_first_name').value;	
	document.getElementById('seminar_registration_billing_last_name').value = document.getElementById('attendee_last_name').value;	
	document.getElementById('seminar_registration_billing_address1').value = document.getElementById('attendee_address1').value;	
	document.getElementById('seminar_registration_billing_address2').value = document.getElementById('attendee_address2').value;	
	document.getElementById('seminar_registration_billing_city').value = document.getElementById('attendee_city').value;	
	document.getElementById('seminar_registration_billing_state').value = document.getElementById('attendee_state').value;	
	document.getElementById('seminar_registration_billing_postal_code').value = document.getElementById('attendee_postal_code').value;	
}
function hideCCInfo(){
	var ccdiv = document.getElementById('ccinfo');
	ccdiv.style.display='none';
} 