﻿test=0;
var mainTest=1;

function setCookie(posStr)
{
	var expiry = new Date();
	expiry.setTime(expiry.getTime() + (365*24*60*60*1000));
	document.cookie="uid="+posStr+";"+"expires="+expiry.toGMTString()+";path=/";
}

function cookieKill()
{
	var tempCook=unescape(document.cookie);
	var expiry = new Date();
	//expiry.setTime(expiry.getTime() -1);
	expiry.setTime(expiry.getTime() +(5*1000));
	document.cookie=tempCook+";"+"expires="+expiry.toGMTString()+";path=/";
}

function saveCookie()
{
	if (document.cookie)
	{
		var tempCook=unescape(document.cookie);
		var expiry = new Date();
		//expiry.setTime(expiry.getTime() -1);
		expiry.setTime(expiry.getTime() + (365*24*60*60*1000));
		document.cookie=tempCook+";"+"expires="+expiry.toGMTString()+";path=/";
	}
}

function checkCookie()
{
	if (document.cookie)
	{
		var cookDat=(document.cookie).split('=');
					
		var dat=cookDat[1];
					
		var cookArr=dat.split(':');
		var mmpU=cookArr[0];
		var sid=cookArr[1];
		var pg=cookArr[2];
		parent.contentFrame.location=pg;
		mainTest=0;
	}
	else
	{
		mainTest=1;
	}
}

function setAdd()
{
	var part1="orderdesk";
	var part2="@";
	var part3="mmpmedford";
	var part4=".com";
	
	document.getElementById('contactUs').href="mailto:"+part1+part2+part3+part4+"?Subject=Web Contact";
}

function timeSticker(theForm)
{
	now = new Date();
	myTime=(now.getHours()*3600)+(now.getMinutes()*60)+now.getSeconds();
	theForm.timeCheck.value=myTime;
	
}


