var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function onlyDigits(e,decReq) {
	var key = (isIE) ? window.event.keycodigo : e.which;
	var obj = (isIE) ? event.srcElement : e.target;
	var isNum = (key > 47 && key < 58) ? true:false;
	var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
	window.event.keycodigo = (!isNum && !dotOK && isIE) ? 0:key;
	e.which = (!isNum && !dotOK && isNS) ? 0:key;
	return (isNum || dotOK);
}
function EnableTarifa() {
    if(document.master.c1_composicion_tarifa_id.value=="F" || document.master.c1_composicion_tarifa_id.value=="P"){
	document.getElementById('d82_tarifa').readOnly=false;    
    }else{
	document.getElementById('d82_tarifa').readOnly=true;        
    }
}
function ClaseNoAplica() {
    if(document.master.c1_tipo_tarifa_id.value=="N"){
	document.master.c2_codigo_id.value = "NA";
	document.master.v64_codigo.value = "NO APLICA";
    }
}
var OpenWindow;
function ConstructTarifaID(tributo,tipo,frecuencia,composicion,clase){
    if(tributo == ""){alert("Seleccione el Tributo antes");return;}
    if(clase == ""){alert("Seleccione la Clase antes");return;}
    if (!OpenWindow || OpenWindow.closed){
	OpenWindow =window.open('','Rod','top=200,left=350,width=200,height=40,scrollbars=no,resizable=no,toolbar=no,menubar=no');
	OpenWindow.document.open();
	OpenWindow.document.write("<html>");
	OpenWindow.document.write("<head><title>Tarifa ID</title>");
	OpenWindow.document.write("</head>");
	OpenWindow.document.write("<body>");
	OpenWindow.document.write("<form name=IDContructor>");
	OpenWindow.document.write("<DIV ID=span0  style=position:absolute;left:10px;top:50px;visibility:visible><input type=text class=my_style name=tarifa size=16 value="+tributo+tipo+clase+frecuencia+composicion+" readonly></DIV>");
	OpenWindow.document.write("<DIV ID=span1  style=position:absolute;left:135px;top:51px;visibility:visible><SELECT class=inputext size=1 cols=4 NAME=sel><OPTION value=001>001</OPTION><OPTION value=002>002</OPTION><OPTION value=003>003</OPTION><OPTION value=004>004</OPTION><OPTION value=005>005</OPTION><OPTION value=006>006</OPTION><OPTION value=007>007</OPTION><OPTION value=008>008</OPTION><OPTION value=009>009</OPTION><OPTION value=010>010</OPTION><OPTION value=011>011</OPTION><OPTION value=012>012</OPTION><OPTION value=013>013</OPTION><OPTION value=014>014</OPTION><OPTION value=015>015</OPTION><OPTION value=016>016</OPTION><OPTION value=017>017</OPTION><OPTION value=018>018</OPTION><OPTION value=019>019</OPTION><OPTION value=020>020</OPTION><OPTION value=021>021</OPTION><OPTION value=022>022</OPTION><OPTION value=023>023</OPTION><OPTION value=024>024</OPTION><OPTION value=025>025</OPTION><OPTION value=026>026</OPTION><OPTION value=027>027</OPTION><OPTION value=028>028</OPTION><OPTION value=029>029</OPTION><OPTION value=030>030</OPTION><OPTION value=031>031</OPTION><OPTION value=032>032</OPTION><OPTION value=033>033</OPTION><OPTION value=034>034</OPTION><OPTION value=035>035</OPTION><OPTION value=036>036</OPTION><OPTION value=037>037</OPTION><OPTION value=038>038</OPTION><OPTION value=039>039</OPTION><OPTION value=040>040</OPTION><OPTION value=041>041</OPTION><OPTION value=042>042</OPTION><OPTION value=043>043</OPTION><OPTION value=044>044</OPTION><OPTION value=045>045</OPTION><OPTION value=046>046</OPTION><OPTION value=047>047</OPTION><OPTION value=048>048</OPTION><OPTION value=049>049</OPTION><OPTION value=050>050</OPTION><OPTION value=051>051</OPTION><OPTION value=052>052</OPTION><OPTION value=053>053</OPTION><OPTION value=054>054</OPTION><OPTION value=055>055</OPTION><OPTION value=056>056</OPTION><OPTION value=057>057</OPTION><OPTION value=058>058</OPTION><OPTION value=059>059</OPTION><OPTION value=060>060</OPTION><OPTION value=061>061</OPTION><OPTION value=062>062</OPTION><OPTION value=063>063</OPTION><OPTION value=064>064</OPTION><OPTION value=065>065</OPTION><OPTION value=066>066</OPTION><OPTION value=067>067</OPTION><OPTION value=068>068</OPTION>OPTION value=069>069</OPTION><OPTION value=070>070</OPTION><OPTION value=071>071</OPTION><OPTION value=072>072</OPTION><OPTION value=073>073</OPTION><OPTION value=074>074</OPTION><OPTION value=075>075</OPTION><OPTION value=076>076</OPTION><OPTION value=077>077</OPTION><OPTION value=078>078</OPTION><OPTION value=079>079</OPTION><OPTION value=080>080</OPTION><OPTION value=081>081</OPTION><OPTION value=082>082</OPTION><OPTION value=083>083</OPTION><OPTION value=084>084</OPTION><OPTION value=085>085</OPTION><OPTION value=086>086</OPTION><OPTION value=087>087</OPTION><OPTION value=088>088</OPTION><OPTION value=089>089</OPTION><OPTION value=090>090</OPTION><OPTION value=091>091</OPTION><OPTION value=092>092</OPTION><OPTION value=093>093</OPTION><OPTION value=094>094</OPTION><OPTION value=095>095</OPTION><OPTION value=096>096</OPTION><OPTION value=097>097</OPTION><OPTION value=098>098</OPTION><OPTION value=099>099</OPTION><OPTION value=100>100</OPTION><OPTION value=101>101</OPTION><OPTION value=102>102</OPTION><OPTION value=103>103</OPTION><OPTION value=104>104</OPTION><OPTION value=105>105</OPTION><OPTION value=106>106</OPTION><OPTION value=107>107</OPTION><OPTION value=108>108</OPTION><OPTION value=109>109</OPTION><OPTION value=210>210</OPTION><OPTION value=211>211</OPTION><OPTION value=212>212</OPTION><OPTION value=213>213</OPTION><OPTION value=214>214</OPTION><OPTION value=215>215</OPTION><OPTION value=216>216</OPTION><OPTION value=217>217</OPTION><OPTION value=218>218</OPTION><OPTION value=219>219</OPTION><OPTION value=220>220</OPTION><OPTION value=221>221</OPTION><OPTION value=222>222</OPTION><OPTION value=223>223</OPTION><OPTION value=224>224</OPTION><OPTION value=225>225</OPTION><OPTION value=226>226</OPTION><OPTION value=227>227</OPTION><OPTION value=228>228</OPTION><OPTION value=229>229</OPTION><OPTION value=230>230</OPTION><OPTION value=231>231</OPTION><OPTION value=232>232</OPTION><OPTION value=233>233</OPTION><OPTION value=234>234</OPTION><OPTION value=235>235</OPTION><OPTION value=236>236</OPTION><OPTION value=237>237</OPTION><OPTION value=238>238</OPTION><OPTION value=239>239</OPTION><OPTION value=240>240</OPTION><OPTION value=241>241</OPTION><OPTION value=242>242</OPTION><OPTION value=243>243</OPTION><OPTION value=244>244</OPTION><OPTION value=245>245</OPTION><OPTION value=246>246</OPTION><OPTION value=247>247</OPTION><OPTION value=248>248</OPTION><OPTION value=249>249</OPTION><OPTION value=250>250</OPTION></select></DIV>");
	OpenWindow.document.write("<DIV ID=span11 style=position:absolute;left:10px;top:10px;visibility:visible><input type=button name=aceptar value=Aceptar class=button onClick=opener.Cod()></DIV>");
	OpenWindow.document.write("</form></body></html>");
    }else{OpenWindow.focus();}
}
function Cod(){
    tip=OpenWindow.document.IDContructor.tarifa.value;
    cor=OpenWindow.document.IDContructor.sel.value;    
    document.master.c16_tarifa_id.value=tip+cor;
    parent.list.Add();
    OpenWindow.close();
}
function GetClase(){
    if(document.master.c1_tipo_tarifa_id.options[document.master.c1_tipo_tarifa_id.selectedIndex].value==""){alert("Escojer el Tipo de Clase Primero");return;}	
    var TipoClase = document.master.c1_tipo_tarifa_id.options[document.master.c1_tipo_tarifa_id.selectedIndex].text.toLowerCase();
    var TipoClases = TipoClase+"s";
    var GetBackStream	 = "c2_"+TipoClase+"_id|c2_codigo_id,v64_"+TipoClase+"|v64_codigo";
    if ((TipoClase=="tipo_impuesto")||(TipoClase=="tipo_actividad_economica")){
        parent.list.GetBack('gmfl',TipoClases,GetBackStream,'parent.opener.parent.form.master',300,100,'','','scrollbars=yes,toolbar=no,menu=no');
    }
    else{
        parent.list.GetBack('LIST',TipoClases,GetBackStream,'parent.opener.parent.form.master',300,100,'','','scrollbars=yes,toolbar=no,menu=no');
    }
    
}