// * ============================================================= *
// * File: ipenzwc040817.js                                        *
// * Author: Mark Healey                                           *
// *         Hydro-Logic Limited                                   *
// *         http://www.hydro-logic.co.nz                          *
// * Version: 17 Aug 2004                                          *
// * Website: http://www.ipenz.org.nz/westcoast/                   *
// *                                                               *
// * (c) Hydro-Logic Limited 2004.  All rights reserved.           *
// * Visit http://www.hydro-logic.co.nz                            *
// * ============================================================= *


// * Heading 1 =================================================== *

// * Heading 2 --------------------------------------------------- *

// * Heading 3 ................................................... *

 function MM_swapImgRestore() { //v3.0
   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
 }

 function MM_preloadImages() { //v3.0
   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
 }

 function MM_findObj(n, d) { //v4.0
   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 && document.getElementById) x=document.getElementById(n); return x;
 }

 function MM_swapImage() { //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
 }

 function decodemail(addresses) {
   var decodedmail = "";
   var codearray = addresses.split(";")
   var codeOffset = 9;
   var codeIncrement = 9;
   for (i = 0; i < codearray.length; i++){
      decodedmail += String.fromCharCode(codearray[i]-(codeIncrement*i)-codeOffset);
   }
   return decodedmail;
 }

 function queryemail(firstname, surname, mailaddress) {
   var mailsubject = "IPENZ%20West%20Coast%20Branch:%20Website%20Enquiry";
   writemail(firstname, surname, mailsubject, mailaddress);
 }

 function writemail(firstname, surname, mailsubject, mailaddress) {
   var realname = firstname + " " + surname;
   document.write("<a href=\"" + "mail" + "to:" + decodemail(mailaddress) + "?subject=" + mailsubject + "&amp;cc=%20&amp;bcc=%20&amp;body=" + firstname +"\" title=\"Email " + realname + "\" onMouseOver=\"(window.status='Email " + realname + "'); return true\" onMouseOut=\"(window.status=''); return true\">" + realname + "</a>");
 }

 function committeemail(mailgroup, tolist, cclist, bcclist) {
   var sendertest=retrieveCookie("WhoAmI");
   if (sendertest == null)
   {
     var sendername="Your Name";
     var senderposition="Your Position";
   }
   else
   {
     var sender=sendertest.split(", ");
     var sendername=sender[0];
     var senderposition=sender[1];
   }
   
   var tonum = 0;
   if (tolist != " ")
   {
     tonum += tolist.split(";").length;
   }
   if (cclist != " ")
   {
     tonum += cclist.split(";").length;
   }
   if (bcclist != " ")
   {
     tonum += bcclist.split(";").length;
   }

   var mailbody = "Hi all%0d%0a%0d%0a%0d%0a%0d%0aFurther information, a calendar appointment and automatic recording of CPD for this event can be found here: %0d%0ahttp://www.ipenz.org.nz/westcoast/events.htm#%0d%0a%0d%0aRegards%0d%0a%0d%0a" + sendername + "%0d%0a" + senderposition + "%0d%0aIPENZ West Coast Branch%0d%0awww.ipenz.org.nz/westcoast/%0d%0a%0d%0aYou have received this email because you are one of " + tonum + " people on the IPENZ West Coast Branch '" + mailgroup + "' email distribution list.  If you don't want to receive these emails please let us know (by replying to this email) and we will remove your address from the list.";
   document.write("<a href=\"" + "mail" + "to:" + tolist + "?subject=IPENZ West Coast " + mailgroup + ": &amp;cc=" + cclist + "&amp;bcc=" + bcclist + "&amp;body=" + mailbody + "\" title=\"Email " + mailgroup + "\" onMouseOver=\"(window.status='Email " + mailgroup + "'); return true\" onMouseOut=\"(window.status=''); return true\">" + mailgroup + "</a>");
 }

 function enzcopyright(document)
 {
    if(confirm("The attached profile is copyright to e.nz magazine. For permission to reprint or host on your website, please contact " + decodemail("110;118;132;152;156;168;127;177;193;191;209;230;163;237;249;247;199;272;293") + ".")) {
        window.open(document, "pdf");
    } else {
        alert("You have chosen not to download the document");
    }
    return false;
 }

 function retrieveCookie( cookieName ) {
 	/* retrieved in the format
 	cookieName4=value; cookieName3=value; cookieName2=value; cookieName1=value
 	only cookies for this domain and path will be retrieved */
 	var cookieJar = document.cookie.split( "; " );
 	for( var x = 0; x < cookieJar.length; x++ ) {
 		var oneCookie = cookieJar[x].split( "=" );
 		if( oneCookie[0] == escape( cookieName ) ) { return unescape( oneCookie[1] ); }
 	}
 	return null;
 }

 function setCookie( cookieName, cookieValue, lifeTime, path, domain, isSecure ) {
 	if( !cookieName ) { return false; }
 	if( lifeTime == "delete" ) { lifeTime = -10; } //this is in the past. Expires immediately.
 	/* This next line sets the cookie but does not overwrite other cookies.
 	syntax: cookieName=cookieValue[;expires=dataAsString[;path=pathAsString[;domain=domainAsString[;secure]]]]
 	Because of the way that document.cookie behaves, writing this here is equivalent to writing
 	document.cookie = whatIAmWritingNow + "; " + document.cookie; */
 	document.cookie = escape( cookieName ) + "=" + escape( cookieValue ) +
 		( lifeTime ? ";expires=" + ( new Date( ( new Date() ).getTime() + ( 1000 * lifeTime ) ) ).toGMTString() : "" ) +
 		( path ? ";path=" + path : "") + ( domain ? ";domain=" + domain : "") +
 		( isSecure ? ";secure" : "");
 	//check if the cookie has been set/deleted as required
 	if( lifeTime < 0 ) { if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return false; } return true; }
 	if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return true; } return false;
 }

 function IdentifyUser( cookieName, cookieValue ) {
   if (cookieValue == "delete") {
     var cookieLife = "delete"
   }
   else {
     var cookieLife = "15552000"
   }
   setCookie( cookieName, cookieValue, cookieLife );
   window.location.reload();
 }

 function ShowImage (sURL, sTitle, sWidth, sHeight) {
   var sFeatures = "channelmode=no,directories=no,fullscreen=no,height=" + sHeight + ",width=" + sWidth + ",left=0,top=0,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=yes,toolbar=no";
   var ImageWindow = window.open( '', '_blank', sFeatures, true );
   var dDate = new Date();
   var sDate = (dDate.getDate() + "/" + dDate.getMonth() + 1) + "/" + dDate.getYear();
   ImageWindow.document.write('<!doctype html public "-//w3c//dtd html 4.0 strict//en">\n');
   ImageWindow.document.write('<head>\n');
   ImageWindow.document.write(' <title>' + sTitle + '</title>\n');
   ImageWindow.document.write(' <meta http-equiv="imagetoolbar" content="no" />\n');
   ImageWindow.document.write(' <meta name="date" content="' + sDate + '" />\n');
   ImageWindow.document.write(' <style type="text/css">\n');
   ImageWindow.document.write('  body {margin:0; padding:0; line-height:0pt}\n');
   ImageWindow.document.write(' </style>\n');
   ImageWindow.document.write('</head>\n');
   ImageWindow.document.write('<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginwidth="0" marginheight="0" bgcolor="#ffffff">\n');
   ImageWindow.document.write(' <img src="' + sURL + '" alt="' + sTitle + '" title="" border="0" width="' + sWidth + '" height="' + sHeight + '">\n');
   ImageWindow.document.write('</body>\n');
   ImageWindow.document.write('</html>\n');
 }
 
 function runSlideShow(){
   if (document.all){
     document.images.SlideShow1.style.filter="blendTrans(duration=crossFadeDuration)";
     document.images.SlideShow1.filters.blendTrans.Apply();
     document.images.SlideShow2.style.filter="blendTrans(duration=crossFadeDuration)";
     document.images.SlideShow2.filters.blendTrans.Apply();
     document.images.SlideShow3.style.filter="blendTrans(duration=crossFadeDuration)";
     document.images.SlideShow3.filters.blendTrans.Apply();
   }
   document.images.SlideShow1.src = preLoad1[j].src;
   document.images.SlideShow2.src = preLoad2[j].src;
   document.images.SlideShow3.src = preLoad3[j].src;
   if (document.all){
     document.images.SlideShow1.filters.blendTrans.Play();
     document.images.SlideShow2.filters.blendTrans.Play();
     document.images.SlideShow3.filters.blendTrans.Play();
   }
   j = j + 1;
   if (j > (p1-1)) j=0;
   t = setTimeout('runSlideShow()', slideShowSpeed);
 }

 function initSlideShow(iOffset){
  j = iOffset;
 }

 function writeGetURL(sURL,aParameters){
   var iParaNum = aParameters.length;
   var GetURL = sURL;
   GetURL += "?" + aParameters[0];
   GetURL += "=" + escape(aParameters[1]);
   for (i = 2; i < (iParaNum - 1); i+=2){
     GetURL += "&" + aParameters[i];
     GetURL += "=" + escape(aParameters[i + 1]);
   };
   return GetURL;
 }

 function submitCPD (sActivity, sDates, sYear, sVerification, sDescription, sHours, sWeighting, sCompetencies){
   var aParameters = new Array();
   aParameters[0] = 'Activity';
   aParameters[1] = sActivity;
   aParameters[2] = 'dates';
   aParameters[3] = sDates;
   aParameters[4] = 'foryear';
   aParameters[5] = sYear;
   aParameters[6] = 'verification';
   aParameters[7] = sVerification;
   aParameters[8] = 'description';
   aParameters[9] = sDescription;
   aParameters[10] = 'hours';
   aParameters[11] = sHours;
   aParameters[12] = 'weighting';
   aParameters[13] = sWeighting;
   aParameters[14] = 'competencies';
   aParameters[15] = sCompetencies;
   window.location = writeGetURL('http://www.ipenz.org.nz/ipenz/members/cpdsummary/checkinput.cfm',aParameters);
 }