//---------
function showobject(object) {
         var obj = document.getElementById(object) ;
         obj.style.display = "block";
};

//---------
function hideobject(object) {
         var obj = document.getElementById(object) ;
         obj.style.display = "none";
};
//--------------------------------------------

function checkPohotos(filen) {

  	var allok = '1';
	var allowedExt1 = '.jpg';
	var allowedExt2 = '.jpeg';
	var allowedExt3 = '.JPG';
	var allowedExt4 = '.JPEG';

        var obj = document.getElementById(filen);
        var objdiv = document.getElementById(filen+'div');
        var formname = document.getElementById(filen+'upload');

		var ext = getfileextension(filen);

		if( ext != allowedExt1 && ext != allowedExt2 && ext != allowedExt3 && ext != allowedExt4 && ext != "empty") {
			objdiv.innerHTML = 'Изберете валиден файл от типа .jpg или .jpeg';
			var allok = '0';
		}else if( ext == "empty") {
			objdiv.innerHTML = 'Изберете файл';
			var allok = '0';
		}else{
			objdiv.innerHTML = '&nbsp;';
		}

	if(allok == '1'){formname.submit();}
}

//--------------------------------------------

function getfileextension(filen) {
	var fileinput = document.getElementById(filen);
	var filename = fileinput.value;
	if( filename.length == 0 ) return "empty";
	var dot = filename.lastIndexOf(".");
	if( dot == -1 ) return "";
	var extension = filename.substr(dot,filename.length).toLowerCase();
	return extension;
}

//--------------------------------------------
