// JavaScript Document

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Matt Murphy | http://www.matts411.com/ */

function autoSelect(selectTarget) {
 	if(selectTarget != null && ((selectTarget.childNodes.length == 1
      && selectTarget.childNodes[0].nodeName == "#text") || (selectTarget.tagName == "INPUT"
      && selectTarget.type == "text"))) {
  		if(selectTarget.tagName == 'TEXTAREA' || (selectTarget.tagName == "INPUT" && selectTarget.type == "text")) {
  			 selectTarget.select();
  		} else if(window.getSelection) { // FF, Safari, Opera
   			var sel = window.getSelection();
   			var range = document.createRange();
   			range.selectNode(selectTarget.firstChild);
   			sel.removeAllRanges();
   			sel.addRange(range);
  		} else { // IE
   			document.selection.empty();
   			var range = document.body.createTextRange();
   			range.moveToElementText(selectTarget);
   			range.select();
  		}
 	}
}


function verifChampSearch(nom,emailaddress,comments,captcha) { 

if(nom.value=='') { 
	alert('Champ vide');
	nom.focus(); return false }

	
if(emailaddress.value==''){ 
	alert('Email vide');
	emailaddress.focus(); return false }

if(emailaddress.value.search(/^[_a-z0-9-]+(.[_a-z0-9-]+)*[^._-]@[a-z0-9-]+(.[a-z0-9]{2,4})*$/) == -1) { 
 	alert('Email non valide');
 	emailaddress.focus(); return false }

if(comments.value=='') { 
	alert('Champ vide');
	comments.focus(); return false }
	
if(captcha.value=='') { 
	alert('Champ vide');
	captcha.focus(); return false }

	
return true // envoie les champs
}




function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		$.post("/fonctions/rpc.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup

function fill(thisValue) {
	$('#inputString').val(thisValue);
	setTimeout("$('#suggestions').hide();", 200);
}




function setCookie(cookieName,cookieValue) {
  document.cookie = cookieName + "=" + escape(cookieValue);
}

function getCookie(cookieName) {
  var cookieDataBeg, cookieDataEnd;
  cookieDataBeg = document.cookie.indexOf(cookieName + "=");
  if (cookieDataBeg >= 0) {
    cookieDataBeg += cookieName.length + 1;
    cookieDataEnd = document.cookie.indexOf(";",cookieDataBeg);
    if (cookieDataEnd < 0) cookieDataEnd = document.cookie.length;
    return unescape(document.cookie.substring(cookieDataBeg,cookieDataEnd));
  }
  return "";
}

function checkCookie() {
  var cookData = getCookie('popUnderEI');
  if ( cookData == "" ) {
    openSiteUnder();
    setCookie('popUnderEI','true');
  }
}

function openSiteUnder() {
  var siteUnder = window.open('http://www.demooniak.com/adout.php?adid=8', 'puei', 'left=0, top=0, width=' + screen.availWidth + ', height=' + screen.availHeight + ', scrollbars=1');
  if(siteUnder) {
    siteUnder.blur();
    window.focus();
  }
}