﻿var msg = "Thank you for contacting us.\nA representative will review your email and contact you shortly.";

function loader()
{
    hiliteNav();
    SetBannerTitle();
    
}
function SetBannerTitle()
{
    try {
        var pageName = document.getElementById("pageName");
        var pageTitleSpan = document.getElementById("litPageTitleSpan");
        var headerBannerTextDiv = document.getElementById("ProdDetails1_lblPageTitle");
        if (pageName.value != "ahome") {
            if (pageTitleSpan != null && pageTitleSpan.innerHTML != "" && headerBannerTextDiv != null) {
                headerBannerTextDiv.innerHTML = pageTitleSpan.innerHTML;
            }
            else {
                var ProdDetailNameSpan = document.getElementById("ProdDetailNameSpan");
                if (ProdDetailNameSpan != null) {
                    pageTitleSpan.innerHTML = ProdDetailNameSpan.innerHTML;
                }
            }
        }
        if (pageName.value == "acontactus") {
        	//pageTitleSpan.innerHTML = "Contact CS & L For More Information";
        }
    }
    catch (Error) {
        alert(Error);
    }
}
// set the querystring for registration from the schedules page
function SetQueryStringUrl(id) {
    try {
        document.getElementById(id).src += window.location.search;
    }
    catch (Error) { }    
}

function drawVideo()
{
var vid = "GJHDigital HTML5 Video<br><video id='GJHDigitalHTML5Video' src='http://tinyvid.tv/file/q31g9htvwjdh.ogg' width='480' height='320' autoplay controls>";
vid += "Your browser does not support the HTML 5 video tag, please upgrade your browser. </video>";
vid += "<img src='http://www.gjhdigital.net/pics/GJHHTML5Video.jpg'>";
document.write(vid);
}

function setFocus(id)
{
    try
    {
        document.getElementById(id).focus();
    }
    catch(ex)
    {}
}
function PrevPageNav()
{
   var p = "";
   try
   {
        p = document.getElementById("pageName");
        if (p.value == "menu")
        {
            document.getElementById("PrevPageNav").style.display="block";
        }
        else
        {
            document.getElementById("PrevPageNav").style.display="none";
        }
   }
   catch(ex)
   {
        document.getElementById("PrevPageNav").style.display="none";
   } 
}
function LinkTargets()
{
    var id = "";
    try{
    id = document.getElementById("linkTargets");
    
    var a = id.getElementsByTagName("a");
        for(i=0; i<a.length; i++)
        {
          a[i].setAttribute("target", "_blank")
        }
    }
    catch(ex)
    {
        // dont do anything
    }
}
function SetImage(fileName)
{
    try
    {
        document.getElementById('defaultImage1_hidDefault').value = fileName;
        document.getElementById('defaultImage1_imgDefault').src = "pix/"+ fileName;
    }
    catch(errMsg)
    {
       //do nothing
    }
}
function Alert(msg)
{
    alert(msg);
}
function newWindow(url)
{
    window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=400, height=400");
}
function shipconfirm()
{
	if (confirm("Confirm Ship!")==true) 
		{
		return true; 
		}
	else 
	{
		alert('Action cancelled.');
		return false; 
	}
}
function CheckQryStr()
{
	var url = window.location.toString();
	if(url.indexOf("?mp=true") == -1)
	{
		parent.window.location = "http://www.gjhdigital.net/Items.aspx?type=Make A Payment&id=100";
	}
}

function getconfirm() 
{
	if (confirm("Confirm Delete!")==true) 
		{
		return true; 
		}
	else 
	{
		alert('Deletion(s) have been cancelled.');
		return false; 
	}
}
function select_deselectAll (chkVal, idVal) 
{ 
	var frm = document.forms[0];
	// Loop through all elements
	for (i=0; i<frm.length; i++) 
	{
		// Look for our Header Template's Checkbox
		if (idVal.indexOf ('CheckAll') != -1) 
		{
			// Check if main checkbox is checked, then select or deselect datagrid checkboxes 
			if(chkVal == true) 
			{
				frm.elements[i].checked = true;
			} 
			else 
			{
				frm.elements[i].checked = false;
			}
			// Work here with the Item Template's multiple checkboxes
		} 
		else if (idVal.indexOf ('DeleteThis') != -1) 
		{
			// Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
			if(frm.elements[i].checked == false) 
			{
				frm.elements[1].checked = false; //Uncheck main select all checkbox
			}
		}
	}
}
function swapImgOn()
{
	document.getElementById('bulletImg').src = "images/BulletNavs5.jpg";
}
function swapImgOff()
{
	document.getElementById('bulletImg').src = "images/BulletNavs6.jpg";
}

