////////////////////////////////////////////////////////////////////////////////
//Name:   mnho.js
//Date:   2005-MAR-11
//Author: Wayne Hohl	
//eMail:  whohl@techsupportservices.biz
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function login(custid)
	{
	//Security Check Part I
	if(custid.length!=8)
		{alert("Invalid Customer ID\nfor MyNewHomeOnline\n\nPlease Try Again.");
		exit;}

	//passes the custid to sql query and opens the photos page

	//2005-09-20 
	//added 'active' field for disabling customers AND active=1 

	//2006-02-12
	//removed sql= and replaced with s=
	//sql="SELECT * FROM photos WHERE custid="+custid.substr(0,4)+" ORDER BY SUBSTRING(photoid,1,8) DESC";
	//2006-11-25
	//remove s= it wasn't needed at this point
	//added screen dims as v=WxH
	window.location="photos.php?custid="+custid+"&d=1&v="+screen.width+"x"+screen.height;
	}
////////////////////////////////////////////////////////////////////////////////
function photo_sort(custid,dir)
	{
	//Sorts photos by date
	window.location="photos.php?custid="+custid+"&sort="+dir;
	}

////////////////////////////////////////////////////////////////////////////////
function photo_sort_tour(custid,dir)
	{
	//Sorts photos by date
	window.location="tour.php?custid="+custid+"&sort="+dir;
	}

////////////////////////////////////////////////////////////////////////////////
function tour_Inspect()
	{
	//traps the call to building permits during the tour
	alert("Function disabled for tour.\nThis button opens a new page to the building permits office and \nretrieves your building permit and inspections status.");
	}

////////////////////////////////////////////////////////////////////////////////
function tour_email()
	{
	//traps the call to email during the tour
	alert("Function disabled for tour.\nThis button allows you to email this photo to a friend.");
	}

////////////////////////////////////////////////////////////////////////////////
function tour_photoreq()
	{
	//traps the call to photo request during the tour
	alert("Function disabled for tour.\nThis button allows you request a specific photo\nof your home from the photographer.");
	}

////////////////////////////////////////////////////////////////////////////////
function tour_bldr_web()
	{
	//traps the call to builder website during the tour
	alert("Function disabled for tour.\nThis button opens a new page to the builder's website.");
	}

////////////////////////////////////////////////////////////////////////////////
function tour_bldr_email()
	{
	//traps the call to builder email during the tour
	alert("Function disabled for tour.\nThis button creates a new email message to the builder.");
	}

////////////////////////////////////////////////////////////////////////////////
function byid(id)
	{alert(id);}

////////////////////////////////////////////////////////////////////////////////
function byname(name)
	{alert(name);}

////////////////////////////////////////////////////////////////////////////////
function datechange(cust,latest)
	//selects the month for displaying thumbnails, 
	//default to latest minus 30 days
	{
//	alert(cust+", "+latest+", "+document.chgdt.dtrng.value+", "+document.chgdt.dtrng.selectedIndex);
	//2006-02-12
	//removed sql= and replaced with s=

	switch(document.chgdt.dtrng.value)
		{
		case ''://separator
		break;

		case '0'://All Dates
		window.location="photos.php?custid="+cust+"&d=0&v="+screen.width+"x"+screen.height;
		break;		

		case '30'://Most recent 30 days
		window.location="photos.php?custid="+cust+"&d=1&v="+screen.width+"x"+screen.height;
		break;

		default://Selected yyyymm
		window.location="photos.php?custid="+cust+"&d="+document.chgdt.dtrng.selectedIndex+"&ym="+document.chgdt.dtrng.value+"&v="+screen.width+"x"+screen.height;
		break;
		}
	}

////////////////////////////////////////////////////////////////////////////////
function datechangeTOUR(cust,latest,job,sess)
	// selects the date range for displaying thumbnails, 
	// default to most recent 30 days
	{
	// garbage string
	grbg=Math.random();
	grbg=Math.round(grbg*10000);
	while (grbg<1000)//>
		{		
		grbg=Math.random();
		grbg=Math.round(grbg*10000);
		}

	hidx=document.top.homes.selectedIndex;
	hval=(document.top.homes.value*2);
	didx=document.chgdt.dtrng.selectedIndex;

	if(didx >= 20)
		{didx=didx-20;
		didx="b"+didx;}

	if(didx >= 10)
		{didx=didx-10;
		didx="a"+didx;}
	
	if(document.chgdt.dtrng.selectedIndex!=2)
		{
		dval=(document.chgdt.dtrng.value*2);
//		alert("tour2.php?arg="+didx+hidx+grbg+hval+dval+"&s="+sess+"&v="+screen.width+"x"+screen.height);
		window.location="tour2.php?arg="+didx+hidx+grbg+hval+dval+"&s="+sess+"&v="+screen.width+"x"+screen.height;
		}
	}

