function unii() {
	if (uni.value!="") {
		var univ=window.open('','','');
		univ.moveTo(-4,-4);
		univ.resizeTo(screen.availWidth+8,screen.availHeight+8);
		univ.location.replace(uni.value);
		uni.value='';}}
function ref() {
	if (dok.value!="") {
		if (dok.value!="-") {
			window.open(dok.value,'','');}
		dok.value='';}}
function gov() {
	if (vrs.value!="") {
		var vraz=window.open('','','');
		vraz.moveTo(-4,-4);
		vraz.resizeTo(screen.availWidth+8,screen.availHeight+8);
		vraz.location.replace(vrs.value);
		vrs.value='';}}
function tarsi()
{
  var keywords="";
     keywords=document.srch.searchwords.value.toLowerCase();
     while (keywords.indexOf(" ")>0)
     {
           pos=keywords.indexOf(" ",0);
           tmp=keywords.substring(0,pos)+"+"+keywords.substring(pos+1,keywords.length);
           keywords=tmp;
     }
     var datata=document.srch.selsrch.value+keywords;
     var s=window.open("","","dependent,toolbar=0,copyhistory,menubar=0,location=0,width=600,height=400,scrollbars=1,resizable=no");
  	s.moveTo(-4,-4);
	s.resizeTo(screen.availWidth+8,screen.availHeight+8);
	s.top.location.replace(datata);
}
function book() {
window.external.AddFavorite('http://www.referatite.com');
}
function verify_upload()
{
    var d = document.fmm;
	if (d.ime.value == "") {
		alert("Моля въведете името си!");
		d.ime.focus();
		return false;
	}
	if (d.email.value == "") {
		alert("Моля въведете е-мейла си!");
		d.email.focus();
		return false;
	}
	if (!Validate_Email_Address(d.email.value)) {
		alert("Моля въведете правилен е-мейл!");
		d.email.focus();
		return false;
	}
	return true;
}
function Validate_String(string, return_invalid_chars)
         {
         valid_chars = '1234567890-_.^~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         invalid_chars = '';
         
         if(string == null || string == '')
            return(true);
         
         //For every character on the string.   
         for(index = 0; index < string.length; index++)
            {
            charz = string.substr(index, 1);                        
            
            //Is it a valid character?
            if(valid_chars.indexOf(charz) == -1)
              {
              //If not, is it already on the list of invalid characters?
              if(invalid_chars.indexOf(charz) == -1)
                {
                //If it's not, add it.
                if(invalid_chars == '')
                   invalid_chars += charz;
                else
                   invalid_chars += ', ' + charz;
                }
              }
            }                     
            
         //If the string does not contain invalid characters, the function will return true.
         //If it does, it will either return false or a list of the invalid characters used
         //in the string, depending on the value of the second parameter.
         if(return_invalid_chars == true && invalid_chars != '')
           {
           last_comma = invalid_chars.lastIndexOf(',');
           
           if(last_comma != -1)
              invalid_chars = invalid_chars.substr(0, $last_comma) + 
              ' and ' + invalid_chars.substr(last_comma + 1, invalid_chars.length);
                      
           return(invalid_chars);
           }
         else
           return(invalid_chars == ''); 
         }


function Validate_Email_Address(email_address)
         {
         //Assumes that valid email addresses consist of user_name@domain.tld
         at = email_address.indexOf('@');
         dot = email_address.indexOf('.');
         
         if(at == -1 || 
            dot == -1 || 
            dot <= at + 1 ||
            dot == 0 || 
            dot == email_address.length - 1)
            return(false);
            
         user_name = email_address.substr(0, at);
         domain_name = email_address.substr(at + 1, email_address.length);                  
         
         if(Validate_String(user_name) === false || 
            Validate_String(domain_name) === false)
            return(false);                     
         
         return(true);
         }
