﻿

/*
**
** Global Functions for Trampled Underfoot
** $VER: nec.js 1.0 (08.09.2009)
**
**
** This file is part of the ImpleoCMS project.
**
** (C) 2008-2009 Daniel J. Allsopp
** All rights reserved
**
** See the documentation for conditions.
**
*/

var blogpage = 1;
var testpage = 1;
var testopen = 0;

/*
**
**	Slideshow Functions
**  Created 23.04.2009
**
*/

function StartShow(id, first, last, delay, random, start)
    {
        /* random start */
        if(random != false) start = Math.ceil(Math.random() * last);

        /* true start position */
        if(start == 1)
            start = last;
        else
            start = start - 1;

        /* start playback */
        setTimeout(PlayShow(id, start, first, last, delay), 0);
    }
                                                
function PlayShow(name, frame, first, last, delay)
	{
		return (function()
			{
				Effect.Fade(name + '_' + frame);
				if (frame == last) { frame = first; } else { frame = frame + 1; }
				setTimeout("Effect.Appear('" + name + "_" + frame + "');", 250);
				setTimeout(PlayShow(name, frame, first, last, delay), delay + 250);
			})
	}

/*
**
**	Helper Functions
**  Created 23.04.2009
**
*/

function MouseOver(id, colour)
    {
		id.style.color = colour;
		id.style.cursor = 'Pointer';
    }

function MouseOut(id, colour)
    {
        id.style.color = colour;
    }

function Pointer(id)
    {
        id.style.cursor = 'Pointer';
    }

function ActiveField(id)
	{
		id.style.backgroundColor = '#ffffff';
	}
	
function InactiveField(id)
	{
		id.style.backgroundColor = '#ebeae9';
	}    
    
/*
**
**	GraphicMail Functionality
**  Created 23.04.2009
**
*/

function testInput()
   {
      var Email =  new String(document.forms.inputForm.Email.value); 
      var Correct = true; 
      
      CharCount=1; 
      strLength=Email.length; 
      
      while ((CharCount < strLength) && (Email.charAt(CharCount) != '@')) 
         { 
	         CharCount++ 
         }
         
      if((CharCount>= strLength) || (Email.charAt(CharCount) != '@'))  
         {  
	         Correct = false; 
         } 
      else 
         { 
	         CharCount += 2; 
         } 
         
      while ((CharCount < strLength) && (Email.charAt(CharCount) != '.')) 
         { 
	         CharCount++ 
         } 
         
      if((CharCount>= strLength - 1) || (Email.charAt(CharCount) != '.')) 
         { 
	         Correct = false; 
         }
         
      if(Correct != true) alert ('Email address not valid.');

      return Correct;
   }
