function RemberPass(){
	new Ajax.Updater('div_password',"/remember.php", {
		 parameters: $('remember').serialize(true), asynchronous: false
	 });	 
}
function Tog(obj)
{
	Effect.toggle($(obj),'slide',{duration: 0.3});
}
function checksubmit(){
	vday = document.getElementById("MemberDay").value;
	vmonth = document.getElementById("MemberMonth").value;
	vyear = document.getElementById("MemberYear").value;
	//alert(vday);
	if(vday!=0 && vmonth!=0 && vyear!=0){
		document.location.href ="/"+ vday + "-" + vmonth + "-" + vyear;
	}
}
function ChangeMonthCalendar(year,month)
{
	new Ajax.Updater(
		'box_calendar', 
		'/calendar_show.php?year='+year+"&month="+month, 
		{
			asynchronous:true, 
			evalScripts:true
		}
	);
}	
function Yahoo(adresa)
{
	window.location=encodeURI('ymsgr:im?msg='+'http://www.cotidianul.ro'+escape(adresa)+' ');
}
function countChar(text,div,numar_caractere) {	
	val = text.value;
	if (val.length > numar_caractere) {
		alert('Textul dumneavoastra depaseste limita de '+numar_caractere+' de caractere!');
		text.value = val.substring(0,numar_caractere);
		text.focus();
	}
	document.getElementById(div).innerHTML = parseInt(val.length);
}
function Apare()
{
	$('fotodesc_a').style.left ='0px';
	$('fotodesc').style.left ='0px';
	//Effect.Appear($('fotodesc'),'slide', { duration: 0.3 });	
	
}
function Dispare()
{
	$('fotodesc_a').style.left = '-1000px';
	$('fotodesc').style.left = '-1000px';
	//Effect.Fade($('fotodesc'), { duration: 0.3 });	
}

function getkey(e)
{
	if (window.event)
	   return window.event.keyCode;
	else if (e)
	   return e.which;
	else
	   return null;
}
function isNumber(e)
{
	var accept="0123456789.";
	
	var key = getkey(e);
	
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
	return true;
	
	var char = String.fromCharCode(key);
	char = char.toLowerCase();
	
	if (accept.indexOf(char) != -1)
		return true;

	return false;
}
function Decimal(numar_decimal)
{
	return parseFloat(numar_decimal).toFixed(4);
}

function Calculate()
{
	
	$("input_to").value=parseFloat(Decimal(Decimal($("input_from").value)* (moneda[$("select_from").value][0]/moneda[$("select_to").value][0])));
	if ($("input_from").value==''){$("input_to").value=0;}
}
function ShowMedia(obj)
{
	Effect.toggle(obj,'slide',{duration: 0.3});
	$('foto').style.display="none";
	$('video').style.display="none";
	$('audio').style.display="none";
}
function Raspunde(id)
{
	
	if ($('answer')){ $('answer').value=id; }
}
function FormFocus(obj) {
	if(obj.value==obj.defaultValue) obj.value='';
}

function FormBlur(obj) {
	if(obj.value=='') obj.value=obj.defaultValue;
}
function slide(xMove,album,width){
	var position = Position.positionedOffset($('PLayer' + album));
	var dimensions = $('PLayer' + album).getDimensions();
	//alert(dimensions.width);
	if(position[0]%95 == 0){
		
		if( xMove > 0 && !(position[0] == 0) ){
			new Effect.MoveBy($('PLayer' + album), 0, xMove, {
							duration: 1
						});
		}
		//alert(position[0] + ' ' + (437 - dimensions.width));
		if( xMove < 0 && !( position[0] <= (width - dimensions.width+10) ) ){
			new Effect.MoveBy($('PLayer' + album), 0, xMove, {
							duration: 1
						});
		}
	}
}
function SendComment(){
	if (CheckComment()){
		document.frmAddComment.submit();	
	}	 
}

function CheckComment(){
	return(
		checkString (document.frmAddComment.CommentBody,'Comentariul Dvs.' )&&
		checkEmail(document.frmAddComment.CommentEmail,'Email-ul Dvs !' )&&
		checkString (document.frmAddComment.CommentUsername,'Numele si prenumele Dvs.' )
	);
}	
function openpopup(popurl){ 
	winpops=window.open(popurl,"","width=1000,height=640") 
} 
function Zoom(){
	$('ArticleBody').toggleClassName('zoomBig');
}
	
function OpenPrint(id){
	window.open('/print.php?id='+id,'print','width=700,height=500,scrollbars=yes');
}
	
function OpenBox(url){
	 new Ajax.Updater('box_email',url, {
		 asynchronous: false
	 });
	 
	ttop=0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		ttop=window.pageYOffset;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		ttop=document.documentElement.scrollTop;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		ttop=document.body.scrollTop;
	}

	l = (myWidth-700)/2;
	t = (myHeight-250)/2+ttop ; 
	
	 $('box_email').style.left = l+'px';
	 $('box_email').style.top = t+'px'; 
	 
	 $('box_email').style.display="block";
}
//---------------------send email		
function SendEmail(url){
	if (CheckFormEmail()){
		new Ajax.Updater('box_email',url, {
			 parameters: $('sendemail').serialize(true), asynchronous: false
		 });
	}	 
}

function CheckFormEmail(){
	return(
		checkString (document.sendemail.name,'Numele tau' ) &&
		checkEmail(document.sendemail.email,'Adresa ta de email' ) &&
		checkString (document.sendemail.name_friend,'Numele prietenului tau' ) &&
		checkEmail (document.sendemail.email_friend,'Adresa de email a prietenului' )
	);
}

//---------------------send feedback			
function SendFeedback(){
	if (CheckFormFeedback()){
		new Ajax.Updater('box_email','/articles/feedback/', {
			 parameters: $('sendemail').serialize(true), asynchronous: false
		 });
	}	 
}

function CheckFormFeedback(){
	return(
		checkString (document.sendemail.nume,'Nume' ) &&
		checkString (document.sendemail.prenume,'Prenume' ) &&
		checkEmail(document.sendemail.email,'Adresa ta de email' ) &&
		checkString (document.sendemail.comentariu,'Comentariu' )
	);
}	

function Close(){
	 $('box_email').style.display="none";
} 