var base="http://1februarie.com/";
function topLinks(e,p){
	e=parseInt(e);
	var elem=gE("small_intro");
	if(e==0){
			elem.style.display="none";
	}else{
			elem.style.display="block";
			elem.className="small_intro_min";
			elem.innerHTML='<div class="loader"></div>';
			
			xht=GetXmlHttpObject();
			var url=base + "topLinks.php?from=" + e + "&params=" + p + "&sid=" + Math.random();
			xht.onreadystatechange=function(){
			if (xht.readyState==4 || xht.readyState=="complete"){
					elem.className="small_intro";
					//	window.gE("focusMe").focus();
					elem.innerHTML=xht.responseText;
				}
			}
			xht.open("GET",url,true);
			xht.send(null);	
	}

}
		
function GetXmlHttpObject(){
	var xht=null;
	try{xht=new XMLHttpRequest();}
	catch (e){
		try{xht=new ActiveXObject("Msxml2.XMLHTTP");}
		catch(e){xht=new ActiveXObject("Microsoft.XMLHTTP");}
	}
	return xht;
}		
		
function makeRequest(from,params){
	xht=GetXmlHttpObject();
	var url="myRequest.php?from=" + from + "&params=" + params + "&sid=" + Math.random();
	xht.onreadystatechange=function(){
		if (xht.readyState==4 || xht.readyState=="complete")
			gE("submenu").innerHTML=xht.responseText;
	}
	xht.open("GET",url,true);
	xht.send(null);
}


function updateClock(){
 
	acum = new Date();
	atunci = new Date("1 February, 2011");
	
	delta = atunci.getTime() - acum.getTime();

	delta = parseInt(delta/1000);
	temp = delta;
	secunde = parseInt(delta%60);

	delta = parseInt(delta/60);
	minute = parseInt(delta%60);
	
	delta = parseInt(delta/60);
	ore = parseInt(delta%24);
	
	delta = parseInt(delta/24);
	zile = delta;
	
	t12 = parseInt(secunde % 10);
	t11 = parseInt(secunde / 10);
	
	t9 = parseInt(minute % 10);
	t8 = parseInt(minute / 10);
	
	t6 = parseInt(ore % 10);
	t5 = parseInt(ore / 10);
	
	t3 = parseInt(zile % 10);
	t2 = parseInt(parseInt(zile % 100)/10);
	t1 = parseInt(zile/100);

	if(temp<0){
		for(i=1;i<=12;i++){
			gE("d"+i).style.display="none";
		}
	}
	else{
	
		if(temp>0) gE("d12").className="c" + t12;
			else gE("d12").style.display=none;
			
		if(temp>9) gE("d11").className="c" + t11;
			else gE("d11").style.display=none;
	
	
	
		if(temp>59) gE("d9").className="c" + t9;
			else { gE("d9").style.display="none"; gE("d10").style.display="none"; }
			
		if(temp>599) gE("d8").className="c" + t8;
			else gE("d8").style.display="none";
	
	
	
		if(temp>3599) gE("d6").className="c" + t6;
			else { gE("d6").style.display="none"; gE("d7").style.display="none"; }
			
		if(temp>35999) gE("d5").className="c" + t5;
			else gE("d5").style.display="none";	
			
			
		if(temp>86399) gE("d3").className="c" + t3;
			else { gE("d3").style.display="none"; gE("d4").style.display="none"; }
			
		if(temp>863999) gE("d2").className="c" + t2;
			else gE("d2").style.display="none";
			
		if(temp>8639999) gE("d1").className="c" + t1;
			else gE("d1").style.display="none";
	}
}



function gE(id){
	return document.getElementById(id);
}
function getkey(e){
	if(window.event) return window.event.keyCode;
	else if(e) return e.which;
	else return null;
}
function goodchars(e,goods){
	var key,keychar;
	key=getkey(e);
	if(key==null) return true;
	keychar=String.fromCharCode(key);
	keychar=keychar.toLowerCase();
	goods=goods.toLowerCase();
	if(goods.indexOf(keychar)!=-1) return true;
	if(key==null||key==0||key==8||key==9||key==13||key==27) return true;
	return false;
}

function trimiteContributie(){
	params=gE("an").value + "|" + gE("luna").value + "|" + gE("zi").value + "|" + gE("tip").options[gE("tip").selectedIndex].value + "|" + gE("continut").value;
	topLinks(4,params);
}
function trimiteContact(){
	params=gE("nume").value + "|" + gE("subiect").value + "|" + gE("contact").value + "|" + gE("continut").value;
	topLinks(3,params);
}

function schimbaLuna(e){
	e=parseInt(e);
	for(i=1;i<=12;i++){
		if(i!=e) gE("luna"+i).style.display="none";
	}
	gE("buildLink").innerHTML="";
	if(e!=0) gE("luna"+e).style.display="block";
}

function buildLink(a,b){
	gE("buildLink").innerHTML="<a class=\"buildLink\" href=\"http://1februarie.com/" + a + "/" + b + "/\">Click pentru ziua de " + b + " " + a + "</a>";	
}
function obtineFelicitare(){
	var luna=0;
	var zi=0;
	try{
		luna=gE("luna").options[gE("luna").selectedIndex].value;
	}catch(e){}
	if(luna!="none"){
		try{
			zi=gE("luna" + luna).options[gE("luna" + luna).selectedIndex].value;
		}catch(e){}
	}
	var mesaj=gE("mesaj").value;
	var youtube=gE("youtube").value;
	var dela=gE("dela").value;
	topLinks(6,luna+"|"+zi+"|"+mesaj+"|"+youtube+"|"+dela);
}