var global_i = 1;

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function hideLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'none':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'none';
}

function showLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'block';
  vis.display = (vis.display==''||vis.display=='block')?'block':'block';
}

function showLayers( value )
{
	
	switch(value)
	{
	case 'check':
		hideLayer('step2-accomodation');
		hideLayer('step2-dropdown');
		showLayer('step2');
		hideLayer('step2-comment');
		hideLayer('addoption');
	  break;    
	case 'choice':
		showLayer('step2-dropdown');
		hideLayer('step2');
		hideLayer('step2-accomodation');
		hideLayer('step2-comment');
		showLayer('addoption');
	  break;
	case 'accomodation':	
		showLayer('step2-accomodation');
		hideLayer('step2-dropdown');
		hideLayer('step2');
		hideLayer('step2-comment');
		hideLayer('addoption');
	  break
	case 'info':	
		hideLayer('step2-accomodation');
		hideLayer('step2-dropdown');
		hideLayer('step2');
		showLayer('step2-comment');
		hideLayer('addoption');
	  break
	case 'text':	
		hideLayer('step2-accomodation');
		hideLayer('step2-dropdown');
		showLayer('step2');
		hideLayer('step2-comment');
		hideLayer('addoption');
	  break
	default:

	}
}

function checkBoxes( elmname1, elmname2, layerToShow ){
	
	var elem1, elem2;
    elem1 = document.getElementById( elmname1 );
    elem2 = document.getElementById( elmname2 );
	if(elem1.value != '' && elem2.value != '') {
		 showLayer( layerToShow );
		}

}

function populateText (){
	
	 var dropdownIndex = document.getElementById('tag_dropdown').selectedIndex;
	 var dropdownValue = document.getElementById('tag_dropdown')[dropdownIndex].value;
	 var frm = document.getElementById("newEvent");
	 frm.tags.value = frm.tags.value  + dropdownValue + ',';
}



function addtb( )
{
	
	 
  var elem = "rows";
  var elemcount = document.getElementById('selectcount');
  
  elem += global_i;
  global_i = global_i + 1;
  var div=document.getElementById(elem);
  
  div.innerHTML+="<tr><td>Option</td><td><input name='optiondropdown' id='optiondropdown type='textbox'></input></td></tr><div id='rows'></tr></div>";
  div.innerHTML+="<tr><td>Option" + global_i + "</td><td><input name='optiondropdown" + global_i + "' id='optiondropdown" + global_i + "' type='textbox'></input></td></tr><div id='rows" + global_i + "'></tr></div>";
  
  elemcount.value = global_i;
  
  
 }

function work(){

	  var elem = "rows";
	  var elemcount = document.getElementById('selectcount');
	  
	  elem += global_i;

	  global_i = global_i + 1;
	  var div=document.getElementById(elem);
	
	  
	  div.innerHTML+="<tr><td>Option" + global_i + "</td><td><input name='optiondropdown" + global_i + "' id='optiondropdown" + global_i + "' type='textbox'></input></td></tr><div id='rows" + global_i + "'></tr></div>";
	  
	  
	  elemcount.value = global_i;
	  


}
