
window.onkeypress = function(ev) {
		ev || (ev = window.event);
		if(ev.keyCode ==13){

			if(document.forms){
				for( var i = document.forms.length; i > 0  ; i--){
					if(document.forms[i]['search_by']){
						document.forms[i].submit();
					}
				}
			}
		}
};

    function goto_here_with_args (element_for_concate) {
            //alert('correcto: ' + window.location.protocol+window.location.hostname+window.location.pathname+'?'+element_for_concate );

            window.location = window.location.protocol+'//'+window.location.hostname+window.location.pathname+'?' + element_for_concate;
    }
    

    function goto_url (element_for_concate) {
            window.location = window.location.protocol+'//'+
             window.location.hostname +':'+ window.location.port+
             '/' + window.location.pathname.split('/')[1] +'\/'+
              window.location.pathname.split('/')[2] +'\/'+
              element_for_concate;
    }
    function goto_here_preserving_args (element_for_concate) {

            window.location =window.location.href +'&' + element_for_concate;
    }
    function reindex_selected (selObj, element_id){
        for(var ii = 0; ii < selObj.options.length; ii++){
            if(selObj.options[ii].value == element_id) {
                selObj.options[ii].selected= true;
            }
        }
    }

    function reindex_radio (selObj, element_id){

        for(var ii = 0; ii < selObj.length; ii++){
            if(selObj[ii].value == element_id) {
                selObj[ii].checked= true;
            }
        }

    }

    function convert_checkbox_bool_behavior (the_form ) {

            //alert (the_form.value + ' - ' + the_form.name + ' --> '+ the_form.length);
            for(var ia = 0; ia < the_form.length; ia++){
				if(the_form[ia].name == 'delete_tmp'){

				}else if(the_form[ia].name == 'delete_this_image'){
					
				}else{
                	if(the_form[ia].type == 'checkbox'){
               // alert('existe 1');
                    	if(the_form[ia].checked== false){
                 //       alert('existe 2' );
                        	the_form[ia].checked= true;
                        	the_form[ia].value = the_form[ia].value + '_';
                    	}
                	}
				}
            }
    }

function change_color_of (elem, color_entrada) {
    elem.style.backgroundColor=color_entrada;

}

function wish_delete(formy, texto){
	if(confirm(texto) ){
		return true;
	}
	return false;
}
function confirm_delete (texto, formy, hidden_name, value_to_send){
	if(confirm(texto) ){
		formy[hidden_name].value = value_to_send;
	}else{
		formy['delete_tmp'].checked = false;
	}
}


function Popup(url,name,width,height,resize,scroll) {
var dialogWin = new Object();
dialogWin.width = width;
dialogWin.height = height;
now = new Date();
var millis=now.getTime();
var mstr=""+millis;
if (navigator.appName == "Netscape") {
dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
var attr = 'screenX=' + dialogWin.left + ',screenY=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
} else if (document.all) {
dialogWin.left = (screen.width - dialogWin.width) / 2;
dialogWin.top = (screen.height - dialogWin.height) / 2;
var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
}
window.open(url,name,attr);
}

PositionX = 10;
PositionY = 10;
defaultWidth  = 800;
defaultHeight = 600;

//kinda important
var AutoClose = true;

//don't touch
function popImage(imageURL,imageTitle){
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
		(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
		'<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
		(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}



function toggleLayer(whichLayer){
    if (document.getElementById){
// this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"block";
	} else if (document.all){
// this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"block";
    } else if (document.layers){
    // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
}



var file_counter = 1;
function add_uploaders (){
	var host_tag = document.getElementById('bla');
 	var to_replace = document.createElement('div');
//  	var cloned = to_replace.createElement(true);
	to_replace.innerHTML = '<br> <input type="file" name="archivo_'+file_counter+'" value="archivelly">';
	host_tag.appendChild(to_replace);
	
// 	host_tag.innerHTML += '<br> <input type="file" name="archivo_'+file_counter+'" value="archivelly">';
	++file_counter;
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open('http://www.classicandmodern.com/'+theURL,winName,features);
}
  
