/* funciones de OKA.es */
/* JSON */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8 k=4(){8 m={\'\\b\':\'\\\\b\',\'\\t\':\'\\\\t\',\'\\n\':\'\\\\n\',\'\\f\':\'\\\\f\',\'\\r\':\'\\\\r\',\'"\':\'\\\\"\',\'\\\\\':\'\\\\\\\\\'},s={\'14\':4(x){3 F(x)},13:4(x){3 12(x)?F(x):\'j\'},7:4(x){2(/["\\\\\\E-\\D]/.p(x)){x=x.o(/([\\E-\\D\\\\"])/g,4(a,b){8 c=m[b];2(c){3 c}c=b.11();3\'\\\\10\'+Z.Y(c/d).C(d)+(c%d).C(d)})}3\'"\'+x+\'"\'},X:4(x){2(x){8 a=[],b,f,i,l,v;2(x W V){a[0]=\'[\';l=x.6;B(i=0;i<l;i+=1){v=x[i];f=s[5 v];2(f){v=f(v);2(5 v==\'7\'){2(b){a[a.6]=\',\'}a[a.6]=v;b=z}}}a[a.6]=\']\'}y 2(5 x.A===\'4\'){a[0]=\'{\';B(i U x){2(x.A(i)){v=x[i];f=s[5 v];2(f){v=f(v);2(5 v==\'7\'){2(b){a[a.6]=\',\'}a.T(s.7(i),\':\',v);b=z}}}}a[a.6]=\'}\'}y{3}3 a.S(\'\')}3\'j\'}};3{R:\'(c)Q k.w\',q:\'P://O.k.w/q.N\',M:4(v){8 f=s[5 v];2(f){v=f(v);2(5 v==\'7\'){3 v}}3 j},L:4(h){K{3!(/[^,:{}\\[\\]0-9.\\-+J-u \\n\\r\\t]/.p(h.o(/"(\\\\.|[^"\\\\])*"/g,\'\')))&&I(\'(\'+h+\')\')}H(e){3 G}}}}();',62,67,'||if|return|function|typeof|length|string|var|||||16||||text||null|JSON||||replace|test|license||||||org||else|true|hasOwnProperty|for|toString|x1f|x00|String|false|catch|eval|Eaeflnr|try|parse|stringify|html|www|http|2005|copyright|join|push|in|Array|instanceof|object|floor|Math|u00|charCodeAt|isFinite|number|boolean'.split('|'),0,{}))

var esdesD = (document.location.host.indexOf('.desd')!=-1)?true:false;
var servidor=document.location.protocol+'//'+document.location.host+'/';
var nav=(navigator.appName=='Netscape')?1:0;
var separaAJAX='_o&o_';
var gPosX,gPosY,gAnchoV,gAltoV,elem;
var offX=10;var offY=10;

function fichaPop(id, eltipo, evento) {
	//fichaPop(0, 'llameme', event)
	var ev = (nav)?evento:window.event;
	_getXY(ev);
	var existe=true;
	try {var d=document.getElementById('fichapop').innerHTML;}
	catch (e) {existe=false;}
	
	var div;
	if (existe) {document.body.removeChild(document.getElementById('fichapop'));existe=false;}
	if (!existe) {
		div=document.createElement('DIV');
		with (div) {
			id='fichapop';
			className='vTip';
			style.left=(gPosX-offX)+'px';
			style.top=(gPosY-60)+'px';
			style.zIndex=99;
			style.width='300px';
			innerHTML='<p>Obteniendo datos ...</p>';
		}
		document.body.appendChild(div);
		$('#fichapop').load("/g/tpl/tpl-108/fichapop.php", {'tipo':eltipo,'idioma':window.dwidioma});
	}
}
function _getXY(evento) {
if (nav==1) {gPosX=evento.clientX+window.scrollX;gPosY=evento.clientY+window.scrollY;}
else {gPosX=evento.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);gPosY=evento.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);	}
}

