window.addEvent('domready', function() {


});
var actualPage=0;
var popupshow=false;
var loginform='<'+'form action="news.php" name="loreg" method="post"'+'>'+'<'+'table border=0 width=100%'+'>'+'<'+'tr'+'>'+'<'+'td'+'>'+
        '<'+'h4'+'>'+'Don\'t have a account? '+'<'+'/h4'+'>'+
        'Register now and get the access to the more innovative and exciting community'+'<'+'br'+'>'+
        '<'+'div class="button"'+'>'+'<'+'a href="javascript:register()"'+'>'+'Register'+'<'+'/a'+'>'+'<'+'/div'+'>'+'<'+'/td'+'>'+
        '<'+'/td'+'>'+
        '<'+'td valign="top"'+'>'+
        '<'+'h4'+'>'+'Do you have a account?'+'<'+'/h4'+'>'+
        '<'+'table border=0'+'>'+
            '<'+'tr'+'>'+
                '<'+'td'+'>'+
                'Username '+
                '<'+'/td'+'>'+
                '<'+'td'+'>'+'<'+'input type="text" name="username" id="username" size="10"'+'>'+'<'+'/td'+'>'+
            '<'+'/tr'+'>'+
            '<'+'tr'+'>'+
            '<'+'td'+'>'+'Password'+'<'+'/td'+'>'+
            '<'+'td'+'>'+'<'+'input type="password" name="pass" id="pass" size="10"'+'>'+'<'+'/td'+'>'+
            '<'+'/tr'+'>'+
            '<'+'tr'+'>'+
            '<'+'td'+'>'+'<'+'div class="button"'+'>'+'<'+'a href="javascript:login()"'+'>'+'Login'+'<'+'/a'+'>'+'<'+'/div'+'>'+'<'+'/td'+'>'+
            '<'+'/tr'+'>'+
        '<'+'/table'+'>'+
        '<'+'/td'+'>'+
    '<'+'/tr'+'>'+
'<'+'/table'+'>'+'<'+'input type="hidden" name="action" id="action" '+'>'+
'<'+'/form'+'>';
function expand(num){
	new Fx.Reveal($('lang-'+num)).toggle();
	var src=$('imglang-'+num).src;
	if(src.search(/more.png/)!=-1){
		$('imglang-'+num).src="templates/news_template/images/minuz.png"
	}else{
		$('imglang-'+num).src="templates/news_template/images/more.png";
	}
}
function createPopup(title,innHTML){
var newDiv=new Element('div', {
			'id': 'myNewDiv',
			'class' : 'floatpopup',
			'position' : 'absolute',
			'z-index' : '99',
			'margin' : '0 auto',
			'width' : '0px',
			'height' : '0px'			
		});
var newDivBar=new Element('div', {
			'id': 'myNewDivBar',
			'class' : 'floatpopupbar',
			'position' : 'relative',
			'width' : '100%',
			'height' : '20px'			
		});
var newDivCont=new Element('div', {
			'id': 'myNewDivCont',
			'class' : 'floatpopupcont',
			'position' : 'relative',
			'width' : '100%',
			'height' : '100%'			
		});		
		newDivBar.set('html','<'+'span class="popuptit"'+'>'+title+'<'+'/span'+'>'+'<'+'a href="Javascript:closepopup()"'+'>'+'Close [X]'+'<'+'/a'+'>');
	newDivBar.inject(newDiv,'top');	
	newDivCont.set('html',innHTML);
	newDivCont.inject(newDiv,'bottom');	
		
return newDiv;
}
function injectAndEffect(divI,width,height){
	divI.injectBefore('headinje');
    var myFx = new Fx.Tween(divI);
	myFx.start('width', [0,width]);
	var myFx2 = new Fx.Tween(divI);
	myFx2.start('height', [0,height]);
}
function closepopup(){
	$('myNewDiv').destroy();
    popupshow=false;
}
function showpopup(){
	if(popupshow==false){
	var newpop=createPopup("Login Or Register",loginform);
    injectAndEffect(newpop,600,300);
    popupshow=true;
}
}

function togglepages(num){
	for(var i=0;i<pagenum;i++){
		new Fx.Reveal($('mes-'+i)).dissolve();
		$('numpageslink-'+i).setStyle("color","black");
	}
	new Fx.Reveal($('mes-'+num)).reveal();
	$('numpageslink-'+num).setStyle("color","#4496dd");
	actualPage=num;
	
}
function prev(){
	if(actualPage!=0){
	for(var i=0;i<pagenum;i++){
		new Fx.Reveal($('mes-'+i)).dissolve();
		$('numpageslink-'+i).setStyle("color","black");
	}
	var prefpage=actualPage-1;
	new Fx.Reveal($('mes-'+prefpage)).reveal();
	$('numpageslink-'+prefpage).setStyle("color","#4496dd");
	actualPage=prefpage;	
	}
}
function next(){
	if(actualPage<(pagenum-1)){
	for(var i=0;i<pagenum;i++){
		new Fx.Reveal($('mes-'+i)).dissolve();
		$('numpageslink-'+i).setStyle("color","black");
	}
	var prefpage=actualPage+1;
	new Fx.Reveal($('mes-'+prefpage)).reveal();
	$('numpageslink-'+prefpage).setStyle("color","#4496dd");
	actualPage=prefpage;	
	}
}
function submit(){
	if($('comment').value==""){
		alert("Please fill the box with your comment");
	}else{
		document.sendcom.submit();
	}
}

function register(){
location.href="http://community.affeuro.com/signup.php";
}

function login(){
	if($('username').value==""){
		alert("Please fill the username field");
	}else{
	if($('pass').value==""){
		alert("Please fill the password field");
	}else{
		$('action').value="loginnow";
		document.loreg.submit();
	}
}
	
}
