
function key(e) { 
  	e = (window.Event) ? e : event; 
if(e.keyCode==13) Search($('#q').val());
}

function readForm(form) {
    var data = '';
    $('input, textarea, select',form).each(function() {
         if(this.name!='') 
           if(this.type=='select-multiple') { 
             for(x=0;x<this.options.length;x++) {
                if(this.options[x].selected==true) data += '&'+this.name+'[]='+ encodeURIComponent(this.options[x].value);
             }
           } else if(this.type!='checkbox' && this.type!='radio') {
            value = this.value ? encodeURIComponent(this.value) : '';
            data +='&'+this.name+'='+value;
           } else if(this.checked==true) 
            data +='&'+this.name+'='+encodeURIComponent(this.value);  
    });

    return data;    
}


function sendInquiry(form) {

    f = $(form);
    var data = readForm(f);

    success = function(answ) {
            try {
                answ = eval("("+answ+")");
            } catch(ex) { answ = [answ]; }
            
            if(answ[0] == 1) {
                // f.html(answ[1]);
                alert(answ[1]);
            } else {
                alert(answ[0]);
            } 
        }
    
    $.post(f.attr('action'),data,success);
    
    return false;
}


 function uploadFormChanges(el) {
     el = $(el);
     var file = el.val();
     var fileName = el.prev();
      
     reWin = /.*\\(.*)/;
     var fileTitle = file.replace(reWin, "$1"); 
     reUnix = /.*\/(.*)/;
     fileTitle = fileTitle.replace(reUnix, "$1");
 
     fileName.html(fileTitle);
     el.parent().attr('title',fileTitle);
     
     var RegExExt =/.*\.(.*)/;
     var ext = fileTitle.replace(RegExExt, "$1").toLowerCase();
      
 }

 
 function Search(q) {
	    var data = 'q='+q;

	    success = function(answ) {

	         if(answ==1) {
	               window.location.href=URL+'/Search';
	          } else alert(answ);
	      }
	
	  $.post(URL+'/Search',data,success);
	}
 
 function ZoomPhoto(id) {
	
	      success = function(answ) {
	    		a = answ.split('::');
	    		if(a[0]==0) alert(a[1]); 
	    		else {
	    		 //$('responseContent').style.top = document.documentElement.scrollTop+50+'px';
	    		 showReturn(answ);
	    		}
	      }
	   	
		$.post(URL+'/Gallery/Zoom','id='+id,success);
		
	}
 function showReturn(msg) {
		
         $('#responseContent').html(msg);
		 $('#BlockScreen').show();
		 $('#BlockScreen').css('height',document.documentElement.scrollHeight+'px');
		 $('#responseContent').show(); 
		
}

function UnblockScreen() {
		
	$('#BlockScreen').hide(); 
	$('#responseContent').hide();
	$('#responseContentScroll').hide();

}
