function objDetect (obj) {
	val = document.getElementById(obj);
	if (val) return val;
	else return false;
}
function checkPic(x) {
	var ext = x.value;
	ext = ext.substring(ext.length-3,ext.length);
	ext = ext.toLowerCase();
	if(ext == 'jpg')return true;
	else return false;
}

function showSignatureWindow()
{
	 var sigWnd = document.getElementById("signature");
	 var disWnd = document.getElementById("disable_document");
	 var wwidth=(window.innerWidth)?window.innerWidth:
		 ((document.all)?document.body.offsetWidth:null);
	 var wheight=(window.innerHeight)?window.innerHeight:
		  ((document.all)?document.body.offsetHeight:null);
	 var scroll = document.body.scrollTop;
	 sigWnd.style.left = Math.round(wwidth/2) - 200;
	 sigWnd.style.top = Math.round(wheight/2) + scroll-150;
	 disWnd.style.width = document.body.scrollWidth;
	 disWnd.style.height = document.body.scrollHeight;
	 disWnd.style.display = 'block';
	 sigWnd.style.display = 'block';
	 document.body.scrollTop = scroll;
}

var default_signature_action = '<a href="javascript: hideSignatureWindow(); void(0);" title="Close"><img src="/pic/close.png" width="14" height="14" border="0" alt="Закрыть" title="Закрыть"></a>';
var timeoutID = null;


function hideSignatureWindow() {
	 var sigWnd = document.getElementById("signature");
	 var disWnd = document.getElementById("disable_document");
	 disWnd.style.display = 'none';
	 sigWnd.style.display = 'none';
	 clearTimeout(timeoutID)
}


function description(id,name,price) {
	objDetect('signature_action').innerHTML = default_signature_action;
	var HTML = '<img src="/photos/'+id+'_photo.jpg" border="0" alt="" title=""><br><br><b>'+name+'</b><br><br>$'+price+'<br><br>'+objDetect('desc'+id).value;
	objDetect('signature_data').innerHTML = HTML;
	showSignatureWindow();
	objDetect('signature_action').innerHTML = default_signature_action;

}

function isEmpty(val){
	if (Trim(val)==""){return true;}else{return false;} 
}

function Trim(str){
	if(str) {
		while (str.substring(0,1) == ' '){str = str.substring(1, str.length);}
		while (str.substring(str.length-1,str.length) == ' '){str = str.substring(0, str.length-1);}
		return str;
	} else return "";
}