////////////////////////////////////////////////////////////////////////////////
function homechangeTOUR(sess)
	{
	// selects the jobsite (customer) to use in the tour

	// garbage string, used to disguise numbers in &arg=
	grbg=Math.random();
	grbg=Math.round(grbg*10000);
	while (grbg<1000)//>
		{		
		grbg=Math.random();
		grbg=Math.round(grbg*10000);
		}

	hidx=document.top.homes.selectedIndex;
	hval=(document.top.homes.value*2);
	didx="1";
	dval="60";
//alert("tour2.php?arg="+didx+hidx+grbg+hval+dval+"&s="+sess+"&v="+screen.width+"x"+screen.height);
	window.location="tour2.php?arg="+didx+hidx+grbg+hval+dval+"&s="+sess+"&v="+screen.width+"x"+screen.height;
	}

////////////////////////////////////////////////////////////////////////////////
function showweather()
	{
	var WeatherWindow=window.open('weather.php', '', 'height=400,width=400,top=25,left=400,scrollbars');
	}	

////////////////////////////////////////////////////////////////////////////////
function changeWeatherDates(Wopt)
	{
	switch (Wopt)
		{
		case 0: 
			//Last 30 days
			sql="SELECT DATE_FORMAT(date,'%b %e, %Y')AS dt, remarks FROM weather WHERE date >= DATE_SUB( CURDATE( ) , INTERVAL 29 DAY )ORDER BY date DESC";
			Wmsg="Last 30 Days";
			break; 

		case 1: 
			//Last 12 months
			sql="SELECT DATE_FORMAT(date,'%b %e, %Y')AS dt, remarks FROM weather WHERE date >= DATE_SUB( CURDATE( ) , INTERVAL 12 MONTH) ORDER BY date DESC";
			Wmsg="Last 12 Months";
			break; 

		case 2: 
			//All dates
			sql="SELECT DATE_FORMAT(date,'%b %e, %Y')AS dt, remarks FROM weather ORDER BY date DESC";
			Wmsg="All Dates";
			break; 
		}

		window.location="weather.php?sql="+sql;
	}


////////////////////////////////////////////////////////////////////////////////
function showprogress(cust,pc)
	{var wthrWindow=window.open("progressv1.php?p="+pc+"&c="+cust, "", "scrollbars,height=400,width=400,top=25,left=400");}
//	{var wthrWindow=window.open("progressv1.php?c="+cust, "", "scrollbars,height=400,width=400,top=25,left=400");}

////////////////////////////////////////////////////////////////////////////////
function changeto(id)
	{document.getElementById(id).style.borderColor='black';
	document.getElementById(id).style.backgroundColor='white';}

////////////////////////////////////////////////////////////////////////////////
function changeback(id)
	{document.getElementById(id).style.borderColor='white';
	document.getElementById(id).style.backgroundColor='e1e1e1';}

////////////////////////////////////////////////////////////////////////////////
	function check4min()
		{
		if(
		   (document.signup.y_name.value=="") || (document.signup.y_phone.value=="")||
		   (document.signup.y_addr.value!=="" && document.signup.y_addr.value==document.signup.y_city.value)||
		   (document.signup.y_st.value=="None")||
		   (document.signup.y_zip.value=="None")||
		   (document.signup.y_phone.value=="None")||
		   (document.signup.b_addr.value!=="" && document.signup.b_addr.value==document.signup.b_city.value)||
		   (document.signup.b_st.value=="None")||
		   (document.signup.b_zip.value=="None")||
		   (document.signup.b_bldr.value=="None")
		  )
			{alert("There is a problem submitting your information.\nYou must include your name and phone number.");}
		else
			{document.signup.submit();}
		}
////////////////////////////////////////////////////////////////////////////////
	function expWinBldgPrmt(website) 
		{
		var windowprops = 'width=100,height=100,scrollbars=yes,status=yes,resizable=yes'
		var heightspeed = 4; // vertical scrolling speed (higher = slower)
		var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
		var leftdist = 10;    // distance to left edge of window
		var topdist = 10;     // distance to top edge of window

		if (window.resizeTo&&navigator.userAgent.indexOf('Opera')==-1) 
			{
			var winwidth = window.screen.availWidth - leftdist;
			var winheight = window.screen.availHeight - topdist;
			var sizer = window.open('','','left=' + leftdist + ',top=' + topdist +','+ windowprops);
				for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
				sizer.resizeTo('1', sizeheight);
				for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
					sizer.resizeTo(sizewidth, sizeheight);
					sizer.location = website;
			}
		else
			window.open(website,'BldgOffWin');
		}