function favoritos(){
	var title = document.title;var url = document.location.href;
	if (window.sidebar) {window.sidebar.addPanel(title, url, "");}/*firefox*/
	else if(window.opera && window.print){var elem=document.createElement('a');elem.setAttribute('href',url);elem.setAttribute('title',title);elem.setAttribute('rel','sidebar');elem.click();} /* opera*/
	else if(document.all) {window.external.AddFavorite(url, title);}/* IE */
	else if(Chrome==true) {alert('Presione Control + D para añadir a favoritos')}
}

function _okaPonEstilos() {
	var h1s = document.getElementsByTagName("H1");
	/*
	398	azul1	diseño web
	399	rojo	programacion
	400	verde2	bases de datos
	401	morado	aplicaciones
	402	burdeos	dominios
	403	verde1	contactar
	*/
	estilos = {
		//español
		'0':Array('verde1', 'motivo1'), //portada
		'1242':Array('azul1','motivo4'), //diseño web
		'1243':Array('rojo', 'motivo1'), //programación
		'1244':Array('naranja2', 'motivo2'), //bases de datos
		'1254':Array('verde2', 'motivo6') //despachoweb
	}
	estilos['1448'] = estilos['1425'] = estilos['0']; //portada
	estilos['1449'] = estilos['1426'] = estilos['1242']; //diseño web
	estilos['1450'] = estilos['1427'] = estilos['1243']; //programación
	estilos['1451'] = estilos['1428'] = estilos['1244']; //bases de datos
	estilos['1461'] = estilos['1438'] = estilos['1254']; //despachoweb
	for (var h1=0;h1<h1s.length;h1++) {
		h1s[h1].className=estilos[window.dwmenu][0];
	}
	try {document.getElementById('motivocentral').className=estilos[window.dwmenu][1];}
	catch(err) {}
}
function _okaPortada() {
	//$("#contenido").load("/g/tpl/tpl-108/portada.php", {'idioma':window.dwidioma});
	//colocamos los enlaces
}

