/**
*DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*I did a bit of tweaking, so don't blame SmartWebby.com for the mistakes
*/

function echeck(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.lastIndexOf(dot);
		var rv = true;			

		if(lat<1||ldot-lat<4||ldot<5||lstr-ldot!=4){
			rv = false;
		}

                if (str.indexOf(" ")!=-1)
		{ 		     
                     rv = false;
		}

                if (rv==false)
                {
		     alert("We're sorry, there seems to be a problem with your email format.  Can you please re-check it?");
		}
 		return rv;					
}



function mouseover(str)
{
document.getElementById(str).style.borderLeft="thick solid #099ccf";
return true;
}

function mouseout(str)
{
document.getElementById(str).style.borderLeft="0";
return true;
}

function TestDataCheck()
{
var FirstName = document.index2.FirstName.value;
var LastName  = document.index2.LastName.value;
var email     = document.index2.email.value;

var returnval;

if ( (FirstName != '') && (LastName != '') && (email != '')) {    
    returnval = true;   
}
else
   {
   alert("Please Enter information in all required fields");      
   document.getElementById('fstNm').style.color="red";
   document.getElementById('lstNm').style.color="red";   
   document.getElementById('emailo').style.color="red";
   return false;
   }

if (echeck(email)==false)
{
    returnval = false;
}

return returnval;
}

function mouseover(str)
{
document.getElementById(str).style.borderLeft="thick solid #099ccf";
return true;
}
function mouseout(str)
{
document.getElementById(str).style.borderLeft="0";
return true;
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "d";
  else
    return results[1];
}

function adlinks( number )
{
	var ad1 = "http://www.sochomebusiness.com/emmanolan";
	var ad2 = "http://www.nomesspets.blogspot.com/";
	var ad3 = "http://www.eonenvironmental.com/";
	var ad4 = "http://www.mediatemple.net/go/order/?refdom=network2market.com/";
	var ad5 = "http://www.network2market.com/shop";
		switch(number)
		{
		case 1:
		  return ad1;
		case 2:
		  return ad2;
		case 3:
		  return ad3;
		case 4:
		  return ad4;
		case 5:
		  return ad5;
		default:
		  return "http://www.network2market.com";
		}
}		
function checkLen(x,y)
{
if (y.length==x.maxLength)
  {
  var next=x.tabIndex;
  if (next<document.getElementById("myForm").length)
    {
    document.getElementById("myForm").elements[next].focus();
    }
  }
}

function vidsel ()
{
	var myVideo=new Array(); // regular array (add an optional integer
	myVideo[0]="videos/n2msample.f4v";       // argument to control array's size)
	myVideo[1]="videos/building.f4v";	
	
	return myVideo[Math.floor(Math.random()*2)];
}

function imgload (dook)
{
	dook.width='100';		
}
function changeSize (picture,testindex)
{
	
	picture.width=(picture.width*5)%600;
	switch(picture.width)
		{
		case 500:
			document.getElementById('textdata'+testindex).style.display='table-cell';
			break;
		case 100:
			document.getElementById('textdata'+testindex).style.display='none';
			break;
		default:
			return;
		}
}

function test (textindex)
{
	var imageDescription=new Array(); // regular array (add an optional integer
	imageDescription[1]="The hills around Skardu";       // argument to control array's size)
	imageDescription[2]="The river Indus, running very low";
	imageDescription[3]="View of the restaruant at the Shangrila Resort";       // argument to control array's size)
	imageDescription[4]="Clear lake, mountains of Pakistan";
	imageDescription[5]="Deosai Plains, Lake";       // argument to control array's size)
	imageDescription[6]="More pics from Deosai";
	imageDescription[7]="Creek in the hills";       // argument to control array's size)
	imageDescription[8]="Famous looking mountain peak";
	imageDescription[9]="Helicopter";       // argument to control array's size)
	imageDescription[10]="Valley with lots of colors";
	imageDescription[11]="Another famous looking peak";       // argument to control array's size)
	
	document.write(textindex+' ');
	document.write(imageDescription[textindex]);
	
}
function test2 (passednum)
{	
	passednum=passednum-100;
	document.write('<table><tr><td><a name="C'+passednum+'"><a href="demos/n2mpicturedemo.php#C'+passednum+'"><img onload="imgload(this)" onclick="changeSize(this,'+passednum+')" src="images/n2mdemo'+passednum+'.jpg"></img></a></a></td></tr><tr><td id="textdata'+passednum+'" style="display:none"><script>test("'+passednum+'");</script></td></tr></table>');
}
function writeads()
{
	document.getElementById('ads').innerHTML='<li class="linklist" id="ad1"><a href="'+adlinks(1)+'" target="_blank"></a></li><li class="linklist" id="ad2"><a href="'+adlinks(2)+'" target="_blank"></a></li><li class="linklist" id="ad3"><a href="'+adlinks(3)+'" target="_blank"></a></li><li class="linklist" id="ad4"><a href="'+adlinks(4)+'" target="_blank"></a></li><li class="linklist" id="ad5"><a href="'+adlinks(5)+'" target="_blank"></a><li>';
}