function toggle(el)
{
    lyr = document.getElementById(el);
    if (lyr.style.display != 'block') { lyr.style.display = 'block'; }
    else { lyr.style.display = 'none'; }
}
function ClipBoard(id)
{
	var ccc = MM_findObj(id);
    if (document.all){
	ccc.value = ccc.innerText;
	Copied = ccc.createTextRange();
	Copied.execCommand("Copy");
    }
    else
    {
        alert('Close this box and press \'CTL-c\' to copy');
        ccc.focus();
        ccc.select();
    }
}
function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function highlight(id) {
    var field = MM_findObj(id);
	field.focus();
  	field.select();
}
function checkBeforeEmail()
{
    semail=document.emailform.email.value;
    if(semail==''||semail.indexOf('@')==-1)
    {
       alert('please enter a valid email!');
       return false;
    }
    for (var i=0;i<document.emailform.elements.length;i++)
    {
       var e = document.emailform.elements[i];
       if (e.type == 'checkbox' && e.name != 'allbox'&& !e.disabled)
       if(e.checked ==true) return true;
    }
    alert('Please select a image to email!');
    return false;
}
function checkAll()
{
    for (var i=0;i<document.myform.elements.length;i++)
    {
       var e = document.myform.elements[i];
       if (e.type == 'checkbox' && e.name != 'allbox'&& !e.disabled)
       e.checked = document.myform.allbox.checked;
    }
}
function checkAll2()
{
    for (var i=0;i<document.emailform.elements.length;i++)
    {
       var e = document.emailform.elements[i];
       if (e.type == 'checkbox' && e.name != 'allbox'&& !e.disabled)
       e.checked = document.emailform.allbox.checked;
    }
}
function opConfirm(text, conf)
{
    for (var i=0;i<document.myform.elements.length;i++)
    {
       var e = document.myform.elements[i];
       if (e.type == 'checkbox' && e.name != 'allbox' && e.checked == 1 ) {
          if (conf) {
             return confirm(text);
          } else {
             return 1;
          }
       }
    }
    return false;
}

//added by alun
function getfilename( attaName )
{
	var s = attaName.lastIndexOf( '\\' );
	return attaName.substr(s+1, attaName.length - s -1);
}
function getexpirydate( nodays)
{
    var UTCstring;
    Today = new Date();
    nomilli=Date.parse(Today);
    Today.setTime(nomilli+nodays*24*60*60*1000);
    UTCstring = Today.toUTCString();
    return UTCstring;
}
function getcookie(cookiename)
{
    var cookiestring=""+document.cookie;
    var index1=cookiestring.indexOf(cookiename);
    if (index1==-1 || cookiename=="") return "";
    var index2=cookiestring.indexOf(';',index1);
    if (index2==-1) index2=cookiestring.length;
    return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(name,value,duration)
{
    duration=30;
    cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
    document.cookie=cookiestring;
}
function delcookie(name)
{
    cookiestring=name+"="+escape('')+";EXPIRES="+getexpirydate(-1);
    document.cookie=cookiestring;
}

