function emailValidate(textStr){
	var chk      = true;
	if(textStr.indexOf("@") == -1) chk = false;
	if(textStr.substring(0,textStr.indexOf("@")).length == 0) chk = false;
	if(textStr.substring(textStr.indexOf("@")).lastIndexOf(".") == -1) chk = false;
	if(textStr.substring(textStr.lastIndexOf(".")+1).length < 2 
		|| textStr.substring(textStr.lastIndexOf(".")+1).length > 3) chk = false;
	return(chk);
}

function man_compare(pic_id, w, h) {
		
	manh_cm = 183;
	manh_px = 77;
	ratio = manh_px/manh_cm;
	if (pic_id == 0) {
		//new Effect.Morph('pictureframe', {style: {width: '0px',  height: '0px'}, duration: 0.2, queue: 'front'});
		$('picturedescr').setStyle('display: none;');
	} else {
		w = Math.round(w*ratio); 
		h = Math.round(h*ratio);
		new Effect.Morph('pictureframe', {style: {width: w+'px',  height: h+'px'}, duration: 0.2, queue: 'end'});
		//$('pictureframe').setStyle({ width: w+'px',  height: h+'px'});
		$('picturedescr').innerHTML = $('pictureinfo'+pic_id).innerHTML;
		new Effect.Appear('picturedescr', {duration: 0.2});
	}
}

function add_favorite(userid, pic_id, loaddiv) {
	if (!userid) {
		Modalbox.show('content/login.inc.php', {title: this.title, width: 600});
	} else {
		new Ajax.Request('core/ajax.myartcompaz.php', {
			parameters: {'action': 'addpic', 'pic_id' : pic_id}, 
			method: 'post',
			encoding: 'ISO-8859-1',
			onComplete: function() {
				$(loaddiv).removeClassName('ajaxloading');
				Modalbox.show('<h3>Billedet er tilføjet dine favoritter</h3><a href="index.php?p=mitartcompaz">Gå til din favoritliste</a><br><br><a href="#" onclick="Modalbox.hide(); return false;">Tilbage</a>', 
					{title: this.title, width: 300});
			}
		});
	}
}

function remove_favorite(pic_id, loaddiv, el_remove) {
	new Ajax.Request('core/ajax.myartcompaz.php', {
		parameters: {'action': 'removepic', 'pic_id' : pic_id}, 
		method: 'post',
		encoding: 'ISO-8859-1',
		onComplete: function() {
			$(loaddiv).removeClassName('ajaxloading');
			Effect.Fade(el_remove);
		}
	});
}

// Used for pictureinfo block
function scrolldetect() {
	var top = Math.abs($('outerdiv').viewportOffset().top);
	if (top < pictureinfo_top) {
		top = pictureinfo_top;
	}
	new Effect.Morph('pictureinfo', {style: {"margin-top": top +"px"}, duration: 0.2});
	//$('pictureinfo').setStyle("margin-top: "+ top +"px");
	setTimeout("scrolldetect();",250);
}