function getSet (where)
{
	//alert('you suck');
	theBrowser=navigator.appName;
	navVers=navigator.appVersion;
	getVer=navVers.split(" ");
	theVers=getVer[3];
	theVers=parseInt(theVers);
	var doIt;
	
	if (typeof dontDraw == "undefined")
	{
		if( typeof( window.innerWidth ) == 'number' )
		{
			//Non-IE
			theW = window.innerWidth;
			theH = window.innerHeight;
			isWin=false;
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
			//IE 6+ in 'standards compliant mode'
			theW = document.documentElement.clientWidth;
			theH = document.documentElement.clientHeight;
	
			isWin=true;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		{
			//IE 4 compatible
			theW = document.body.clientWidth;
			theH = document.body.clientHeight;
			isWin=true;
		}
		
		var contain=document.getElementById(where);
		if (where=="cont")
		{
			//alert('what');
			//var contain=document.getElementById('cont');
			//alert('here');
			var cH=contain.offsetHeight;
			var cT=Math.round((theH-cH)/3);
			//alert(theH);
			contain.style['top']=cT+"px";
		}
		else if (where == "formCont")
		{
			var cL=Math.round((theW-800)/2);
			
			contain.style['left']=cL+"px";
			
		}
		else if (where == 'portal')
		{
			contain=document.getElementById('formCont');
			var cL=Math.round((theW-800)/2);
			
			contain.style['left']=cL+"px";
			document.getElementById('portal').style['height']=theH-250+'px';
			document.getElementById('add').style['top']=theH-100+'px';
			//thH+'px';
		}
		else if (where == "log")
		{
			var cH=contain.offsetHeight;
			
			var cT=Math.round((theH-cH)/3);
			//alert(theH);
			
			contain.style['top']=cT+"px";
			var cL=Math.round((theW-800)/2);
			
			contain.style['left']=cL+"px";
	
		}
		
		var lnkLft=Math.round((theW-800)/2);
		lnkLft=lnkLft-8;
		
		if ((doIt==true) && (where=="cont"))
		{
			var service=document.getElementById('serv');
			
			service.style['left']=lnkLft+"px";
			
			//alert(lnkLft);
		}
		men1=document.getElementById('m1');
		men2=document.getElementById('m2');
		men3=document.getElementById('m3');
		men4=document.getElementById('m4');
		
		if (where=="cont")
		{
			if (doIt==false)
			{
				lnkLft=lnkLft-13;
			}
			men1.style['left']=lnkLft+"px";
			men2.style['left']=(lnkLft+202)+"px";
			men3.style['left']=(lnkLft+404)+"px";
			men4.style['left']=(lnkLft+606)+"px";
		}
		else if ((where == "formCont") || (where="log"))
		{
			men2.style['left']="202px";
			men3.style['left']="404px";
			men4.style['left']="606px";
		}
	}
}

function setTable()
{
	var theTab=document.getElementById('orderTable');
	
	theTab.style['left']='';
}

function rollMe(item)
{
	document.body.style.cursor='Hand';
	item.style['background']="#ebe6c1";
	item.style['color']="#4c1825";
}

function goBack(item)
{
	document.body.style.cursor='Default';
	item.style['background']="#4c1825";
	item.style['color']="#ebe6c1";
}

function pullNav(page, item, port)
{
	if ((page =="quote") && (item == 0))
	{
		if (port==true)
		{
			setNSend('portalQuote.cgi');
		}
		else
		{
			window.location="quote.html";
		}
	}
	else if ((page == "quote") && (item == 1))
	{
		if (port==true)
		{
			setNSend('portalOrder.cgi');
		}
		else
		{
			window.location="order.html";
		}
	}
	else if ((page == "order") && (item == 0))
	{
		if (port==true)
		{
			setNSend('portalOrder.cgi');
		}
		else
		{
			window.location="order.html";
		}
	}
	else if ((page == "order") && (item == 1))
	{
		if (port==true)
		{
			setNSend('portalQuote.cgi');
		}
		else
		{
			window.location="quote.html";
		}
	}
	else if (((page == "quote") || (page == 'order')) && (item == 2))
	{
		if (port==true)
		{
			setNSend('portalSend.cgi');
		}
		else
		{
			window.location="send.html";
		}
	}
	else if ((page == 'send') && (item == 0))
	{
		if (port==true)
		{
			setNSend('portalSend.cgi');
		}
		else
		{
			window.location='send.html';
		}
	}
	else if ((page == 'send') && (item == 1))
	{
		if (port==true)
		{
			setNSend('portalOrder.cgi');
		}
		else
		{
			window.location="order.html";
		}
	}
	else if ((page == "send") && (item == 2))
	{
		if (port==true)
		{
			setNSend('portalQuote.cgi');
		}
		else
		{
			window.location="quote.html";
		}
	}
}

function mkUp(make)
{
	if (make == 1)
	{
		var theLoc=document.getElementById('buttHere');
		
		//theLoc.style['height']='75px';
		
		var butt1=document.createElement('input');
		var butt2=document.createElement('input');
		var butt3=document.createElement('input');
		var butt4=document.createElement('input');
		
		
		//var theTab=document.createElement('table');
		//var theTR=document.createElement('tr');
		var theTD1=document.createElement('div');
		var theTD2=document.createElement('div');
		var theTD3=document.createElement('div');
		var theTD4=document.createElement('div');
		
		theTD1.id="cell1";
		theTD2.id="cell2";
		theTD3.id="cell3";
		theTD4.id="cell4";
		theTD1.className="button";
		theTD2.className="button";
		theTD3.className="button";
		theTD4.className="button";
		
		theTD1.style['left']="320px";
		theTD1.style['top']="520px";
		
		theTD2.style['left']="520px";
		theTD2.style["top"]="520px";
		
		theTD3.style['top']="545px";
		theTD3.style['left']="320px";
		
		theTD4.style['left']="520px";
		theTD4.style['top']="545px";
		
		butt1.type='file';
		butt1.name='file1';
		
		butt2.type='file';
		butt2.name='file2';
		
		butt3.type='file';
		butt3.name='file3';

		butt4.type='file';
		butt4.name='file4';

		//theLoc.appendChild(theTab);
		//theTab.appendChild(theTR);
		theLoc.appendChild(theTD1);
		theLoc.appendChild(theTD2);
		theLoc.appendChild(theTD3);
		theLoc.appendChild(theTD4);
		
		theTD1.appendChild(butt1);
		theTD2.appendChild(butt2);
		theTD3.appendChild(butt3);
		theTD4.appendChild(butt4);

	}
	else if (document.getElementById('cell1')!=undefined)
	{
		var theLoc=document.getElementById('buttHere');
		var theTD1=document.getElementById('cell1');
		var theTD2=document.getElementById('cell2');
		var theTD3=document.getElementById('cell3');
		var theTD4=document.getElementById('cell4');
		
		theLoc.removeChild(theTD1);
		theLoc.removeChild(theTD2);
		theLoc.removeChild(theTD3);
		theLoc.removeChild(theTD4);
	}
}

function valForm(which)
{

	var name=document.forms.form.name;
	var phone=document.forms.form.phone;
	var email=document.forms.form.email;
	
	if (name.value == "")
	{
		alert ("Please enter your name.");
		document.forms.form.name.focus();
		theTest=false;
	}
	else if (phone.value == "")
	{
		alert ("Please enter your phone number.");
		document.forms.form.phone.focus();
		theTest=false;
	}
	else if (email.value == "")
	{
		alert ("Please enter your email address.");
		document.forms.form.email.focus();
		theTest=false;
	}
	else
	{
		test1=email.value.indexOf('@');
		test2=email.value.indexOf('.');
			
		if ((test1 != -1) && (test2 != -1))
		{
			theTest = true;
		}
		else
		{
			alert("Please enter a VALID email address.");
			document.forms.form.email.focus();
			theTest=false;
		}
	}
	
	//alert(document.forms.form.file.value);
	//alert(1);
	if ((which == "send") && (document.forms.form.file1.value == "") && (document.forms.form.file2.value == "") && (document.forms.form.file3.value == "") && (document.forms.form.file4.value == "") && (theTest == true))
	{
		alert ("Please select a file to send.");
		document.forms.form.file1.focus();
		theTest=false;
	}
	
	//alert(theTest);
	return theTest;
}

function setNSend(action)		
{
	var theForm=document.forms.sendMe;
	theForm.action=action;
	theForm.submit();
}	

function rollOver(which)
{
	document.body.style.cursor="Hand";
	which.style['color']="#4c1825";
}
				
function rollOut(object)
{
	document.body.style.cursor="Default";
	object.style['color']="black";
}
		
function showOrder(theText, thePath)
{
	var orderDiv=document.getElementById('order');
	var head=document.getElementById('head');
	
	orderDiv.removeChild(head);

	head=document.createElement('div');
	
	head.className="head";
	
	head.id="head";
	
	var text=document.createTextNode(theText);
	
	head.appendChild(text);
	
	orderDiv.appendChild(head);
	
	var thePre=document.getElementById('preview');
	
	thePre.src=thePath;
	
	orderDiv.className="orderShow";
}

function hideOrder()
{
	document.forms.orderFile.reset();
	
	var theSel=document.getElementById('meth');
	
	theSel.disabled=true;

	var orderDiv=document.getElementById('order');
	
	orderDiv.className="orderHide";
}

function toggleSel(theVal)
{
	var theSel=document.getElementById('meth');
	
	if (theVal != "")
	{
		
		theSel.disabled=false;
	}
	else
	{
		theSel.disabled=true;
	}
}