<!--
function onloader()
{
if (document.form1)
	{
	patternalert();
	lengthwidthwidget();
	}
if (document.choices)
	{
	constructionalert();
	}
}

function createXHR() {
if (typeof XMLHttpRequest != 'undefined')
return new XMLHttpRequest();
else if (window.ActiveXObject) {
var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp",
"MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0",
"MSXML2.XmlHttp.5.0"];
for (var i = avers.length -1; i >= 0; i--) {
try {
httpObj = new ActiveXObject(avers[i]);
return httpObj;
} catch(e) {}
}
}
throw new Error('XMLHttp (AJAX) not supported');
}

function patternalert()
{
    if (Get_Cookie('makepattern') && Get_Cookie('makepattern') == "notsaved") {
	  Set_Cookie( 'makepattern', 'off', '', '/', '', '' );
      alert('Thanks for making a pattern!\n\nIt takes about a minute to make your preview pattern.\n\nOnce you click the \'OK\' button on this message you should\nsee your pattern\'s description along with a \'spinner\' icon\ntelling you it\'s being created.\n\nI take great pride in the emails and pictures my customers\nsend me about their first successful projects. While waiting\nfor your preview you can scroll down this page and read their\nremarks and see pictures of their results.\n\nBy the time you\'re done reading your preview should be ready.\n\nThanks,\nDebby Bowman');
      return true;
    }
    if (Get_Cookie('makepattern') && Get_Cookie('makepattern') == "saved") {
	  Set_Cookie( 'makepattern', 'off', '', '/', '', '' );
      alert('Thanks for saving your pattern!\n\nIt takes about a minute to make your new pattern.\n\nOnce you click the \'OK\' button on this message you should\nsee your pattern\'s description along with a \'spinner\' icon\ntelling you it\'s being created.\n\nI take great pride in the emails and pictures my customers\nsend me about their first successful projects. While waiting\nfor your pattern you can scroll down this page and read their\nremarks and see pictures of their results.\n\nBy the time you\'re done reading your pattern should be ready.\n\nThanks,\nDebby Bowman');
      return true;
    }
}


function constructionalert()
{
if (Get_Cookie('constructionalert' ) && Get_Cookie('constructionalert') == 'main')
	{
	Set_Cookie( 'constructionalert', 'off', '', '/', '', '' );
	document.location="#choices";
      alert('Your Shade Kit and Supply Shopping List have been\nupdated by your construction choices.\n\nThanks,\nDebby');
	  return true;
	}
if (Get_Cookie('constructionalert' ) && Get_Cookie('constructionalert') == 'kit')
	{
	Set_Cookie( 'constructionalert', 'off', '', '/', '', '' );
	document.location="#kitchoice";
      alert('Your Shade Kit and Supply Shopping List have been\nupdated by your construction choices.\n\nThanks,\nDebby');
	  return true;
	}
if (Get_Cookie('constructionalert' ) && Get_Cookie('constructionalert') == 'list')
	{
	Set_Cookie( 'constructionalert', 'off', '', '/', '', '' );
	document.location="#listchoice";
      alert('Your Shade Kit and Supply Shopping List have been\nupdated by your construction choices.\n\nThanks,\nDebby');
	  return true;
	}
}

var gAutoPrint = true; // Flag for whether or not to automatically call the print function
function printSpecial()
{
    if (document.getElementById != null)
    {
        var html = '<HTML>\n<HEAD>\n';

        if (document.getElementsByTagName != null)
        {
            var headTags = document.getElementsByTagName("head");
            if (headTags.length > 0)
                html += headTags[0].innerHTML;
        }

        html += '\n</HE' + 'AD>\n<BODY>\n';
        document.getElementById("banner").style.display='block';
        var printReadyElem = document.getElementById("printReady");

        if (printReadyElem != null)
        {
                html += printReadyElem.innerHTML;
				
        }
        else
        {
            alert("Could not find the printReady section in the HTML");
            return;
        }

        html += '\n</BO' + 'DY>\n</HT' + 'ML>';
		
        var printWin = window.open("","printSpecial");
        printWin.document.open();
        printWin.document.write(html);
        printWin.document.close();
        if (gAutoPrint)
            printWin.print();
    }
    else
    {
        alert("Sorry, this printing feature does not work with your web browser.");
    }
}

