function popupImage(theImage) {
     //var myWindow=window.open('viewer.php?image=' + theImage,'windowRef','width=500','height=500','resizable=true');
     //if (!myWindow.opener) myWindow.opener = self;
     popUp("viewer.php?image="+theImage);
}

function redirect(direction){
     window.location=direction;
}


function popupOpinion(){
     day = new Date();
     id = day.getTime();
     eval("page"+id+" = window.open('opinion.php' , '"+ id +"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=728,height=190,left=200,top=150');");
}

function popupRefer(){
     day = new Date();
     id = day.getTime();
     eval("page"+id+" = window.open('refer.php' , '"+ id +"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=728,height=190,left=200,top=150');");
}

function popUp(URL) {
	day = new Date();
	id = day.getTime() + "asd";
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=680,height=550');");
}

function popUp(URL, width, height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,left=400,top=50,location=0,statusbar=0,menubar=0,resizable=1,width="+width+",height="+height+"');");
}

function popUp2(URL, width, height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,left=300,top=0,location=0,statusbar=0,menubar=0,resizable=1,width="+width+",height="+height+"');");
}

function getElement(id) {
     return document.getElementById ? document.getElementById(id) :
     document.all ? document.all(id) : null;
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}

}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function addBookmark(title,url) {
     if (window.sidebar) {
          window.sidebar.addPanel(title, url,"");
     } else if( document.all ) {
          window.external.AddFavorite( url, title);
     } else if( window.opera && window.print ) {
          return true;
     }
}

function validateEmail(entered) {
     apos=entered.indexOf("@");
     dotpos=entered.lastIndexOf(".");
     lastpos=entered.length-1;
     if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
          return false;
     } else {
          return true;
     }
}


/*
 * http://www.activsoftware.com/code_samples/code.cfm/CodeID/59/JavaScript/Get_Query_String_variables_in_JavaScript
 * Credit goes to Pete Freitag for this function
 */
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return false;
}

/*
 * Credits to Simon Willison for this function
 * http://simon.incutio.com/archive/2004/05/26/addLoadEvent
 */
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function getElementsByStyleClass (className) {
  var all = document.all ? document.all :
    document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
    if (all[e].className == className)
      elements[elements.length] = all[e];
  return elements;
}

function addBehavior(){


     elements = getElementsByStyleClass("imageRetaillee");
     for( var i=0; i < elements.length; i++ ){
          thewidth = elements[i].width;
          theheight = elements[i].height;
          elements[i].src = "displayPictureCropped.php?filename="+elements[i].src+"&width="+thewidth+"&height="+theheight;          
     }
     elements = getElementsByStyleClass("popupImage");
     for( var i=0; i < elements.length; i++ ){
          elements[i].target = "_top";
          day = new Date();
          id = day.getTime();
          elements[i].href = "javascript:newwin=window.open('viewer.php?image="+elements[i].href+"' , '"+ id +"', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=5,height=5,left=200,top=150');newwin.focus();";
     }



}
addLoadEvent(addBehavior);

(function(){ /*Use Object Detection to detect IE6*/ var m = document.uniqueID /*IE*/ && document.compatMode /*>=IE6*/ && !window.XMLHttpRequest /*<=IE6*/ && document.execCommand ; try{ if(!!m){ m("BackgroundImageCache", false, true) /* = IE6 only */ } }catch(oh){}; })();