function hiliteNav()
{
    var lnk = ""; //.toLowerCase();
    try 
	{
	    var id = document.getElementById('pageName');
	    document.getElementById(id.value).style.color = "#fff";
	    document.getElementById(id.value).style.background = "url(images/navbtnOn.png) repeat-x top center";//
	    document.getElementById(id.value).style.backgroundColor = "#36474e"; //f99e1c a43231 f99e1c f929cb4

	    //document.getElementById(id.value).className = "activeLeftNavLists";
	    
	}
	catch(err)
	{
		//alert(err.Message);
	}
}
function hiliteMenu(el)
{
	var id = el.id;
	//document.getElementById(id).style.backgroundColor = 'transparent';
	document.getElementById(id).className = 'ProductsHover';
	//document.getElementById(id).style.backgroundImage = "url('../images/prod_Bkgd.gif')";

	
}
function deHiliteMenu(el)
{
	var id = el.id;
	//document.getElementById(id).style.backgroundColor = '#fff';
	document.getElementById(id).className = 'Products';
	//document.getElementById(id).style.backgroundImage = "";

}

function showMenu(id) {
    try {
        var x = document.getElementById(id);
        if (x.style.display == "none" || x.style.display == "") {
            x.style.display = "block";
        }
        else {
            x.style.display = "none";
        }
    }
    catch (Error)
	{ }
}
function hideMenu(id) {
    try{
	    document.getElementById(id).style.display = "none";
    }
    catch (Error)
	{ }
}

