// JavaScript Document

function showPublications(){	
	resizePage();
	if( $("publications_popup") ){

                $("publications_popup").style.display = "block";
                $("publications_popup").innerHTML = '';
                
                $("publications_popup").style.width = "395px";    
                //$("publications_popup").style.border = "1px solid #669933";
                //$("publications_popup").style.position = "absolute";
                $("publications_popup").style.position = "relative";
                $("publications_popup").style.backgroundColor = "white";
                //$("publications_popup").style.padding = "5px";

		//new Ajax.Updater('publications_popup','cdsajax?method=getPublications',
                new Ajax.Updater('publications_popup','cdsajax?method=getPublicationsTemp',
							{insertion:Insertion.Top,
							parameters: Form.serialize(document.forms[0]),
							onComplete: function(request){
										if((!request.status) || 
											(request.status >400)){
											//alert(request.status);
											$("publications_popup").innerHTML = 'The server is not available'+
											'Try soon';
											}
										}
							});
	}
}

function closePublicationPopup(){
        if( $("publications_popup") ){
               $("publications_popup").style.display = "none"; 
        }
}

function trim(theValue){
    r = theValue.toString();
    r = r.replace(/ *$/,"");
    return r.replace(/^ */,"");
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}
function showLogin(id){
							var elem = document.getElementById(id);
							var td = document.getElementById('tdLogin');
							if (elem.style.display=="none"){
								elem.style.display="inline";
								//td.bgColor='#669933';				
							}
							else if (elem.style.display=="inline"){
								elem.style.display="none";
								//td.bgColor='#FFFFFF';
							}
						}
var errorMsg = 'This field is mandatory';