var datPortadas_esp, datPortadas_cat, datPortadas_eng;
datPortadas_esp = {
//inicio
'0':Array('Internet Rentable', 'El diseño y la programación en Internet tiene como único objetivo que su empresa sea más rentable. Para ello OKA es su mejor aliado.','',''),
//diseño web
'1':Array('Dise&ntilde;o Web', 'Dise&ntilde;o que utiliza la &uacute;ltima tecnolog&iacute;a para atraer clientes y hacer su empresa m&aacute;s rentable.','<a href="xNADAx">para saber m&aacute;s ...</a>&nbsp;&nbsp;&nbsp;','diseno_web'),
//programación
'2':Array('Programaci&oacute;n', 'Compruebe c&oacute;mo una Intranet o Extranet pueden hacer que su negocio sea mucho más rentable.','<a href="xNADAx">para saber m&aacute;s ...</a>&nbsp;&nbsp;&nbsp;','programacion'),
//bases de datos
'3':Array('Bases de datos', 'Extraer toda el valor de una base de datos es cuestión de conocimiento, experiencia y potencia.','<a href="xNADAx">para saber m&aacute;s ...</a>&nbsp;&nbsp;&nbsp;','bases_de_datos'),
//dominios//'4':Array('Dominios', 'Compre su dominio para comenzar a operar en Internet ahora mismo.','<a href="nada">busque el suyo  ...</a>&nbsp;&nbsp;&nbsp;'	)
//Despachoweb
'6':Array('Despachoweb', 'El entorno de gestión que le permite realmente tomar el control de su web.','<a href="xNADAx">para saber más  ...</a>&nbsp;&nbsp;&nbsp;','despachoweb')}
datPortadas_cat = {
'0':Array('Internet Rendible', 'El disseny i la programació a Internet té com a únic objectiu que la seva empresa sigui més rendible. Per a això OKA és el seu millor aliat. ','',''),
'1':Array('Disseny Web', 'Disseny que utilitza la darrera tecnologia per fer atraure clients i fer la seva empresa més rendible.', '<a href="xNADAx"> per saber més ...</a>&nbsp;&nbsp;&nbsp;','disseny_web'),
'2':Array('Programació', 'Comprovi com una Intranet o Extranet poden fer que el seu negoci sigui més rendible.', '<a href="xNADAx"> per saber més ...</a>&nbsp;&nbsp;&nbsp;','programacio'),
'3':Array('Bases de dades', "Extreure tota el valor d'una base de dades és qüestió de coneixement, experiència i potència.",'<a href="xNADAx"> per saber més ...</a>&nbsp;&nbsp;&nbsp;','bases_de_dades'),
//dominios//'4':Array('Dominios', 'Compre su dominio para comenzar a operar en Internet ahora mismo.','<a href="nada">busque el suyo  ...</a>&nbsp;&nbsp;&nbsp;')
'6':Array('Despachoweb', "L'entorn de gestió que li permet realment prendre el control de la seva web.",'<a href="xNADAx"> per saber més ...</a>&nbsp;&nbsp;&nbsp;','despachoweb')}
datPortadas_eng = {
'0':Array('Profitable Internet','The design and programming on the Internet has only one objective that your business more profitable. OKA is for this your best ally. ','',''),
'1':Array('Web Design', 'Web design that uses the latest technology to attract customers and make your company more profitable.','<a href="xNADAx">find out more ...</a>&nbsp;&nbsp;&nbsp;','web_design'),
'2':Array('Programming', 'See for yourself how an Intranet or Extranet can make your business more profitable.','<a href="xNADAx">find out more ...</a>&nbsp;&nbsp;&nbsp;','programming'),
'3':Array('Databases', 'Extracting all the value from a database is a matter of knowledge, experience and computing power.','<a href="xNADAx">find out more ...</a>&nbsp;&nbsp;&nbsp;','databases'),
//'4':Array('Dominios', 'Compre su dominio para comenzar a operar en Internet ahora mismo.','<a href="nada">busque el suyo  ...</a>&nbsp;&nbsp;&nbsp;')
'6':Array('Despachoweb', 'The web framework that lets you take full control of your website.','<a href="xNADAx">find out more ...</a>&nbsp;&nbsp;&nbsp;','despachoweb')}
/**/
function _ponMotivo(cual) {
	eval('var dat = datPortadas_'+window.dwidioma);
	document.getElementById('imagenportada').style.backgroundImage='url(/g/tpl/tpl-108/graf/port'+cual.toString()+'.jpg)';
	document.getElementById('h1imagenport').innerHTML = dat[cual][0];
	document.getElementById('pimagenport').innerHTML = dat[cual][1];
	re  = /xNADAx/gi
	var enlace = document.getElementById('mno_'+dat[cual][3]).href;
	document.getElementById('p2imagenport').innerHTML = dat[cual][2].replace(re, enlace);
}
$(document).ready(function() {
	//_okaPonEstilos();
	var p=document.location.href.split('http://'+dominio)[1];
	if (p=='/' || p=='/html/'+window.dwidioma+'/' || p=='/html/'+window.dwidioma || window.esPortada) {_okaPortada();}
	else {_okaPonEstilos();}
	$("#icofliperclose").click(function() {$("#fliper").slideToggle(1000);});
	$("#btnbusca").click(function() {_gBusca();});
	$("#q").keyup(function(event){if(event.keyCode==13) {_gBusca();}});

	//document.getElementById('q').onEnter = _gTextoBusca();
	$("#dividiomas").click(function() {$("#dividiomas2").slideToggle(100);});
	
	var haysubmenu; 
	try {haysubmenu = (trim(document.getElementById('menuleft').innerHTML).substr(0, 3).toUpperCase()=='<H1')?true:false;}
	catch(err) {haysubmenu=true;}
	
	//(trim(document.getElementById('menuleft').innerHTML).substr(0, 3).toUpperCase()=='<H1')?true:false;
	if (!haysubmenu && !window.esPortada) {
		var h1nomenu = '<h1 class="verde2">www.oka.es</h1><p><img src="/g/tpl/tpl-108/graf/internet_rentable.gif" alt="OKA - Internet Rentable"></p>';
		document.getElementById('menuleft').innerHTML=h1nomenu+document.getElementById('menuleft').innerHTML;
	}
	if (window.dwmenu) {
		var as=document.getElementById('menutop').getElementsByTagName('A');
		for (var a=0;a<as.length;a++) {if (as[a].href.indexOf('/'+window.dwmenu+'/')!=-1) {as[a].className+=' actual';}}
	}
	/*
	if (window.esPortada || window.showAd) {
		if (_showAd()) {
			$("#popup1").attr({src:"/g/tpl/tpl-108/graf/popup-595-1_"+window.dwidioma+".png"});
			$("#popup2").attr({src:"/g/tpl/tpl-108/graf/popup-595-2_"+window.dwidioma+".png"});
			$("#popup3").attr({src:"/g/tpl/tpl-108/graf/popup-595-3_"+window.dwidioma+".png"});
			$("#popup").slideToggle(3500);
			
			switch (window.dwidioma) {
				case 'esp':
					$("#enlpopup1").attr({href:"/html/esp/1260/despachoweb__alta_oferta_50.html"});
					$("#enlpopup2").attr({href:"/html/esp/1260/despachoweb__alta_oferta_50.html"});
				break;
				case 'cat':
					$("#enlpopup1").attr({href:"/html/cat/1467/despachoweb__alta_oferta_50.html"});
					$("#enlpopup2").attr({href:"/html/cat/1467/despachoweb__alta_oferta_50.html"});
				break;
				case 'eng':
					$("#enlpopup1").attr({href:"/html/eng/1444/despachoweb__50_discount_offer.html"});
					$("#enlpopup2").attr({href:"/html/eng/1444/despachoweb__50_discount_offer.html"});
				break;
			}
			$("#enlpopup3").click(function() {$("#popup").slideToggle(2000);_noAd();});
		}
	}
	*/
});

