function isCharsInBag (s, bag)
{
    var i;
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return(false);
    }
    return true;
}

function isValidChar(testingStr, userStr)
{
	var condition = true;

	for(counter=0; counter < testingStr.length; counter++)
	{
		if(testingStr.indexOf(userStr.charAt(counter)) == -1)
		{
			condition = false;
		}
	}

	return condition;
}
function EmailCheck(email){

		if(email.value==''){
			alert("Please Enter Email Address");
            email.focus();
            return false;
		}
		if ( !this.isCharsInBag( email.value, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._@-" ))
		{

            alert("Invalid Email Address");
            email.focus();
            return false;
		}

	if(email.value != '')
	   {
		var str=email.value;
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var sdot=str.indexOf(dot,ldot+1);

		if (str.indexOf(at)==-1){
			alert("Invalid Email Address");
            email.focus();
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert("Invalid Email Address");
            email.focus();
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Invalid Email Address");
            email.focus();
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			alert("Invalid Email Address");
            email.focus();
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Invalid Email Address");
            email.focus();
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Invalid Email Address");
            email.focus();
		    return false;
		 }
		if (str.substring(ldot+1)==''){
			alert("Invalid Email Address");
            email.focus();
		    return false;
		 }
		 if (str.substring(sdot+1)==''){
			alert("Invalid Email Address");
            email.focus();
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
			alert("Invalid Email Address");
            email.focus();
		    return false;
		 }
		 if(str.lastIndexOf(".") == str.length-1)
		 {
		 	alert("Invalid Email Address");
            email.focus();
		    return false;
		 }
	}//end of else
	return true;
}
function validateCVForm()
{
	var yname = document.frmCV.yname;
	if (yname.value == "")
	{
		alert("Please Fill the 'Your Name' field.");
		yname.focus();
		return false;
	}
	var cv = document.frmCV.cv;
	if (cv.value == "")
	{
		alert("Please Fill the 'Your CV' field.");
		cv.focus();
		return false;
	}
	else
	{
		if(!this.checkFileName(cv.value)) {
			alert("Invalid File Path/URL in 'Your CV' field.");
			cv.focus();
			return false;
		}
	}
	var comments = document.frmCV.comments;
	if (comments.value == "")
	{
		alert("Please Fill the 'Comments' field.");
		comments.focus();
		return false;
	}
	return true;
}
function checkFileName( filename )
{
	if( filename.match(/(.*)[\/\\]([^\/\\]+\.\w+)$/) && filename.match(/(:|\/)/) )
	{
		return true
	}
	else
	{
		return false;
	}
}
function CheckExtention(el) // pass Upload File object’s ClientID here
{
	var objFSO ;
	try
	{
		objFSO = new ActiveXObject("Scripting.FileSystemObject");
	}
	catch(err)
	{
		//alert(err.message);
		//alert(err.number);
	}
	var myel= document.getElementById(el);
	var file;
	var path = myel.value;
	//alert(path);
	file = objFSO.getFile(path);
	var size;
	size = file.size ; // This size will be in Bytes
	// We are converting it to KB as below
	alert("File Size is : " + file.size / 1024 +" KB");
}


function divShowhide(chkDiv)
{
	//alert("abc");

	objDiv = document.getElementById(chkDiv);

		if (objDiv.style.display == 'none')
		{
			objDiv.style.display = 'inline';
		}

		else if (objDiv.style.display == 'inline')
		{
			objDiv.style.display = 'none';
		}
}
var hWnd
function OpenNewWindow( passurl , width, height, left, top)
{
	//var x = screen.availWidth/2-200;
//	var x = (screen.availWidth-width);
//	var y = 150;

	var x = left;
	var y = top;

	enterCalled = true
	window.name = "parent"
	var url = passurl
	if( !hWnd )
	{
		//if no help window is open then open a new help window and give it focus
		hWnd = window.open(url,"popup","width=" + width + ",height=" + height +", left=" + x + ", top=" + y + ", resizable=yes,scrollbars=yes")
		hWnd.focus()
	}
	else if ( hWnd.closed )
	{
		//if no help window is open then open a new help window and give it focus
		hWnd = window.open(url,"popup","width=" + width + ",height=" + height +", left=" + x + ", top=" + y + ", resizable=yes,scrollbars=yes")
		hWnd.focus()
	}
	else
	{
		//if the help window is already open then update it and give it focus
		hWnd.location=url
		hWnd.focus()
	}
	// handle Navigator 2, which doesn't have an opener property
	if (!hWnd.opener) { hWnd.opener = window}
}
// my address finder code end  here

function ctbWnd(url)
{
	var width = screen.width;
	var height = screen.height;
	var ctbWnd = window.open(url,"ctbWnd","status=1,resizable=1,width=" + width + ",height=" + height);
	ctbWnd.moveTo(0,0);
}
function ctbWndNEW()
{
	var url = "mcgee_flickbook.html";
	var width = screen.width;
	var height = screen.height;
	//var ctbWndNEW = window.open(url,"ctbWnd","status=1,resizable=1,width=" + width + ",height=600");
	var ctbWndNEW = window.open(url,"ctbWnd","status=1,resizable=1,width=" + width + ",height=" + height);
	ctbWndNEW.moveTo(0,0);
}

/* Slide Images on Case Studies Section.*/
function increaseClicked(){
	clicked++;
	if(clicked>2){
		clicked=2;
	}
	//alert(clicked);
	return;
}
function decreaseClicked(){
	clicked--;
	if(clicked<0){
		clicked=0;
	}
	//alert(clicked);
	return;
}
function movedown()
{
	var leftMove = 0;
	if (window.moveupvar) clearTimeout(moveupvar)
	if (iens6 && parseInt(crossobj.style.left)>=(ch)) {
		myStoper[1] = -1505;
		leftMove = parseInt(crossobj.style.left)-speed;
		crossobj.style.left = leftMove +"px";
		//document.getElementById("bugTd").innerHTML += "("+leftMove+"<=" + myStoper[clicked-1] + "), ";

		if(clicked==1 && (leftMove<=myStoper[0])){
			crossobj.style.left = leftMove+20+"px";
			stopscroll();
			//document.getElementById("bugTd").innerHTML += "Done = 1 / "+parseInt(clicked)+"-"+(parseInt(crossobj.style.left)-speed)+"-" + myStoper[0] + ", ";
			return;
		}
	}
	else{
		if(ch>=myStoper[1]) {
			myStoper[1] = -1000;
			//document.getElementById("bugTd").innerHTML += ch+" >= "+myStoper[1];
			crossobj.style.left = parseInt(crossobj.style.left)-40+"px";
			stopscroll();
		}
		return;
	}
	movedownvar=setTimeout("movedown()",10)
}

function moveup()
{
	var rightMove = 0;
	if (window.movedownvar) clearTimeout(movedownvar)
	if (iens6&&parseInt(crossobj.style.left)<0){
		rightMove = parseInt(crossobj.style.left)+speed;
		crossobj.style.left = rightMove+"px";
		//document.getElementById("bugTd").innerHTML += "("+ rightMove +">"+myStoper[0]+"), ";
		if(clicked==1 && (rightMove>myStoper[0])){
			crossobj.style.left = rightMove+10+"px";
			stopscroll();
			return;
		}
	}
	else if (ns4&&crossobj.left<=0){
		crossobj.left+=speed
	}
	else
	{
		if(parseInt(crossobj.style.left)>0){
			//document.getElementById("bugTd").innerHTML += "("+ parseInt(crossobj.style.left)+")";
			crossobj.style.left = (parseInt(crossobj.style.left)-20)+"px";
			stopscroll();
		}
		return;
	}
	moveupvar=setTimeout("moveup()",10)
}

function stopscroll()
{
	if (window.moveupvar) clearTimeout(moveupvar)
	if (window.movedownvar) clearTimeout(movedownvar)
}

function movetop()
{
	stopscroll()
	if (iens6)
		crossobj.style.left=0+"px"
	else if (ns4)
		crossobj.left=0
}

function getcontent_height()
{
	if (iens6)
		contentheight=crossobj.offsetHeight
	else if (ns4)
		document.nscontainer.document.nscontent.visibility="show"
}

/* ************************************** */
function increaseClicked2(){
	clicked2++;
	if(clicked2>2){
		clicked2=2;
	}
	//alert(clicked);
	return;
}
function decreaseClicked2(){
	clicked2--;
	if(clicked2<0){
		clicked2=0;
	}
	//alert(clicked);
	return;
}
function movedown2()
{
	var leftMove2 = 0;
	if (window.moveupvar2) clearTimeout(moveupvar2)
	if (iens6 && parseInt(crossobj2.style.left)>=(ch2)) {
		myStoper2[1] = -1505;
		leftMove2 = parseInt(crossobj2.style.left)-speed2;
		crossobj2.style.left = leftMove2 +"px";
		//document.getElementById("bugTd").innerHTML += "("+leftMove+"<=" + myStoper[clicked-1] + "), ";

		if(clicked2==1 && (leftMove2<=myStoper2[0])){
			crossobj2.style.left = leftMove2+20+"px";
			stopscroll2();
			//document.getElementById("bugTd").innerHTML += "Done = 1 / "+parseInt(clicked)+"-"+(parseInt(crossobj.style.left)-speed)+"-" + myStoper[0] + ", ";
			return;
		}
	}
	else{
		if(ch2>=myStoper2[1]) {
			myStoper2[1] = -1000;
			//document.getElementById("bugTd").innerHTML += ch+" >= "+myStoper[1];
			crossobj2.style.left = parseInt(crossobj2.style.left)-40+"px";
			stopscroll2();
		}
		return;
	}
	movedownvar2=setTimeout("movedown2()",10)
}

function moveup2()
{
	var rightMove2 = 0;
	if (window.movedownvar2) clearTimeout(movedownvar2)
	if (iens6&&parseInt(crossobj2.style.left)<0){
		rightMove2 = parseInt(crossobj2.style.left)+speed2;
		crossobj2.style.left = rightMove2+"px";
		//document.getElementById("bugTd").innerHTML += "("+ rightMove +">"+myStoper[0]+"), ";
		if(clicked2==1 && (rightMove2>myStoper2[0])){
			crossobj2.style.left = rightMove2+10+"px";
			stopscroll2();
			return;
		}
	}
	else if (ns4&&crossobj2.left<=0){
		crossobj2.left+=speed2
	}
	else
	{
		if(parseInt(crossobj2.style.left)>0){
			//document.getElementById("bugTd").innerHTML += "("+ parseInt(crossobj.style.left)+")";
			crossobj2.style.left = (parseInt(crossobj2.style.left)-20)+"px";
			stopscroll2();
		}
		return;
	}
	moveupvar2=setTimeout("moveup2()",10)
}
function stopscroll2()
{
	if (window.moveupvar2) clearTimeout(moveupvar2)
	if (window.movedownvar2) clearTimeout(movedownvar2)
}

function movetop2()
{
	stopscroll2()
	if (iens6)
		crossobj2.style.left=0+"px"
	else if (ns4)
		crossobj2.left=0
}

function getcontent_height2()
{
	if (iens6)
		contentheight2=crossobj2.offsetHeight
	else if (ns4)
		document.nscontainer2.document.nscontent2.visibility="show"
}