// Javascript
function openWindow(url, name, width, height)
{
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	if (window.screen)
	{
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	str += ",scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no, resizable=no";
	var thewindow = window.open(url, name, str);
	thewindow.focus();
}

function openWindowResizable(url, name, width, height)
{
        var str = "height=" + height + ",innerHeight=" + height;
        str += ",width=" + width + ",innerWidth=" + width;
        if (window.screen)
        {
                var ah = screen.availHeight - 30;
                var aw = screen.availWidth - 10;

                var xc = (aw - width) / 2;
                var yc = (ah - height) / 2;

                str += ",left=" + xc + ",screenX=" + xc;
                str += ",top=" + yc + ",screenY=" + yc;
        }
        str += ",scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes";
        var thewindow = window.open(url, name, str);
        thewindow.focus();
}

function openOrder(width, height)
{
        var str = "height=" + height + ",innerHeight=" + height;
        str += ",width=" + width + ",innerWidth=" + width;
        if (window.screen)
        {
                var ah = screen.availHeight - 30;
                var aw = screen.availWidth - 10;

                var xc = (aw - width) / 2;
                var yc = (ah - height) / 2;

                str += ",left=" + xc + ",screenX=" + xc;
                str += ",top=" + yc + ",screenY=" + yc;
        }
        str += ",scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no, resizable=yes";
        var thewindow = window.open("https://www.voxtoneonline.com/orderstep1.php", "myVoxTone", str);
        thewindow.focus();
}

function openWindow2(url, name, width, height)
{
	var str = "height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	if (window.screen)
	{
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	str += ",scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no, resizable=yes";
	var thewindow = window.open(url, name, str);
	thewindow.focus();
}
function do_filter(inpstr) {
   var arr_find = [
       String.fromCharCode(8220), //“
       String.fromCharCode(8221), //”
       String.fromCharCode(8216), //‘
       String.fromCharCode(8217), //‘
       String.fromCharCode(8211), //–
       String.fromCharCode(8212), //—
       String.fromCharCode(189), //½
       String.fromCharCode(188), //¼
       String.fromCharCode(190), //¾
       String.fromCharCode(169), //©
       String.fromCharCode(174), //®
       String.fromCharCode(8230) //…
   ];


   var arr_replace = [
       '"',
       '"',
       "'",
       "'",
       "-",
       "--",
       "1/2",
       "1/4",
       "3/4",
       "(C)",
       "(R)",
       "..."
   ];


       //Make sure find and replace have equal lengths
       if ( !(arr_find.length == arr_replace.length) ) {
           throw new Error("The MS Word entities find values do not match the replacement values");

       }

       //Still here, then replacement rules are ok - loop across and do the replacement
       for ( var i=0; i< arr_find.length; i++ ) {
           var regex = new RegExp(arr_find[i], "gi");
           inpstr = inpstr.replace(regex, arr_replace[i]);

       }//for

       return inpstr 
}
function fixit(elemname) {
	var elem = document.getElementById(elemname);
	txt = elem.value;
	txt = txt.replace(String.fromCharCode(145), "'");
	txt = txt.replace(String.fromCharCode(146), "'");
	txt = txt.replace(String.fromCharCode(147), String.fromCharCode(34));
	txt = txt.replace(String.fromCharCode(148), String.fromCharCode(34));
	txt = txt.replace(String.fromCharCode(150), "-");
	txt = txt.replace(String.fromCharCode(151), "--");
	txt = txt.replace(String.fromCharCode(180), "'");
	txt = txt.replace(String.fromCharCode(184), ",");
	txt = txt.replace(String.fromCharCode(149), "·");
	txt = txt.replace(String.fromCharCode(133), "...");
	txt = txt.replace(String.fromCharCode(132), String.fromCharCode(34));
	txt = txt.replace(String.fromCharCode(152), "~");
	txt = txt.replace(String.fromCharCode(126), "~");
	for (i=129;i<256;i++) {
		c = "&#" + i + ";"
		txt = txt.replace(String.fromCharCode(i), c);
	}
	elem.value=txt;
}


function notEmpty(elemname){
        var myTextField = document.getElementById(elemname);
        if(myTextField.value != "")
                alert("You entered: " + myTextField.value)
        else
                alert("Would you please enter some text?")
}