function productshow(page)
{
if (page != 'kit')
{
var dest = 'http://www.make-roman-shades.com/sample_about.php?p=' + page ;
}
else
{
var dest = 'http://www.make-roman-shades.com/kits.html';
}

	if (page != 'hidebutton')
	{
	document.getElementById('hidebutton').style.display = "block";
	document.getElementById('showcase').style.display = "block";
	window.frames['showcase'].location = dest;
	}
	else
	{
	document.getElementById('showcase').style.display = "none";
	document.getElementById('hidebutton').style.display = "none";
	}
}

function helper(section)
{
document.getElementById('helphelp').style.display = "none";

for (var x = 1; x <= 10; x++)
   {
    if (section == x || section == x + 10)
    {
    document.getElementById(x).style.display = "block";
        if (x < 10)
        {
        document.getElementById(x+10).style.backgroundColor = "#FFFEFD";
        }
    }
    else
    {
    document.getElementById(x).style.display = "none";
        if (x < 10)
        {
        document.getElementById(x+10).style.backgroundColor = "#FFF5F0";
        }
    }
   }
}

function aFunction()
{
}

function lengthwidthwidget()
{
// Get Shade style and drop value
var styleIndex, styleText
styleIndex = document.form1.shadetype.selectedIndex
styleValue = document.form1.shadetype.options[styleIndex].value
styleText = document.form1.shadetype.options[styleIndex].text
    if (styleIndex > 0)
    {
    var drop
        switch(styleIndex)
        {
        case 1:
            drop = 8;
            break;
        case 2:
            drop = 10;
            break;
        case 3:
            drop = 12;
            break;
        }
    }
// Get shade width whole number
var swidthIndex = document.form1.swidth.selectedIndex
if (swidthIndex > 0)
{
    var swidthValue = document.form1.swidth.options[document.form1.swidth.selectedIndex].value
}
        if(document.form1.swidth.options[document.form1.swidth.selectedIndex].value == 72)
        {
        document.form1.wfrac.disabled = true;
        document.form1.wfrac.value = 0
        }
        else
        {
        document.form1.wfrac.disabled = false;
        }
// Get shade width fractional value
var wfracIndex = document.form1.wfrac.selectedIndex
if (wfracIndex > 0)
{
    var wfracText
    var wfracValue = document.form1.wfrac.options[wfracIndex].value
    switch(wfracIndex)
    {
    case 1:
        wfracText = "";
        break;
    case 2:
        wfracText = "1/8";
        break;
    case 3:
        wfracText = "1/4";
        break;
    case 4:
        wfracText = "3/8";
        break;
    case 5:
        wfracText = "1/2";
        break;
    case 6:
        wfracText = "5/8";
        break;
    case 7:
        wfracText = "3/4";
        break;
    case 8:
        wfracText = "7/8";
        break;
    }
}
// Get shade length whole number
var lengthIndex = document.form1.slength.selectedIndex
if (lengthIndex > 0)
{
    var lengthValue = document.form1.slength.options[document.form1.slength.selectedIndex].value
}
        if(document.form1.slength.options[document.form1.slength.selectedIndex].value == 90)
        {
        document.form1.lfrac.disabled = true;
        document.form1.lfrac.value = 0
        }
        else
        {
        document.form1.lfrac.disabled = false;
        }
// Get shade length fractional value
var lfracIndex = document.form1.lfrac.selectedIndex
if (lfracIndex > 0)
{
    var lfracText
    var lfracValue = document.form1.lfrac.options[lfracIndex].value
    switch(lfracIndex)
    {
    case 1:
        lfracText = "";
        break;
    case 2:
        lfracText = "1/8";
        break;
    case 3:
        lfracText = "1/4";
        break;
    case 4:
        lfracText = "3/8";
        break;
    case 5:
        lfracText = "1/2";
        break;
    case 6:
        lfracText = "5/8";
        break;
    case 7:
        lfracText = "3/4";
        break;
    case 8:
        lfracText = "7/8";
        break;
    }
}
if ((swidthIndex > 0 && wfracIndex > 0) || (lengthIndex > 0 && lfracIndex > 0))
{
document.getElementById('widthlengthtable').style.display = "block";	
}
else
{
document.getElementById('widthlengthtable').style.display = "none";	
}

if (swidthIndex > 0 && wfracIndex > 0)
    {
    var tempwidthtext = swidthValue + "&nbsp;" + wfracText + "&nbsp;inches" 
    document.getElementById('show_width').innerHTML = tempwidthtext;
    document.getElementById('show_width').style.display = "block";
    document.getElementById('currentwidth').style.fontWeight = "bold";
    }
    else
    {
    document.getElementById('show_width').style.display = "none";
    document.getElementById('currentwidth').style.fontWeight = "normal";
    }
if (lengthIndex > 0 && lfracIndex > 0)
    {
    var templengthtext = lengthValue + "&nbsp;" + lfracText + "&nbsp;inches" 
    document.getElementById('show_length').innerHTML = templengthtext;
    document.getElementById('show_length').style.display = "block";
    document.getElementById('currentlength').style.fontWeight = "bold";
        // check roman shade drop only
        if (drop)
        {
            var totalwidth = Number(lengthValue) + Number(lfracValue)
            if (totalwidth > 17.875 && totalwidth <= 39.875 && drop != 8)
            {
            var recommended = "8 Inch Rib Spacing";
			var correctstyleindex = 1;
            }
            else if (totalwidth > 39.875 && totalwidth <= 59.875 && drop != 10)
            {
            var recommended = "10 Inch Rib Spacing";
			var correctstyleindex = 2;
            }
            else if (totalwidth > 59.875 && totalwidth <= 90 && drop != 12)
            {
            var recommended = "12 Inch Rib Spacing";
			var correctstyleindex = 3;
            }
            else
            {
            }
        }
        if (recommended)
        {
		document.getElementById('dropwarning').style.marginTop = "6px";
		document.getElementById('dropwarning').style.padding = "6px";
        document.getElementById('dropwarning').style.border = "1px solid #B33A00";
        document.getElementById('dropwarning').style.backgroundColor = "#FFF5F0";
        document.getElementById('dropwarning').innerHTML = '<div align="center" style="margin-bottom:7px;"><img src="images/shade_style.gif" border="0" align="absbottom"></div><div align="left">' + 'With a finished length of ' + templengthtext + ', I\'d suggest changing <strong><font color="#993300">Shade Style</font></strong> to:</div><div align="center" style="padding:7px;"><strong><font color="#993300">Flat Roman - ' + recommended + '</font></strong></div><div align="center" style="padding-bottom:3px;"><a title="Learn about flat roman shade rib spacing" href="makepatterns_help.php#drop" onMouseOver="helper(11)">Read why I suggest this</a><BR><BR><a title="Click here and it will change automatically to my suggested amount" href="javascript:autochange(' + correctstyleindex + ');">Change it for me</a></div>';
        document.getElementById('dropwarning').style.display = "block";
		document.form1.shadetype.style.fontWeight = "bold";
			for (var x = 1; x <= 3; x++)
			{
			document.form1.shadetype.options[x].style.color = "black";	
			}
		document.form1.shadetype.options[correctstyleindex].style.color = "red";
		document.form1.shadetype.focus();
        }
        else
        {
		document.getElementById('dropwarning').style.marginTop = "0px";
		document.getElementById('dropwarning').style.padding = "0px";
        document.getElementById('dropwarning').style.border = "none";
        document.getElementById('dropwarning').style.backgroundColor = "white";
        document.getElementById('dropwarning').innerHTML = "&nbsp;";
        document.getElementById('dropwarning').style.display = "none";
		document.form1.shadetype.style.border = "1px solid #8E8E8E";
		document.form1.shadetype.style.fontWeight = "normal";
			for (var x = 1; x <= 3; x++)
			{
			document.form1.shadetype.options[x].style.color = "black";	
			}
        }
    }
    else
    {
    document.getElementById('show_length').style.display = "none";
    document.getElementById('currentlength').style.fontWeight = "normal";
    }
}  //end lengthwidthwidget function