function dime() {alert(document.cookie);}
function _showAd() {
	var c= document.cookie;
	var show =true;
	if (c.indexOf('oka=')!=-1) {show=(c.split('oka={showad=')[1].split('}')[0]=='1')?true:false;}
	else {show=true;}
	return show;
}
function _noAd() {
	var fecha=new Date();
	var Periodo=fecha.getTime()+(10*24*60*60*1000);//10 días
	fecha.setTime(Periodo);
	document.cookie="oka={showad=0}; path=/; expires="+fecha.toGMTString();
}
function borra() {
	var fecha=new Date();
	var Periodo=fecha.getTime()-(10*24*60*60*1000);//30 días
	fecha.setTime(Periodo);
	document.cookie="oka={showad=1}; path=/; expires="+fecha.toGMTString();
}

function _gTextoBusca() {
	var d = document.forms['formq'];
	alert(d.q.value);
}
//"texto a buscar"
var Res;
function _gBusca() {
	var d = document.forms['formq'];
	//alert(d.q.value);
	if (!d.q.value || d.q.value.length<3) {alert('La cadena de búsqueda debe tener al menos 3 caracteres');return;}
	var q = trim(d.q.value);
	$.post('/g/tpl/tpl-108/rec.php', {'q':q, 'dominio':window.dominio}, _gColocaResultados, "text");
}
function _gColocaResultados(datos) {
	//alert(datos)
	var dat=JSON.parse(datos);
	var dat0 = dat[0];
	var dat1 = dat[1];
	var t="<h1>Buscando '<i>"+dat0.q+"</i>' en oka.es</h1><p>&nbsp;</p><span id='listares'></span>";
	var na, sigo;
	try {na=dat1.length; sigo=true;}
	catch(err) {sigo=false;}
	if (sigo) {window.Res = dat1;$("#flipertd").html(t);_paginaRes(1);}
	else {t += "<p>No se han encontrado resultados</p>";$("#flipertd").html(t);}
	$("#fliper").slideToggle(1000);
}
var porPaginaRes = 5;
function _paginaRes(pag) {
	var t= '';
	var inicio = (pag-1)*porPaginaRes;
	var fin=inicio+porPaginaRes;
	if (fin>window.Res.length) {fin=window.Res.length;}
	for (var i=inicio;i<fin;i++) {
		 t += "<p><img src='/g/flag/"+window.Res[i].idm+"' align='absmiddle'> <a href='"+window.Res[i].url+"'>"+window.Res[i].t+"</a></p>";
	}
	var t2='';
	if (pag>1) {t2 += "<a href='javascript:_paginaRes("+(pag-1)+")'>&laquo; p&aacute;gina anterior</a>&nbsp; &nbsp;";}
	if (window.Res.length>fin) {t2 += "<a href='javascript:_paginaRes("+(pag+1)+")'>siguiente p&aacute;gina &raquo;</a>";}
	if (t2!='') {t+="<p align='right'>"+t2+"</p>";}
	$("#listares").html(t);
}

