function showMe(text, ev) {
	var theDiv = document.getElementById('showMeDiv');
	theDiv.scrollTop = 0;
	theDiv.style.left = (ev.clientX + 15 + document.documentElement.scrollLeft)+ "px";
	theDiv.style.top = (ev.clientY + document.documentElement.scrollTop)+ "px";
	theDiv.innerHTML = text;
	theDiv.style.visibility = 'visible';
	theDiv.style.width = "250px";
	var wid, hei, dWid, dHei;
	if (window.innerWidth) {
		wid = window.innerWidth;
		hei = window.innerHeight;
	}
	else {
		wid = document.body.clientWidth;
		hei = document.body.clientHeight;
	}
	wid -= 15;
	
	dWid = theDiv.clientWidth;
	dHei = theDiv.clientHeight;
	if (ev.clientX + dWid > wid)
		theDiv.style.left = (parseInt(theDiv.style.left+document.documentElement.scrollTop) - dWid - 30) + "px";
	if (ev.clientY + dHei > hei)
		theDiv.style.top = (parseInt(theDiv.style.top+document.documentElement.scrollTop) - dHei) + "px";
}

var sDir = 5;
var tId;
var runDelay = 20;
var scrollVar;
var stillScroll;

function load_big_image(id, img_src)
{//alert(img_src);
if (Element.visible('article_image_big_div_'+id))
	{
	 new Effect.Opacity('article_image_big_div_'+id,
			{ duration: 0.5, 
			  transition: Effect.Transitions.linear, 
			  from: 0.95, to: 0.0, afterFinish:function(){
										Element.hide('article_image_big_div_'+id);				
										$("article_image_big_div_"+id).style.zIndex=-50;
										}
			});
	}
else
	{
	 new Effect.Opacity('article_image_big_div_'+id,
			{ duration: 0.5, 
			  transition: Effect.Transitions.linear, 
			  from: 0.0, to: 0.95, beforeStart:function(){
				  new Ajax.Updater('article_image_big_div_'+id,'jax/return_img_content.php',{method:'post',postBody:'img_src='+img_src,onComplete:function(){Element.show('article_image_big_div_'+id);$("article_image_big_div_"+id).style.zIndex=50;}});
			  } });
	}
}


function hideMe() {
	var theDiv = document.getElementById('showMeDiv');
	theDiv.style.visibility = 'hidden';
	stillScroll = false;
	if (tId)
		clearTimeout(tId);
}

function moveMe(ev) {
	var theDiv = document.getElementById('showMeDiv');
	theDiv.style.left = (ev.clientX + 15 + document.documentElement.scrollLeft)+ "px";
	theDiv.style.top = (ev.clientY + document.documentElement.scrollTop)+ "px";
	var wid, hei, dWid, dHei;
	if (window.innerWidth) {
		wid = window.innerWidth;
		hei = window.innerHeight;
	}
	else {
		wid = document.body.clientWidth;
		hei = document.body.clientHeight;
	}
	wid -= 15;
	
	dWid = theDiv.clientWidth;
	dHei = theDiv.clientHeight;
	
	if (ev.clientX + dWid > wid)
		theDiv.style.left = (parseInt(theDiv.style.left) - dWid - 30) + "px";
		
	if (ev.clientY + dHei > hei)
		theDiv.style.top = (parseInt(theDiv.style.top) - dHei) + "px";
}

function sizeMe(x) {
	var theDiv = document.getElementById('showMeDiv');
	if (x != '')
		theDiv.style.width = x + 'px';
	else
		theDiv.style.width = '';
	theDiv.style.height = '';
}

function scrollMe() {
	scrollVar = 0;
	stillScroll = true;
	sDir = 5;
	nextScrollStep();	
	var theDiv = document.getElementById('showMeDiv');
}

function nextScrollStep() {
	var theDiv = document.getElementById('showMeDiv');
		
	runDelay = 20;
	
	theDiv.scrollTop = scrollVar;
	scrollVar += sDir;
	
	if (scrollVar <= 0) {
		scrollVar = 0;
		sDir = -sDir;
		runDelay = 1500;
	}
	
	if (scrollVar >= theDiv.scrollHeight - parseInt(theDiv.style.height) +25 ) {
		scrollVar = theDiv.scrollHeight - parseInt(theDiv.style.height) + 25;
		sDir = -sDir;
		runDelay = 1500;
	}
	
	if (stillScroll)
		tId = setTimeout('nextScrollStep()', runDelay);
}
function getInfo(text_value){
	new Ajax.Updater('showMeDiv','jax/return_img_text.php',{method:'post',postBody:'text_value='+text_value});
}

/*  Show me DIV   -    END*/
function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".")+1 == email.length) {  // . must not be the last character
	return false;
    }
    return true;
	}
	
	function allValidChars(email) {
	  var parsed = true;
	  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
	  for (var i=0; i < email.length; i++) {
		var letter = email.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
		  continue;
		parsed = false;
		break;
	  }
	  return parsed;
	}

function allValidUsernameChars(username){
		var parsed = true;
	  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789_";
	  for (var i=0; i < username.length; i++) {
		var letter = username.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
		  continue;
		parsed = false;
		break;
	  }
	  return parsed;
	}
function check_duplication(frm,username)
		{
			new Ajax.Updater('username_verif_div','jax/check_username_duplication.jax.php',{method:'post',evalScripts:true, postBody:'username='+username});
		}	

function AutoScroll(){
	alert(document.body.clientHeight);
	document.body.scrollLeft=0;
	document.body.scrollTop=0;
	if (1600-document.body.clientWidth>0){
		document.body.scrollLeft +=Math.round((1600-document.body.clientWidth)/2);
	}
	
	if (1000-document.body.clientHeight>0){
		document.body.scrollTop +=Math.round((1000-document.body.clientHeight)/2);
	}
	
}
