// JavaScript Document

var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;
var noNm;
var newNm;
var	iStart = 1;
var	nStart = 1;
var	iEnd = 30;
var iPage = 4
var	nEnd = nStart + iPage - 1;
var iRight = true;
// open hidden layer
function mopen(id, noNm)
{	
	// cancel close timer
	mcancelclosetime();
	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	if(this.noNm) this.noNm.className = "";
	// get new layer and show it
	this.noNm = noNm;
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
	noNm.className = "selected";
}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	if(this.noNm) this.noNm.className = "";
	if(newNm) document.getElementById(newNm).className = "selected";
}
// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}
// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
// close layer when click-out
document.onclick = mclose; 

function moveLeft()
{
	if(nStart > iStart)
	{
		nStart--;
		nEnd--;
	}
	changeImage();
}
function moveRight()
{
	
	if(nStart <= iEnd - iPage)
	{
		nStart++;
		nEnd++;
	}
	changeImage();
}
function changeImage()
{
	document.getElementById("mnuList").innerHTML = '';
	for(i=nStart;i<=nEnd;i++)
	{
		document.getElementById("mnuList").innerHTML += '<a href="javascript:void(0)" onclick="selectImage(' + i + ')"><img src="images/thumb_' + i + '.jpg" alt="Thumb' + i + '" border="0" class="borderImage" /></a>&nbsp;';
	}	
}
function selectImage(n)
{
	document.getElementById("project").src="images/project_" + n + ".jpg";
}
function Validate(nForm)
{
	return frmValidate(nForm);
}
function display()
{
	if(nEnd == iEnd)
	{
		iRight = false;
	}
	else if(nStart == iStart)
	{
		iRight = true;
	}
	if(iRight)
	{
		moveRight();
	}
	else
	{
		moveLeft();
	}
	setInterval("display()",5000);
}


<!--hide this script from non-javascript-enabled browsers

var DayNames= new Array("Mon","Tue","Wed","Thu","Fri","Sat","Sun");

/******************************
** Common Javascript routines
** c.Saravanan : July 2008
*******************************/

function isblank(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

// validate an email address
function isValidEmail(e)
{
	// assume an email address cannot start with an @ or white space, but it
	// must contain the @ character followed by groups of alphanumerics and '-'
	// followed by the dot character '.'
	// It must end with 2 or 3 alphanumerics.
	//
	var result="";
	//var alnum="a-zA-Z0-9";
	//exp="^[^@\\s]+@(["+alnum+"+\\-]+\\.)+["+alnum+"]["+alnum+"]["+alnum+"]?$";
	exp="^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$";
	emailregexp = new RegExp(exp);

	result = e.match(emailregexp);
	if (result != null)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function isValidNumber(numval)
{
	if (numval==""){return false;}
	var myRegExp = new RegExp("^[/+|/-]?[0-9]*[/.]?[0-9]*$");
	return myRegExp.test(numval);
}

// This is the function that performs form verification.  It will be invoked
// from the onSubmit() event handler.  The handler should return whatever
// value this function returns.
function ReadableName(s)
{
	var formatted = "";
	var c = "";
	var wStart = true;
    for(var i = 0; i < s.length; i++)
    {
        c = s.charAt(i);
        if (c == "_"){c=" ";}
        if (wStart==true){formatted=formatted+c.toUpperCase();wStart=false;}
        else {formatted=formatted+c.toLowerCase();}
        if (c == " "){wStart=true;}
    }
    return formatted;
}

function ucFirst(s)
{
	var c = s.charAt(0);

	if (parseInt(s.length)==1){
		return c.toUpperCase();
	}
	else
	{
		return c.toUpperCase() + s.slice(1).toLowerCase();
	}
}

function frmValidateCommon(f)
{
    var msg;
    var empty_fields = "";
    var errors = "";
    var mylen = parseInt(f.length);
    var errOne = false;

    // Loop through the elements of the form, looking for all
    // text and textarea elements that don't have an "optional" property
    // defined.  Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // then verify that they are numbers and that they are in the right range.
    // Put together error messages for fields that are wrong.
    for(var i = 0; i < mylen; i++) {
        var e = f.elements[i];

        if (((e.type == "text") || (e.type == "textarea") || (e.type == "file")) && !e.optional && !e.opNumeric)
        {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value))
            {
                empty_fields += "\n          " + ReadableName(e.name);
                if (!errOne)
                {
					errOne=true;e.focus();
				}
                continue;
            }
        }

	    // now validate email addresses
	    if (e.aname) {
			if ((e.value == null) || (e.value == "") || isblank(e.value)) continue;
			if (!isValidName(e.value)) {
				errors += "\n- The value in field " +ReadableName(e.name)+" does not appear to be a valid name\n"
				if (!errOne){errOne=true;e.focus();e.select();}
			}
		}

	    // now validate email addresses
	    if (e.email) {
			if ((e.value == null) || (e.value == "") || isblank(e.value)) continue;
			if (!isValidEmail(e.value)) {
				errors += "\n- The value in field " +ReadableName(e.name)+" does not appear to be a valid email address\n"
				if (!errOne){errOne=true;e.focus();e.select();}
			}
		}
        if (e.opNumeric)
        {
			if ((e.value == null) || (e.value == "") || isblank(e.value)) continue;
			var v = parseFloat(e.value);
			if (!isblank(e.value) && !isValidNumber(e.value))
			{
				errors += "\n- The field " + ucFirst(e.name) + " must be a number";
				if (!errOne){errOne=true;e.focus();e.select();}
            }
        }
        // Now check for fields that are supposed to be numeric.
        if (e.numeric || (e.min != null) || (e.max != null))
        {
			if ((e.value == null) || (e.value == "") || isblank(e.value)) continue;
			var v = parseFloat(e.value);
			if (isNaN(v) || !isValidNumber(e.value) || ((e.min != null) && (v < e.min)) || ((e.max != null) && (v > e.max)))
			{
				if (!errOne){errOne=true;e.focus();e.select();}
				errors += "\n- The field " + ucFirst(e.name) + " must be a number";
				if (e.min != null)
					errors += " that is greater than " + e.min;
				if (e.max != null && e.min != null)
					errors += " and less than " + e.max;
				else if (e.max != null)
					errors += " that is less than " + e.max;
				errors += ".\n";
            }
        }
    }

    // Now, if there were any errors, then display the messages, and
    // return true to prevent the form from being submitted.  Otherwise
    // return false
    if (!empty_fields && !errors) return true;

    msg  = "Sorry, but we cannot process your request because of the\n";
    msg += "following error(s). Please correct the problem and try again\n";

    if (empty_fields) {
        msg += "\n- The following fields are mandatory:"
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}

function isValidName(numval)
{
	if (numval==""){return false;}
	var myRegExp = new RegExp(/^[\a-zA-Z .]*[a-zA-Z]+$/);
	return myRegExp.test(numval);
}

// stop hiding -->
function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
} 

