/*jquery functions*/
		function centrarDiv(div) {
			/*div = 'ImageBrowser';	*/

			/*define element to work with*/
				element = $('#'+div+'');

			/*Obtein element height and width*/
				width = element.width();
				height = element.height();

			/*Calculate element position*/
				var top = (($(this).height()-height)/2) + $(this).scrollTop();
				var left = ($(this).width()-width)/2;

			/*Calculate element position*/				
				element.css('position' , 'absolute');
				element.css('left' , left);
				element.css('top' , top);
		}
/***/

function do_pick_file( pElement, pType,  pButtonElement) {

	/*funcion que centra en la pagina el elemento con el id especificado teniendo en cuenta si se hizo scroll*/
		centrarDiv('ImageBrowser');

	var args = null;
	var filters = null;
	
	filters =   "&filters=" + pType ;
	if (pElement.value != "") {
		args = new Array();
		args['img_url'] = pElement.value;
	}

	iframe 		= document.getElementById('ifImageBrowser');
	diviframe 	= document.getElementById('ImageBrowser');


	diviframe.style['display'] 	= 'block';

	for (n=0; n < pButtonElement.parentNode.childNodes.length; n++)	
	{
		if (pButtonElement.parentNode.childNodes[n].nodeType == 1 && pButtonElement.parentNode.childNodes[n].nodeName =="INPUT" )
			var pId = pButtonElement.parentNode.childNodes[n].id;
	}

	iframe.src = "common/imgbrowser/browse.php?workingOnEditor=0&fld=" + pId  + filters;
}

function do_pick_file_multiple( pElement, pType,  pButtonElement, posic) {
	/*funcion que centra en la pagina el elemento con el id especificado teniendo en cuenta si se hizo scroll*/
		centrarDiv('ImageBrowser');
		
	var args = null;
	var filters = null;
	var n = 0;
	
	filters =   "&filters=" + pType ;
	if (pElement.value != "") {
		args = new Array();
		args['img_url'] = pElement.value;
	}

	iframe 		= document.getElementById('ifImageBrowser');
	diviframe 	= document.getElementById('ImageBrowser');

	diviframe.style['display'] 	= 'block';

	var input_position =0;

	for (n=0; n < pButtonElement.parentNode.childNodes.length; n++)	
	{
		if (pButtonElement.parentNode.childNodes[n].nodeType == 1 && pButtonElement.parentNode.childNodes[n].nodeName =="INPUT"){
			input_position ++;
			if( input_position  == posic){
				var pId = pButtonElement.parentNode.childNodes[n].id;
				break;
			}
		}

	}

	iframe.src = "common/imgbrowser/browse.php?workingOnEditor=0&fld=" + pId  + filters;
}



function set_file(field, value) {
	iframe 		= document.getElementById('ifImageBrowser');
	document.forms[0].field.value = value;
}

function do_chgOrder( pos, id ) {
	document.forms[0].chg_orders_values.value = id  + ", " +  eval ("document.forms[0].chgOrder[" + pos + "].value") ;
	document.forms[0].submit();
}

