function getValue(elementId)
{
	//alert(document.getElementById(elementId).value); 	
	if (document.getElementById(elementId) != undefined)
	{
		return  document.getElementById(elementId).value;
	}else
	{
		return false;
	}
}

function setValue(elementId,value)
{
	//alert(document.getElementById(elementId).value); 	
	if (document.getElementById(elementId) != undefined)
	{
		document.getElementById(elementId).value=value;
	}else
	{
		return false;
	}
}

function ge(elementId)
{
	//alert(document.getElementById(elementId).value); 	
	if (document.getElementById(elementId) != undefined)
	{
		return  document.getElementById(elementId);
	}else
	{
		return false;
	}
}

function shb(what) 
{	 
   if(document.getElementById(what).style.display=="none" || document.getElementById(what).style.display=="") 
   {
     document.getElementById(what).style.display="block";
    
   } else {
     document.getElementById(what).style.display="none";
   }   
}

function hide_el(what) 
{	
	if(document.getElementById(what)!= undefined && document.getElementById(what)!= '')
	{
	 //document.getElementById(what).style.top="0px";    
		 try 
		 {
		   document.getElementById(what).style.display="none";
		 }	 
		 catch(ex) 
		 {
		 	
		 }//catch    
     
	}   
}

function show_el(what) 
{
	//alert(document.getElementById(what));
 if(document.getElementById(what)!= undefined && document.getElementById(what)!= '')
 {	 
     document.getElementById(what).style.display="block"; 
     try 
	 {
	    //document.getElementById(what).style.top="-10px"; // standards compliant; doesn't work in IE   
	   // document.getElementById(what).style.margin="0px"; // standards compliant; doesn't work in IE  
	   // document.getElementById(what).style.bottom="0px"; // standards compliant; doesn't work in IE   
	    //document.getElementById(what).scrollTop =  document.getElementById(what).scrollHeight;
	    //alert(document.getElementById(what).scrollHeight); 
	 }	 
	 catch(ex) 
	 {
	 	//alert(ex);  
	    //document.getElementById(what).style.top="0px";  
	 }//catch
     	
 }//if	  
}//function

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

function isValidEmail(email) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-z]{2,4})+$/;  
    
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    
    if (!filter.test(email)) 
    {
		return false;
	}else
	{
		return true;
	}
  
}//function


function submit_form(fId)
{
	document.getElementById(fId).submit(); 
}


function byteConv(bytes)
{
	if((bytes / (1024*1024*1024))<1)
	{
		if((bytes / (1024*1024))<1)
		{
			
			if((bytes / 1024)<1)
			{
				return bytes + ' bytes';
				
			}else return round((bytes / 1024),2) + 'Kb';
			
			
		}else return round(bytes / (1024*1024),2) + 'Mb';
		
	} else return round(bytes / (1024*1024*1024),2) + 'Gb';
	
}

function round ( val, precision ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +    revised by: Onno Marsman
    // *     example 1: round(1241757, -3);
    // *     returns 1: 1242000
    // *     example 2: round(3.6);
    // *     returns 2: 4
 
    return parseFloat(parseFloat(val).toFixed(precision));
}


function switchmap(map)
{	
	document.getElementById('themap').src='http://cem.bg/img/map/map'+map+'.png'; 		
}