var arr = "";
function validateForm(ids)
{
	arr = ids.split(",");
	var isGood = false;
	for (i=0;i<=arr.length;i++)
	{
		var id = document.getElementById(arr[i]);
		if (id.value.length < 1)
		{
		
			if(id.id == "Email")
			{
				if(id.value.indexOf("@") < 1)
				{
					alert("Valid email is required!");
					isGood = false;
					break;
				}
				else if(id.value.indexOf(".") < 1)
				{
					alert("Valid email is required!");
					isGood = false;
					break;
				}
			}
			else
			{
				alert(id.id + " is required!");
				isGood = false;
				break;
			}
		}
		else
		{
			isGood = true;
		}
	}
	if (isGood)
	{
		sendEmail(ids);
	}
	return isGood;
}
function sendEmail()
{
		// strip array of any bad values
		for (i=0;i<=arr.length;i++)
		{
			var id = document.getElementById(arr[i]);
			try
			{
				id.value.Replace("<", "");
				id.value.Replace("/>", "");
				id.value.Replace("[", "");
				id.value.Replace("]", "");
				id.value.Replace("'", "");
				id.value.Replace("\"", "");
				id.value.toLowerCase().Replace("select", "");
			}
			catch(err)
			{}
		}

	var form = document.getElementById('ContactUs');

	//ajax email
}
var OptionVal1 = "";
var OptionName1 = "";
var amount = "";
function ItemOpt(val)
{
    var arr = val.split(", ");
    OptionVal1 = arr[1];
    amount = arr[0];
    OptionName1 = "Item";//arr[1];

}
function AddToCart(item_name, item_number, amount, shippingamount, strOpt)
{
    
    var optName = "";
    
    if (strOpt == "")
    {
        optValue = "";
        optName = "";
    }
    else 
    {
        var optDll = document.getElementById(strOpt);
        optIndex = optDll.selectedIndex;

        optValue = optDll.options[optIndex].text;
        optName = "Option ";
    }
    var atcForm = document.getElementById("AddToCart");
    document.getElementById("item_name").value = item_name;
    document.getElementById("item_number").value = item_number + " : " + item_name;
    document.getElementById("amount").value = amount;
    document.getElementById("on0").value = OptionName1;
	document.getElementById("os0").value = OptionVal1;
    document.getElementById("on1").value = optName;
	document.getElementById("os1").value = optValue;
	//document.getElementById("no_shipping").value = shipping;
	document.getElementById("shipping").value = shippingamount;	
	atcForm.action = "https://www.paypal.com/cgi-bin/webscr"
	atcForm.method = "Post"
	atcForm.target = "paypal"
	atcForm.submit()
	
	strOpt = "";
	optValue = "";
	optName = "";
}
//View Cart
function viewCartpp()
{
	var x = document.getElementById("viewCartform");
	x.action = "https://www.paypal.com/cgi-bin/webscr";
	x.method = "Post";
	x.target = "paypal";
	//document.getElementById("business").value = "";
	x.submit();
}
function MakePayment()
{
	//window.location = window.location;

	var frm = document.getElementById('MakePaymentForm');
	document.getElementById('item_name').value = document.getElementById('txtItemName').value
	document.getElementById('item_number').value = document.getElementById('txtItemNo').value
	document.getElementById('amount').value = document.getElementById('txtAmount').value
	frm.action="https://www.paypal.com/cgi-bin/webscr";
	frm.method = "Post";
	frm.target = "paypal";
	frm.submit();
	
	//pause(5000);
}
function pause(milSec) 
{
 var now = new Date();
 var exitTime = now.getTime() + milSec;
   while (true)
   {
   	now = new Date();
   	if (now.getTime() > exitTime)
   		return;
   }
}
// adds new pricing and pricing description
var rowCnt = 0;
function AddNewItemPriceRow(divID)
{
    var el = document.getElementById(divID);
    el.style.display="block";
    //rowCnt += 1;    
    //var row = "<div><span>Price:</span><input type=\"text\" id=\"price"+rowCnt +"\"  /> Add Option Description:<input type=\"text\" id=\"priceDesc"+rowCnt +"\" style=\"width:200px;\" /> <a href=\"javascript:AddNewItemPriceRow('AddItemPrice');\">+ Add</a></div>";
    //el.innerHTML += row;
}
function RemoveNewItemPriceRow(id)
{
    var el = document.getElementById("p"+id);
    document.getElementById("price"+id).value = "";
    document.getElementById("priceDesc"+id).value = "";
    el.style.display="none";
}
//
function drawFlash(file,w,h)
{
	var str = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+w+"' height='"+h+"' id='Flash Animation' align='middle'>"
	str += "<param name='allowScriptAccess' value='sameDomain' />"
	str += "<param name='movie' value='" + file + "' />"
	str += "<param name='quality' value='high' />"
	str += "<param name='wmode' value='transparent' />"
	str += "<embed src='" + file + "' quality='high' wmode='transparent' width='"+w+"' height='"+h+"' name='Flash Animation' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
	str += "<" + "/" + "" + "object>"
	document.write(str);
}

var xmlHttp;
var myDiv;
var myPage;
function getData(elemID, page, query)
{ 
	myDiv = elemID; //the div to display data
	myPage = page; //the serverpage to get the data from
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url=page;
	url=url+"?q="+query;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById(myDiv).innerHTML=xmlHttp.responseText;
	}
	else
	{
		document.getElementById(myDiv).innerHTML = "<h3>Loading...</h3>";
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
try
{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
	{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
catch (e)
	{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
}
return xmlHttp;
}




/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="OfficeFeatures.aspx">Office Features</a>'
menu1[1]='<a href="MissionStatement.aspx">Mission Statement</a>'
menu1[2]='<a href="Contest.aspx">Contest</a>'
menu1[3]='<a href="Newsletter.aspx">Newsletter</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="YourFirstVisit.aspx">Your First Visit</a>'
menu2[1]='<a href="ChoosingOrthodontist.aspx">Choosing an Orthodontist</a>'
menu2[2]='<a href="FinancialInfo.aspx">Financial Information</a>'
menu2[3]='<a href="LifeWithBraces.aspx">Life with Braces</a>'
		
var menuwidth='165px' //165px default menu width
var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)

document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu









