function Querystring()
{
// get the query string, ignore the ? at the front.
 var querystring=location.search.substring(1,location.search.length);
// parse out name/value pairs separated via &
 var args = querystring.split('&');
// split out each name = value pair
 for (var i=0;i<args.length;i++)
 {
  var pair = args[i].split('=');
  // Fix broken unescaping
         temp = unescape(pair[0]).split('+');
  name = temp.join(' ');
  temp = unescape(pair[1]).split('+');
  value = temp.join(' ');
  this[name.toUpperCase()]=value;
 }
 this.get=Querystring_get;
}
function Querystring_get(strKey,strDefault)
{
 var value=this[strKey.toUpperCase()];
 if (value==null)
 {
  value=strDefault;
 }
 return value;
}
 
 
if(window.location.href.toLowerCase().indexOf("productdetails.asp") > -1)
{
 
var qs = new Querystring()
 
  var checkboxname= qs.get("ProductCode","0");

    var a = document.getElementsByName('SELECT___' + checkboxname + '___19')[0];
 
 if(a != null)
    {
        ShowHideMonogram();
     a.onclick= function Checkbox_Click()
        {
            ShowHideMonogram();
            change_option('SELECT___' + checkboxname + '___19',a.value);
     }
 
    }
   }
 
function ShowHideMonogram()
{
var qs = new Querystring()
  var checkboxname= qs.get("ProductCode","0");
    var flag = document.getElementsByName('SELECT___' + checkboxname + '___19')[0].checked;
    var list = document.getElementsByTagName("font");
 
    for (var i=0; i < list.length; i++) 
    {
          if (list[i].innerHTML.toLowerCase().indexOf("1. select thread color") > -1 || list[i].innerHTML.toLowerCase().indexOf("2. select embroidery style") > -1  || list[i].innerHTML.toLowerCase().indexOf("3. provide name or initials for monogramming") > -1) 
          {
              var list1 =list[i].parentNode.parentNode.parentNode.getElementsByTagName("tr");    
              for (var j=0; j < list1.length; j++) 
              {       
                    if (list1[j] != null && list1[j].innerHTML != null)
                    {
                        if (list1[j].innerHTML.toLowerCase().indexOf("1. select thread color") > -1 || list1[j].innerHTML.toLowerCase().indexOf("2. select embroidery style") > -1  || list1[j].innerHTML.toLowerCase().indexOf("3. provide name or initials for monogramming") > -1) 
                        {
                            if(flag == false)
                            {
                                    var k = 0;
                                    var l = 0;
                                    k=j;
                                    k=j;
                                    l = k;
                                    
                                    if(list1[k] != null)
                                            list1[k].style.display="none";
                                    if(list1[k+1] != null)
                                            list1[k+1].style.display="none";
                                    if(list1[k+2] != null)
                                            list1[k+2].style.display="none";
                                    if(list1[k+3] != null)
                                            list1[k+3].style.display="none";
 
                            }
                            else
                            {
                                    var k = 0;
                                    var l = 0;
                                    k=j;
                                    k=j;
                                    l = k;
                                    
                                    if(list1[k] != null)
                                             list1[k].style.display="";
                                    if(list1[k+1] != null)
                                             list1[k+1].style.display="";
                                    if(list1[k+2] != null)
                                             list1[k+2].style.display="";
                                    if(list1[k+3] != null)
                                             list1[k+3].style.display="";
                            }
                      }
                }
            }             
        }
    }
}
 
function scriptInit() {
if (!document.getElementById) {
	return;
	}
}
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
	elm.addEventListener(evType, fn, useCapture);
	return true;
	} else if (elm.attachEvent) {
	var r = elm.attachEvent('on' + evType, fn);
	return r;
	} else {
	elm['on' + evType] = fn;
	}
}
function checkActive() {
	var a = document.getElementsByTagName("a");
	if (window.location.href.substr(location.href.length - 1, 1) == '/') {
		var loc = window.location.href + 'default.asp'; 
	}
	else {
		var loc = window.location.href;
	}
	for(var i=0; i < a.length; i++) {
		if (a[i].href == loc) {
			a[i].setAttribute("class", "active");
			a[i].setAttribute("className", "active");
		}
	}
}
addEvent(window, 'load', checkActive, false);