function autochange(correctshadestyle)
{
document.form1.shadetype.selectedIndex = correctshadestyle;
lengthwidthwidget()
}


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

function deleteCookie(cookie_name)
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  {
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    {
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function hider(span,section)
{
var switcher = document.getElementById(section);
if(span.innerHTML=='- Hide')
 {
 span.innerHTML='+ Show';
 switcher.style.display='none';
 writeCookie('shoplist',0);
 }
else if(span.innerHTML=='+ Show')
 {
 span.innerHTML='- Hide';
 switcher.style.display='block';
 writeCookie('shoplist',1);
 }
}

var popupwin=0;
function popupwindow(urlstr)
{
  if(popupwin)
  {
    if(!popupwin.closed) popupwin.close();
  }
popupsin = open(urlstr, 'popupwin', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,top=50,left=50,width=580,height=500');
}

var winpattern=0;
function popuppattern(urlstr)
{
  if(winpattern)
  {
    if(!winpattern.closed) winpattern.close();
  }
popupsin = open(urlstr, 'winpattern', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,top=30,left=100,width=550,height=600');
}

submitcounter = 0;
function submitmonitor() {
submitcounter++;
if(submitcounter > 1) { return false; }
return true;
}

// Trying to prevent duplicate pattern submissions. It works with YY_checkform directly below it.
psubmitcounter = 0;
function psubmitmonitor() {
psubmitcounter++;
if (psubmitcounter > 1)
	{
	return false;	
	}
	else
	{
		if (document.form1.pemail.value != '')
		{
		__utmSetVar('psvr');	
		}
		else
		{
		__utmSetVar('npsvr');	
		}
	return true;	
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
	  // Bowman addition
	   {
		   if (o.type == 'text' && o.name == 'window')
		   {
		   var numspaces = 0;
			   for (x=0; x<=v.length;x++){
					if (o.value.charAt(x) == ' ')
					{
					numspaces = numspaces + 1;	
					}
				}
		   		if (numspaces == v.length)
				{
				err=true;	
				}
		   }
	   }
	  //
	  
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!='')
	{
	alert('Ooops! Items need your attention before things can proceed:\t\t\t\t\t\n\n'+s);
	document.MM_returnValue = (s=='');
	}
	else
	{
	document.MM_returnValue = (psubmitmonitor());
	}
}
function getScrollY() {
        var scrOfY = 0;
        if( typeof( window.pageYOffset ) == 'number' ) {
                //Netscape compliant
                scrOfY = window.pageYOffset;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
                //DOM compliant
                scrOfY = document.body.scrollTop;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
                //IE6 standards compliant mode
                scrOfY = document.documentElement.scrollTop;
        }
        return scrOfY;
}
function scrollto(target_id,speed){
        if(target_id == '') return;
        if(!document.getElementById(target_id)) return;
        var currentypos = getScrollY();
        targetdiv = document.getElementById(target_id);
        var desty = targetdiv.offsetTop;
        var thisNode = targetdiv;
        while (thisNode.offsetParent && (thisNode.offsetParent != document.body)) {
                thisNode = thisNode.offsetParent;
                desty += thisNode.offsetTop;
        }
        // bring you to just above
        desty -= 4;
        if(desty < currentypos){
                for ( I=currentypos; I > desty; I-= speed ){
                        parent.scroll(1,I);
                }
        }else{
                for ( I=currentypos; I < desty; I+= speed ){
                        parent.scroll(1,I);
                }
        }
}
//-->
