// JavaScript Document
function switchT(show, hide){
	document.getElementById(hide).className = "divHide";
	document.getElementById(show).className = "divShow";
}
function switchDiv(show, top, step) {
  
  for (i=1; i<10 ; i++){
  	if (document.getElementById && document.getElementById('d'+i)) {
		 document.getElementById('d'+i).className = "divHide";
		 if(step)
		 document.getElementById('td'+i).className = "lmenu_item4";
  	}
  }
	
  if (document.getElementById && document.getElementById('d'+show)) {
    document.getElementById('d'+show).className = "divShow";
	if(step)
	document.getElementById('td'+show).className = "activeStep";
  }
}


function setAction(act){
	obj = document.getElementById('action');
	obj.value = act;
}


function viewCV(url, action){
	
	if(!action)
	action = 'view';
	
	action = '&action='+action;
	
	win=window.open(url+action,'myWin','menubar=no,scrollbars=yes,width=700, height=750,left=150,status=no');
	win.focus();
}

function cForm(form, myWin, action){
 if(myWin){
 	win=window.open('','myWin','toolbars=0,scrollbars=1,width=750, height=750,status=0'); 
 	form.target='myWin';
	form.action.value=action;
 }else{
 	form.target='_self';
	form.action.value=action;
 }
}

function switchTable(show, count, prefix) {
  
 	 for (i=1; i<=count ; i++){
  		if (document.getElementById && document.getElementById(prefix+'tb'+i)) {
		 	if(i < show){
				if(document.getElementById(prefix+'tc'+i))
					document.getElementById(prefix+'tc'+i).className = "tbHide";
			 }else if(i > show){
		 	document.getElementById(prefix+'tb'+i).className = "tbHide";
			 }		 
  		}
 	 }
}

function tbControl(num,prefix,control){
	if(control){
		if(document.getElementById(prefix+'tc'+num))
			document.getElementById(prefix+'tc'+num).className = "tbHide";
		document.getElementById(prefix+'tb'+(num+1)).className = "tbShow";
		if(document.getElementById(prefix+'tc'+(num+1)))
			document.getElementById(prefix+'tc'+(num+1)).className = "tbShow";
	}else{
		document.getElementById(prefix+'tb'+num).className = "tbHide";
		if(document.getElementById(prefix+'tc'+num))
			document.getElementById(prefix+'tc'+num).className = "tbHide";
		if(document.getElementById(prefix+'tc'+(num-1))){
			//alert(num-1);
			document.getElementById(prefix+'tc'+(num-1)).className = "tbShow";
		}
		if(document.getElementById(prefix+'Field'+num))
			document.getElementById(prefix+'Field'+num).value = "";
	}
}

function autoSelect(name, val){
	obj = document.getElementById(name);
	if(!val){
		obj.options[0].selected = true;
	}else{
		for (var i = 0; i < obj.length; i++) {
    		if (obj.options[i].value == val) {
       	 		obj.options[i].selected = true;
    		}
		}
	}
}

function text2pass(pass, passcontainer){
	if(document.getElementById(pass).value == 'Slaptažodis'){
		var passbox = document.getElementById(pass);
		document.getElementById(passcontainer).innerHTML="<input id=\""+pass+"\" name=\"data[password]\" type=\"password\" style=\"width:170px;\" maxlength=\"40\"/>" ;
		document.getElementById(pass).focus();
		document.getElementById(pass).focus();
	
		document.getElementById(pass).onblur = function(){
		if(!document.getElementById(pass).value)
			document.getElementById(passcontainer).innerHTML="<input id='"+pass+"' type='text' style='width:170px;' value='Slaptažodis' onFocus=\"text2pass('"+pass+"','"+passcontainer+"')\">" ;
		
	}
	}
}