/* droppy */
$.fn.droppy=function(options){options=$.extend({speed:250},options||{});this.each(function(){var root=this,zIndex=1000;function getSubnav(ele){if(ele.nodeName.toLowerCase()=='li'){var subnav=$('> ul',ele);return subnav.length?subnav[0]:null;}else{return ele;}}function getActuator(ele){if(ele.nodeName.toLowerCase()=='ul'){return $(ele).parents('li')[0];}else{return ele;}}function hide(){var subnav=getSubnav(this);if(!subnav){return;}$.data(subnav,'cancelHide',false);setTimeout(function(){if(!$.data(subnav,'cancelHide')){$(subnav).slideUp(options.speed);}},500);}function show(){var subnav=getSubnav(this);if(!subnav){return;}$.data(subnav,'cancelHide',true);$(subnav).css({zIndex:zIndex++}).slideDown(options.speed);if(this.nodeName.toLowerCase()=='ul'){var li=getActuator(this);$(li).addClass('hover');$('> a',li).addClass('hover');}}$('ul, li',this).hover(show,hide);$('li',this).hover(function(){$(this).addClass('hover');$('> a',this).addClass('hover');},function(){$(this).removeClass('hover');$('> a',this).removeClass('hover');});});};
/* Tooltip */
(function(a){a.fn.wTooltip=function(h,i){h=a.extend({content:null,ajax:null,fadeIn:0,fadeOut:0,appendTip:"body",degrade:false,offsetY:10,offsetX:1,style:{},className:null,id:null,callBefore:function(){},callAfter:function(){},delay:0},h||{});if(!h.style&&typeof h.style!="object"){h.style.zIndex="1000"}else{h.style=a.extend({border:"1px solid #000",background:"#6699FF",color:"#FFF",padding:"10px",zIndex:"1000",maxWidth:"350px",textAlign:"left",fontSize:"15px"},h.style||{})}if(typeof i=="function"){h.callAfter=i||h.callAfter}h.style.display="none",h.style.position="fixed";var e,d=document.createElement("div"),c=document.getElementsByTagName("html")[0],b=(typeof document.body.style.maxWidth=="undefined")?true:false;if(b){h.style.position="absolute"}if(h.id){d.id=h.id}if(h.className){d.className=h.className}h.degrade=(h.degrade&&b)?true:false;for(var g in h.style){d.style[g]=h.style[g]}function f(j){if(j){if(h.degrade){a(d).html(h.content.replace(/<\/?[^>]+>/gi,""))}else{a(d).html(h.content)}}}if(h.ajax){a.get(h.ajax,function(j){if(j){h.content=j}f(h.content)})}f(h.content&&!h.ajax);a(d).appendTo(h.appendTip);return this.each(function(){this.onmouseover=function(j){if(this.title&&!h.degrade){h.title=this.title;this.title=""}if(h.content&&h.degrade){this.title=d.innerHTML}e=setTimeout(function(){if(typeof h.callBefore=="function"){h.callBefore()}var l=(j)?j:window.event;var k;if(h.content){if(!h.degrade){k="block"}}else{if(h.title&&!h.degrade){a(d).html(h.title);k="block"}else{k="none"}}if(k=="block"&&h.fadeIn){a(d).fadeIn(h.fadeIn)}else{d.style.display=k}},h.delay)};this.onmouseout=function(k){clearTimeout(e);var l=(k)?k:window.event,j=this;var m=function(){if(typeof h.callAfter=="function"){h.callAfter()}if(h.title){j.title=h.title;h.title=null}};if(h.fadeOut){a(d).fadeOut(h.fadeOut,function(){m()})}else{m();d.style.display="none"}};this.onmousemove=function(l){var o=(l)?l:window.event;var j=(b)?c.scrollTop:0;var k=(b)?c.scrollLeft:0;var n={top:o.clientY+j+h.offsetY+"px",left:o.clientX+k+h.offsetX+"px"};for(var m in n){d.style[m]=n[m]}}})}})(jQuery);