conf = function (str){ return confirm('Realmente desea :\n'+str);}
// Funciones comunes
c= function (tag) { // Crea un elemento
   return document.createElement(tag);
}
d = function (id) { // Retorna un elemento en base al id
   return document.getElementById(id);
}
e = function (evt) { // Retorna el evento
   return (!evt) ? event : evt;
}
f = function (evt) { // Retorna el objeto que genera el evento
   return evt.srcElement ?  evt.srcElement : evt.target;
}
var numero =0;
addField = function (id,id2) {
   container = d(id);
   span = c('span');
   span.className = 'urls';
   span.id = 'url' + (++numero);
   span.innerHTML=id2+'-Url <br/>';
   field = c('input');
   field.name = id2+'_url[]';
   field.type = 'text';
   field.className = 'input_url';

   var selector = c('select');
   selector.name = id2+'_titulo[]';
   selector.className = 'select_url';

   var option = c('option');
   option.value = '0';
   option.appendChild(document.createTextNode('Titulo descarga'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'Descargar';
   option.appendChild(document.createTextNode('Descargar'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD01';
   option.appendChild(document.createTextNode('CD01'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD02';
   option.appendChild(document.createTextNode('CD02'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD03';
   option.appendChild(document.createTextNode('CD03'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD04';
   option.appendChild(document.createTextNode('CD04'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD05';
   option.appendChild(document.createTextNode('CD05'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD06';
   option.appendChild(document.createTextNode('CD06'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD07';
   option.appendChild(document.createTextNode('CD07'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD08';
   option.appendChild(document.createTextNode('CD08'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD09';
   option.appendChild(document.createTextNode('CD09'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'CD10';
   option.appendChild(document.createTextNode('CD10'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'Sample';
   option.appendChild(document.createTextNode('Sample'));
   selector.appendChild(option);
   option = c('option');
   option.value = 'Subtitulos';
   option.appendChild(document.createTextNode('Subtitulos'));
   selector.appendChild(option);

   a = c('A');
   a.name = span.id;
   a.className = 'enlaces';
   a.href = '#'+span.id;
   a.onclick = removeField;
   a.innerHTML = ' Quitar<br/>';

   span.appendChild(field);
   span.appendChild(selector);
   span.appendChild(a);
   container.appendChild(span);
}

removeField = function (evt) {
   lnk = f(e(evt));
   span = d(lnk.name);
   span.parentNode.removeChild(span);
   --numero;
}

hide = function (id){
		d(id).innerHTML="";
}
hide_show = function (id){
		if (id=="1")
			d("cap1").style.display='block';
		else d("cap1").style.display='none';
}
show_hide = function (idItem){
	if (document.getElementById(idItem))
	{
    id=document.getElementById(idItem);
	if (id.style.display=='none')
		id.style.display='block';
	else id.style.display='none';
	}
}
//Basic Ajax Routine- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: Jan 15th, 06'

function createAjaxObj(){
var httprequest=false
if (window.XMLHttpRequest){ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject){ // if IE
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return httprequest
}

var ajaxpack=new Object()
ajaxpack.basedomain="http://"+window.location.hostname
ajaxpack.ajaxobj=createAjaxObj()
ajaxpack.filetype="txt"
ajaxpack.addrandomnumber=1 //Set to 1 or 0. See documentation.

ajaxpack.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
if (ajaxpack.addrandomnumber==1) //Further defeat caching problem in IE?
var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
if (this.ajaxobj){
this.filetype=filetype;
this.ajaxobj.onreadystatechange=callbackfunc ;
this.ajaxobj.open('GET', url+"?"+parameters, true);
this.ajaxobj.send(null);
}
}

ajaxpack.postAjaxRequest=function(url, parameters, callbackfunc, filetype,returnPath){
ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
if (this.ajaxobj){
this.filetype=filetype;
this.returnPath=returnPath;
this.ajaxobj.onreadystatechange = callbackfunc;
this.ajaxobj.open('POST', url, true);
this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
this.ajaxobj.setRequestHeader("Content-length", parameters.length);
this.ajaxobj.setRequestHeader("Connection", "close");
this.ajaxobj.send(parameters);
}
}
function processGetPost(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
var returnPath=ajaxpack.returnPath
if (myajax.readyState == 4){ //if request of file completed
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
if (myfiletype=="txt")
d(returnPath).innerHTML=myajax.responseText;
else
alert(myajax.responseXML)
}
}
}
callAjax = function (item,op,cap,path){
	var params="item=" + encodeURI(item)+"&op=" + encodeURI(op);
	ajaxpack.postAjaxRequest(path, params, processGetPost, "txt",cap);
}