//funkcija nakljucno generira uporabnisko ime
function getUsername(){
	
	var username='';
	username=document.getElementById("username");
	var naziv='';
	naziv=document.getElementById("naziv").value;
	
	if(naziv=='')
	{
		var u=randomString(10);
		username.value=u;
	}
	else
	{
		var temp = new Array();
		temp = naziv.split(' ');

		var i=temp.length;
		if(i==0){//naziv je prazno mesto
			var u=randomString(10);
			username.value=u;
		}
		else{
			if(i>1)//naziv je sestavljen iz vec besed
			{
				var u1=temp[0];
				var u2=temp[1];
				
				if(u1.length>10) //prva beseda je ful dovga
				{
					var u3=u1.toLowerCase();
					username.value=u3.substr(0,12);
				}
				else//zlimam dve besedi skupaj
				{
					var u3=u1+u2;
					if(u3.length>18) //skupni niz je daljsi od 18 znakov
					{
						var u4=u3.toLowerCase();
						username.value=u4.substr(0,18);
					}
					else username.value=u3.toLowerCase();
				}
			}
			else
			{
				//ima samo eno besedo v nazivo 
				var upor=temp[0];
				var uporIme=upor.toLowerCase();
				if(uporIme.length>12)//naziv je daljsi od 12 znakov
					username.value=uporIme.substr(0,12);
				else
					username.value=uporIme;
			}
		}
	}
}
//funkcija nakljucno generira password
function getPassword(){
	
	var pass='';
	pass=document.getElementById("pass1");
	
	pass.value=randomString(5);
}
//generiram nakljucni string
function randomString(string_length) {
	var chars = "0123456789abcdefghiklmnopqrstuvwxyz";
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
//funkcija za preverit ce so vsa polja polna v registraciji
function preveriPodatke()
{
	var naziv='';
	var podrocje='';
	var status='';
	
	naziv = document.getElementById("naziv").value;
	podrocje = document.getElementById("podrocje").value;
	status = document.getElementById("status").value;
	
	if(naziv!='' && status!='' && podrocje!='')
	{
		//var btn = document.getElementById(TagsHelperConfig.FORM_TAGS_ENTRY_SUBMIT_BUTTON_ID );
	    // Programmatically click the submit button
	    //btn.click();
		document.reg.submit();  //dela samo kadar je a href=....
	}
	else 
	{
		var label = document.getElementById("label");
		label.innerHTML='<font size="4px" color="red">Izpolnite vsa obvezna polja</font>';
	}	
}
//preveri podateke v podjetju in področju - obe formi imata name=pod ter naziv ima name=naziv
function preveriPodatkePod()
{
	var naziv='';
	naziv = document.getElementById("naziv").value;
	if(naziv!='')
	{
		document.pod.submit();  //dela samo kadar je a href=....
	}
	else 
	{
		var label = document.getElementById("label");
		label.innerHTML='<font size="4px" color="red">Izpolnite vsa obvezna polja</font><br /><br />';
	}	
}
//funkcija za pošiljanje post za spremembe
function spremembe(){
	var naslov1='';
	var naslov2='';
	var naslov3='';
	var body1='';
	var body2='';
	var body3='';
	var label='';
	
	naslov1 = document.getElementById("n1").value;
	body1=document.getElementById("tekst1").value;
	naslov2 = document.getElementById("n2").value;
	body2=document.getElementById("tekst2").value;
	naslov3 = document.getElementById("n3").value;
	body3=document.getElementById("tekst3").value;
	
	var znacka=0;
	var label = document.getElementById("label1");
	label.innerHTML='';
	label = document.getElementById("label2");
	label.innerHTML='';
	label = document.getElementById("label3");
	label.innerHTML='';
	label = document.getElementById("label4");
	label.innerHTML='';
	label = document.getElementById("label5");
	label.innerHTML='';
	label = document.getElementById("label6");
	label.innerHTML='';
	label = document.getElementById("label7");
	label.innerHTML='';
		
	
		
	if(naslov1 == ''){
		var label = document.getElementById("label1");
		label.innerHTML='<font size="2px" color="red"><b>- prvi naslov je prazen </b></font>';
		znacka=1;
	}
	if(naslov2 == ''){
		var label = document.getElementById("label3");
		label.innerHTML='<font size="2px" color="red"><b>- drugi naslov je prazen </b></font>';
	}
	if(naslov3 == ''){
		var label = document.getElementById("label5");
		label.innerHTML='<font size="2px" color="red"><b>- tretji naslov je prazen </b></font>';
		znacka=1;
	}
	if(body1 == ''){
		var label = document.getElementById("label2");
		label.innerHTML='<font size="2px" color="red"><b>- prvi tekstbox je prazen </b></font>';
		znacka=1;
	}
	if(body2 == ''){
		var label = document.getElementById("label4");
		label.innerHTML='<font size="2px" color="red"><b>- drugi textbox je prazen </b></font>';
		znacka=1;
	}
	if(body3 == ''){
		var label = document.getElementById("label6");
		label.innerHTML='<font size="2px" color="red"><b>- tretji textbox je prazen </b></font>';
		znacka=1;
	}
	if(znacka==1){
		var label = document.getElementById("label7");
		label.innerHTML='<font size="2px" color="red"><b><br />Preglejte opozorila in ce ste prepricani o spremembah kliknite gumb "UREDI PODATKE". </b><br /><br /><input type="submit" value="UREDI PODATKE" /><p></font>';
		znacka=1;
	}
	else
	{
		document.sprememba.submit();
	}
}
//popup funkcija
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=800,height=1050,scrollbars=yes');
return false;
}
//funkcije za meni - mous over out
//************************************************************************************************
function mouseOverHome()
{
document.getElementById("home").src="images/small/home2.gif";
}
function mouseOverMail()
{
document.getElementById("mail").src="images/small/mail2.gif";
}
function mouseOutHome()
{
document.getElementById("home").src="images/small/home1.gif";
}
function mouseOutMail()
{
document.getElementById("mail").src="images/small/mail1.gif";
}
function mouseOverTdMeni()
{
var element = document.getElementById("tdM").style.verticalAlign="bottom";
}
function mouseOutTdMeni()
{
document.getElementById("tdM").style.verticalAlign="top";
}
function mouseOverTdMeni1()
{
document.getElementById("tdM1").style.verticalAlign="bottom";
}
function mouseOutTdMeni1()
{
document.getElementById("tdM1").style.verticalAlign="top";
}
function mouseOverTdMeni2()
{
document.getElementById("tdM2").style.verticalAlign="bottom";
}
function mouseOutTdMeni2()
{
document.getElementById("tdM2").style.verticalAlign="top";
}
function mouseOverTdMeni3()
{
document.getElementById("tdM3").style.verticalAlign="bottom";
}
function mouseOutTdMeni3()
{
document.getElementById("tdM3").style.verticalAlign="top";
}
function mouseOverLaptop()
{
document.getElementById("imgLaptop").src="./images/laptop3.gif";
}
function mouseOutLaptop()
{
document.getElementById("imgLaptop").src="./images/centerGlava4.gif";
}
//************************************************************************************************