// Image Object Functions
// The following code is copyright Robert Fisher, 25th January 2008 (www.fisher-solutions.co.uk)
// you may copy this code but please keep the copyright notice as well

function popup_window(url,width,height,params)
{

  // This function will open a new window with the supplied parameters...
  var w = width;
  var h = height;
  window.open(url,"_blank",params+", width="+w+", height="+h);

  //window.open(url,"_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400");
}

function getuniquestring() {
 // This function returns a string of the number of milliseconds since 01/01/1970.
 // I use this value to create a permanently unique value for anti-caching links...
 
  var tmpdate = new Date();
  var tmpstr = tmpdate.getTime() + '';
  
  return tmpstr;
}

function getOpacity(objId) {

  if (document.getElementById) {
	obj = document.getElementById(objId);
	var retval = 0;//0.99999;
	if (obj) {
	  if(obj.style){
	    if (obj.style.opacity) {
	      retval = obj.style.opacity;
	    }
	  }
	}
  }

	retval = retval * 100;
	//alert("retval:" + retval);
	return retval;
}

function setOpacity(obj, opacity) {
  opacity = (opacity >= 100)?99.999:opacity;
  opacity = (opacity <= 0)?0:opacity;
	
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity = opacity + 4;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 1);
    }
  }
}

function fadeOut(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >= 0) {
      setOpacity(obj, opacity);
      opacity = opacity - 2;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 1);
    }
  }
}


function echeck(str) {
  //returns true for a "valid" email address and false for an invalid one.

  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
      //alert("Invalid E-mail ID")
      return false
  }

  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    //alert("Invalid E-mail ID")
    return false
  }

  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    //alert("Invalid E-mail ID")
    return false
  }

  if (str.indexOf(at,(lat+1))!=-1){
    //alert("Invalid E-mail ID")
    return false
  }

  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    //alert("Invalid E-mail ID")
    return false
  }

  if (str.indexOf(dot,(lat+2))==-1){
    //alert("Invalid E-mail ID")
    return false
  }
		
  if (str.indexOf(" ")!=-1){
    //alert("Invalid E-mail ID")
    return false
  }

  return true					
}
