// JavaScript Document

var lcell=0;
var xswx=0; 
var oplayer="none";
var opvalue=0;
savedplans=getCookie('plancookie');
if(savedplans==null || savedplans=="")
{
var savedplans="0";
}


function showLayer(layer)  
{                  
document.getElementById(layer).style.display="";         
} 

function hideLayer(layer)           
{                                           
document.getElementById(layer).style.display="none"; 
} 

function autochangeEm()

{                     
aa="info";            
b="ryanmoehomedesign";       
c=(aa + "@" + b + ".com");   
 
for (y in document.links)       
  {                        
z=document.links[y].href;      
if (z=="mailto:default@allcustomplans.com" || z=="mailto:default@ryanmoehomedesign.com")    
{                      
zz=document.links[y].id;   
document.getElementById(zz).href="mailto:" + c;     
document.getElementById(zz).innerHTML=c;       
}          
}         
}     

function replaceImage(x,image)

{   
image="images/" + image;   
document.getElementById(x).src=image; 
}

 function navIn(x)  
 {
               
//x=document.getElementById(x);
if(x != null)
{
 x.style.backgroundImage="url('images/newgrad1.jpg')";  
  x.style.color="#fff";            
   x.style.fontWeight="bold";     
 }         
 }       
  function navOut(x)     
 {
                        
 y=x.id;  
if (y != thispage)
{
x.style.backgroundImage="";   
x.style.color="";      
x.style.fontWeight="";   
 
}                   
 }     

function myLink(link)
 {      
parent.window.location.assign(link);
 }  

 
function changeOpacity(x,a)

{     
b=(a/100);
x.style.opacity=b;  
x.filters.alpha.opacity=a; 
} 

function swapLayer(xin,xout)  
{     
document.getElementById(xout).style.display="none";   
document.getElementById(xin).style.display="";    
}              


function switchLayer(layerin,layerout){ 
document.getElementById(layerin).style.display="inline"; 
document.getElementById(layerout).style.display="none"; 
}

function submitForm(x,a)
{

y=document.getElementById(x);
y.action="results.php";
if(validate_form(y,a)!=false)
{
y.submit();       
}
}

function switchForm(x)                  
{

document.getElementById('hform').style.display="none";
 document.getElementById('aform').style.display="none";
 document.getElementById('gform').style.display="none";
 document.getElementById(x).style.display="";
 
 if(x=="gform")
 {
 document.getElementById('garageframe').src="http://garage.allcustomplans.com/questions-garage.php";
 }
  }

  function expandList(a,x)
  {
  i=1;
  while(i != 99)
  {
b=a + i;
c=a + x;
if(document.getElementById(b) != undefined )
{
document.getElementById(b).style.display="none";
i++;
}
else
{
i=99;
}  
 }
document.getElementById(c).style.display="block";
 
  }
  
    function portPage(a,x,z)
  {
  i=1;
  while(i != 99)
  {
b=a + i;
c=a + x;
d="link" + i;
e="link" + x;
if(document.getElementById(b) != undefined )
{
document.getElementById(b).style.display="none";
document.getElementById(d).style.color="";

i++;
}
else
{
i=99;
}  
 }
document.getElementById(c).style.display="block";
document.getElementById(e).style.color="#ff0000";

  }
  
    function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

 function switchLay(pname,open){
x=1;
i=0;

 
c=("top" + (pname) + (open));
if (xswx==1)
{
while (i!="xx")
{ 
aa=((pname) + (x));
b=((pname) + (open));
d=("top" + (pname) + (x));

b=document.getElementById(b);
aa=document.getElementById(aa);
  
if (aa !== null)
{
if (aa != b){

aa.style.display="none";
document.getElementById(d).className="toplist";
}
}
else
{
i="xx"
}
x=x+1;
}
if (b !== null){
var myLayer = b.style.display;
if(myLayer!="block"){
b.style.display="block";
  
document.getElementById(c).className="toplist-open";

} else {
b.style.display="none";
document.getElementById(c).className="toplist";
}
xswx=1;
}
}
else
{
b=((pname) + (open));


document.getElementById(b).style.display="block";
document.getElementById(c).className="toplist-open";
xswx=1;
}
}

function selectPlan(a,x,q)
{
z="plancookie";  
if(a !=null)
{
b=x + "box";
b=document.getElementById(b);  
x=x.substr(0,7);
if(a.checked==true || q=="manual")      
{    
a.checked=true;               
b.style.borderColor="#ff0000";
if(savedplans=="0" || savedplans=="")
{
savedplans=x;
}
else
{
xx=savedplans.indexOf(x);

if(xx<0)
{
savedplans=savedplans + "," + x;
savedplans=savedplans.replace(",,",",");
}
}  
if(q !="manual")
{
addData(x);
}
 }
else
{
b.style.borderColor="#000";
savedplans=savedplans.replace(x,"");
savedplans=savedplans.replace(",,",",");
 }    
var exdate=new Date();
exdays=365;
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(savedplans) + ((exdays==null) ? "" : ";expires="+exdate.toUTCString());

document.cookie=z + "=" + c_value;
}
}

function loadSavedPlan()
{   
if(savedplans !="" && savedplans !="0")
{  
x=savedplans.split(",");
for(i in x)
{  
y=x[i]; 
if(y.length > 3)
{
if(y.length==6)
{
ba=(y.substr(0,5))
bb=(y.substr(5,1));
cc=ba + "0" + bb;
y=cc;  

}
y=y.replace(",","");
z="ck" + y;    
z=document.getElementById(z);
selectPlan(z,y,'manual');
}
}
}      
}

function showGo(x)
{
y=x.value.length;
if(y > 3)
{
showLayer('pnsearch');
}
}

function selText(x)
{
x.select();
}

function hidePic(x)
{
document.body.style.overflow="auto";
document.getElementById(x).style.display="none";
}

function showPic(x,a)
{
b=a + "pic";
document.body.style.overflow="hidden";
document.getElementById(a).style.display="block";
document.getElementById(b).src=x;
}

function reSize(x)
{
if(x.style.width=="")
{
x.style.width="1200px";
x.style.maxHeight="";
}
else
{
x.style.width="";
x.style.maxHeight="95%";
}
}

 // validate email address in forms --------------------------------------

  function validate_email(field,alerttxt,x)
{   
with (field)    
  {           
  apos=value.indexOf("@"); 
  dotpos=value.lastIndexOf(".");  
  if (apos<1||dotpos-apos<2)  
    {alert(alerttxt);document.getElementById(x).style.border='solid 1px #ff0000';return false}  
  else {
 
  if(x=="pdfemail")
  { 
  hideLayer('pdffirst');
  showLayer('pdfsecond');
  }
  return true;
  
  
  }    
  }   
}   
function validate_form(thisform,x)     
{ 
with (thisform) 
  { 
  if (validate_email(email,"Please enter a valid e-mail address",x)==false) 
    {return false;} 
  }   
}

function addData(x)
{
document.getElementById('saveformplan').value=x;
document.getElementById('saveform').submit();

}

function validateOptional(thisform,x)
{
aa=document.getElementById(x).value.length;

if(aa>0)
{
return validate_form(thisform,x);
}  
}

function toggleLayer(x)
{
y=document.getElementById(x);
if(y.style.display=="none")
{
y.style.display="block";
}
else
{
y.style.display="none";
}
}

function viewFavorites()
{
document.getElementById('favorites').value=savedplans;
document.getElementById('viewfavorites').submit();
}

function giveFocus(x)
{
document.getElementById(x).focus();
}