////////////////////////////////////////////////////////////////////////////////
	function expWinWthr(website) 
		{
		var windowprops = 'height=100,width=100,scrollbars'
		var heightspeed = 4; // scrolling speed (higher = slower)
		var widthspeed = 7; // scrolling speed (higher = slower)
		var leftdist = window.screen.availWidth-425;
		var topdist = 25;     

		if (window.resizeTo&&navigator.userAgent.indexOf('Opera')==-1) 
			{
			var winwidth = window.screen.availWidth - leftdist;
			var winheight = window.screen.availHeight - topdist;
			var sizer = window.open('','','left=' + leftdist + ',top=' + topdist +','+ windowprops);
			for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
				sizer.resizeTo('1', sizeheight);
				for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
					sizer.resizeTo(sizewidth, sizeheight);
					sizer.location = website;
			}
		else
			window.open(website,'WthrWin');
		}

////////////////////////////////////////////////////////////////////////////////
	function expWinPrgs(website, cust, prg) 
		{
		var windowprops = 'height=100,width=100,scrollbars'
		var heightspeed = 5; // scrolling speed (higher = slower)
		var widthspeed = 7; // scrolling speed (higher = slower)
		var leftdist = window.screen.availWidth-425;
		var topdist = 25;     

		if (window.resizeTo&&navigator.userAgent.indexOf('Opera')==-1) 
			{
			var winwidth = window.screen.availWidth - leftdist;
			var winheight = window.screen.availHeight - topdist;
			var sizer = window.open('','','left=' + leftdist + ',top=' + topdist +','+ windowprops);
			for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
				sizer.resizeTo('1', sizeheight);
					for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
					sizer.resizeTo(sizewidth, sizeheight);
					sizer.location = website+"?c="+cust+"&p="+prg;
			}
		else
			window.open(website+"?c="+cust+"&p="+prg,'WthrWin');
		}

////////////////////////////////////////////////////////////////////////////////
	function expWinLocalLinks(website) 
		{
		var windowprops = 'width=100, height=100, scrollbars=yes'
		var heightspeed = 4; // vertical scrolling speed (higher = slower)
		var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
		var leftdist = (window.screen.availWidth/2)-100;//window.screen.availWidth-425;
		var topdist = 25;     
	//	var leftdist = (window.screen.availWidth/2)-100;    // distance to left edge of window
	//	var topdist = (window.screen.availHeight/2)-100;     // distance to top edge of window

		if (window.resizeTo&&navigator.userAgent.indexOf('Opera')==-1) 
			{
			var winwidth = window.screen.availWidth - leftdist;
			var winheight = window.screen.availHeight - topdist;
			var sizer = window.open('','','left=' + leftdist + ', top=' + topdist +', '+ windowprops);
			for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
				sizer.resizeTo('1', sizeheight);
				for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
					sizer.resizeTo(sizewidth, sizeheight);
					sizer.location = website;
			}
		else
			window.open(website,'LocalLinksWin');
		}

////////////////////////////////////////////////////////////////////////////////
	function expWinFuelPrcs(website) 
		{
		var windowprops = 'width=100,height=100,scrollbars=yes,status=yes,resizable=yes'
		var heightspeed = 4; // vertical scrolling speed (higher = slower)
		var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
		var leftdist =360	// distance to left edge of window
		if(screen.width==800)
			{leftdist = 140;}    
		var topdist = 10;     // distance to top edge of window
	
		if (window.resizeTo&&navigator.userAgent.indexOf('Opera')==-1) 
			{
			var winwidth = window.screen.availWidth - leftdist;
			var winheight = window.screen.availHeight - topdist;
			var sizer = window.open('','','left=' + leftdist + ',top=' + topdist +','+ windowprops);
			for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
				sizer.resizeTo('1', sizeheight);
				for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
					sizer.resizeTo(sizewidth, sizeheight);
					sizer.location = website;
			}
		else
			window.open(website,'FuelWin');
		}

////////////////////////////////////////////////////////////////////////////////
	function expWinHelp(addr) 
		{
//alert(addr);
		var windowprops = 'height=100,width=100,scrollbars'
		var heightspeed = 4; // scrolling speed (higher = slower)
		var widthspeed = 7; // scrolling speed (higher = slower)
		var leftdist = window.screen.availWidth-425;
		var topdist = 25;     

		if (window.resizeTo&&navigator.userAgent.indexOf('Opera')==-1) 
			{
			var winwidth = window.screen.availWidth - leftdist;
			var winheight = window.screen.availHeight - topdist;
			var sizer = window.open('','','left=' + leftdist + ',top=' + topdist +','+ windowprops);
			for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
				sizer.resizeTo('1', sizeheight);
				for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
					sizer.resizeTo(sizewidth, sizeheight);
					sizer.location = addr;
			}
		else
			window.open(addr,'HelpWin');
		}

