function GetHoverEffect(btn, img)
    {
    if (document.images) 
	    {
		MyButton = new Image;		
		MyButtonShaded = new Image;
		switch (img) 
		    {
			case "1":
			    MyButton.src = 'images\\RWViewCart.gif';
				MyButtonShaded.src = 'images\\RWViewCartHover.gif';
				break;
            case "2":
			    MyButton.src = 'images\\RWAddToCart.gif';
				MyButtonShaded.src = 'images\\RWAddToCartHover.gif';
				break;
            case "3":
			    MyButton.src = 'images\\RWCheckOut.gif';
				MyButtonShaded.src = 'images\\RWCheckOutHover.gif';
				break;
            case "4":
			    MyButton.src = 'images\\RWClearCart.gif';
				MyButtonShaded.src = 'images\\RWClearCartHover.gif';
				break;
            case "5":
			    MyButton.src = 'images\\RWContinueShopping.gif';
				MyButtonShaded.src = 'images\\RWContinueShoppingHover.gif';
				break;
			case "6":
				MyButton.src = 'images\\RWEmailMe.gif';
				MyButtonShaded.src = 'images\\RWEmailMeHover.gif';
				break;
            }
            if (btn=="1") return MyButtonShaded.src;
			if (btn=="2") return MyButton.src;
        }
    else 
	    {
		MyButton = '';
        MyButtonShaded = '';
        }
	}
	
// open popup info windows
function winfoopen(InfoPage, name, w, h) 
    {
    w += 10; 
	h += 20; 
    wleft = (screen.width - w) / 2; 
	wtop = (screen.height - h) / 2; 
	var parms = 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop;
    var win = window.open('RWInfoWindow.aspx?wdw=' + InfoPage, name, parms + ', location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no'); 
	if (window.focus) {win.focus()}; 
    }

function OpenUserChat(usr)
    {
        if (usr != 'ddlConvos')
            return false;
        
        var usrName;
        var el;

        el = document.getElementsByName(usr);
        if (el.length == 0)
            return false;
            
        usrName = el[0].value;
        if (usrName == "-- select user --")
            return false;
        
        winfoopen('-1&usr=' + usrName, replaceAll(usrName," ",""), 500, 500);
        return false;
    }

function replaceAll(text, strA, strB)
{
    return text.replace( new RegExp(strA,"g"), strB );    
}


    
// REGISTER WINDOW

// open register window
function wopenregister(InfoPage, name, w, h) 
    {
	w += 10; 
	h += 20; 
    wleft = (screen.width - w) / 2; 
    wtop = (screen.height - h) / 2; 
	var parms = 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop;
    var win = window.open(InfoPage, name, parms + ', location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no'); 
	if (window.focus) {win.focus()}; 
    }

function document_onkeydown(confirm) 
    {
	if ((window.event.ctrlKey)&&(window.event.keyCode==86)) 
	    { 
		alert('You cannot copy into the confirm box.');
		event.returnValue = false;
		}
    }		

function RemovePhoneFormatting(txtPhone) 
    {
	var txt = document.getElementById(txtPhone).value;
	txt = txt.replace("(","").replace(")","").replace(" ","").replace("-","");
	document.getElementById(txtPhone).value = txt;
	document.getElementById(txtPhone).select();
    }

function ResetPhoneFormatting(txtPhone) 
    {
	var txt = document.getElementById(txtPhone).value;
	txt = txt.replace("(","").replace(")","").replace(" ","").replace("-","");
	var strValidChars = "0123456789"; 
	var strChar;
	var txtNew = "";
	for (i = 0; i < txt.length; i++) 
	    { 
		strChar = txt.charAt(i); 
		if (strValidChars.indexOf(strChar) !== -1) 
		    { 
			txtNew = txtNew + strChar;
		    }
        }
    txt = txtNew;
	if (txt.length >= 10) 
	    {
		txt = txt.substring(0,10);
		txt = "(" + txt.substring(0, 3) + ") " + txt.substring(3, 6) + "-" + txt.substring(6);
	    }
    document.getElementById(txtPhone).value = txt;
    }
                
function HideSubmit(valid)
    {
    document.getElementById("btnSubmit").style.display="none";
    document.getElementById("btnValidate").style.display="none";
    if (valid==1)
        {
        var txt = document.getElementById("txtError");
        txt.style.display="block";
        txt.value = "Sending validation email to your email account...";
        txt.style.color = "#518ce6"
        }
    }

// END REGISTER WINDOW

// open item detail pictures
function wopendetailpic(imgpath, ItemNo, Title, w, h) 
    {
	var img = document.getElementById(imgpath).src;
    w += 10; 
	h += 20; 
	wleft = 0; //(screen.width - w); 
	wtop = 0; //(screen.height - h); 
	w = screen.width - 20;
	h = screen.height - 50;
	var parms = 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes';
    var win = window.open('RWPictureWindow.aspx?img=' + img + '&itm=' + ItemNo + '&tit=' + Title, 'DetailPicture', parms);
	if (window.focus) {win.focus()}; 
	}

// open gallery pictures
function wopengallerypic(picImage, ItemNo, Title, w, h) 
    {
   	w += 10; 
    h += 20; 
	wleft = (screen.width - w) / 2; 
	wtop = (screen.height - h) / 2; 
	var parms = 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes';
   	var win = window.open('RWPictureWindow.aspx?img=' + picImage + '&itm=' + ItemNo + "&tit=" + Title + "&bckclr=1", 'GalleryPicture', parms); 
	if (window.focus) {win.focus()}; 
	}

function IsUserLoggedOn(email)
    {
    if (email=="")
        {
       	var w = 700; 
        var h = 400; 
	    var wleft = (screen.width - w) / 2; 
	    var wtop = (screen.height - h) / 2; 
        var parms = 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes';
        window.open('RWInfoWindow.aspx?wdw=15', "Login", parms);
        }
    }
    
// hide error window
function HideError()
    {
    document.getElementById("txtError").setAttribute("value","");
    document.getElementById("txtError").setAttribute("border","none");
    }
    
// hide error window
function HideError2(err)
    {
    if (err.value!="This item is pending a sale.")
        {
        document.getElementById("txtError").setAttribute("value","");
        document.getElementById("txtError").setAttribute("border","none");
        }
    }

function wsearchopen(search) 
	{
	var srch = document.getElementById(search).value;
	if (srch=="")
	    {
	    return false;
	    }
	srch = srch.replace('<','').replace('>','');
	document.getElementById(search).value = srch;
	var win = window.open('Search.aspx?s=' + srch,'_blank'); 
	if (window.focus) {win.focus()}; 
	return false;
	} 

function UpdateUserCart()
    {
    return true;
                
    var desc;
    var itemno;
    var quantity;
    var price;
    var weight;
    var imageurl;
    var i;
                
    desc = document.getElementById("txtDescription").value.split("|");
    itemno = document.getElementById("txtItemNo").value.split("|");
    quantity = document.getElementById("intQuantity").value.split("|");
    price = document.getElementById("decPrice").value.split("|");
    weight = document.getElementById("decWeight").value.split("|");
    imageurl = document.getElementById("strImageURL").value.split("|");

    for(i=0; i < desc.length; i++)
        {
        SetDesc(desc[i]);
        SetCode(itemno[i]);
        SetQty(quantity[i]);
        SetPrice(price[i]);
        SetWt(weight[i]);
        SetImg(imageurl[i]);
        var msg = "";
        msg = ReadForm (this, true);
        if (msg.length==0) 
            {
            CallView ();
            }
        ClearAll ();
        }
    return true;
    }

// toggle datalist panel for multi-level sites like Unique Creations and Children's Furniture
function ToggleMultiLevelDL(rptr) 
    {
    var rptrstyle = document.getElementById(rptr).style;
    if (rptrstyle.display == "none")
        {
        rptrstyle.display = "block";
        }
    else
        {
        rptrstyle.display = "none";
        }
    return false;
    }
    
// toggle datalist panel for the Gallery
var win = "";
function ToggleGalleryDL(pnl,fldr,clss,lnkid,lnkitems,show) 
    {
    if (document.getElementById(lnkitems).innerText.substring(0,1) == 0)
        {
        return false;
        }
    if (show == 0)
        {
        if (document.getElementById(pnl).style.display == "none")
            {
            document.getElementById(lnkitems).setAttribute("title","Click here close the thumbnails!");
            if (document.getElementById("hidRptr").value == 1)
                {
                document.getElementById(pnl).style.display = "block";
                var clssOld = document.getElementById("hidClss").value;
                if (clssOld == clss)
                    {
                    return false;
                    }
                else
                    {
                    document.getElementById("hidClss").value = clss;
                    return true;
                    }
                }
            else
                {
                return true;
                }
            }
        else
            {
            if (show == 0) 
                {
                document.getElementById(pnl).style.display = "none";
                document.getElementById(lnkitems).setAttribute("title","Click here view the thumbnails!");
                }
            return false;
            }
        }
    else
        {
        if (!win.closed && win.location)
            {
            win.close();
            }
        var w = (screen.width-10)*3/4;
        var h = (screen.height-65)*3/4;
		var wleft = (screen.width-10 - w)/2; 
		var wtop = (screen.height-65 - h)/2; 
		var parms = 'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', location=no, menubar=no, status=yes, toolbar=no, scrollbars=yes, resizable=yes';
        win = window.open("GalleryPics.aspx?fldr=" + fldr + "&clss=" + clss, "slideshow", parms);
        if (!win.opener)
            {
            win.opener = self;
            }
        if (window.focus)
            {
            win.focus();
            }
        return false;
        //changed this to false so only slide show plays
        }
    }

// OBSOLETE: add item to cart
function AddToCart(desc, itemno, price, weight, qtyflag, image, currentemail)
    {
    var qty = document.getElementById("txtQuantity").value;
    if (!isNumeric(qty) || qty<=0) 
        {
        document.getElementById("txtError").setAttribute("value","Quantity must be a positive, numeric value.");
        document.getElementById("txtQuantity").value = 1;
        return;
        //return false;
        }
        
    var parms = 'width=10, height=10, left=0, top=0, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no';
	var procwin = window.open("RWProcessing.aspx?itm=" + itemno + "&upd=1&em=" + currentemail + "&qty=" + qty,"proc",parms);
	var pend = "";
	var email = "";
	while (pend=="")
	    {
	    try
	        {
	        pend = procwin.document.getElementById("lblPend").innerText;
	        email = procwin.document.getElementById("lblEmail").innerText;
	        }
	    catch(err)
	        {
	        }
	    }
	procwin.close();

	if (pend=="0")
	    {
        SetDesc(desc);
        SetCode(itemno);
        SetQty(qty);
        SetPrice(price);
        SetWt(weight);
        SetImg(image);
        ReadForm(this, true);
        document.getElementById("txtError").style.display="block";
        document.getElementById("txtError").setAttribute("value","This item has been added to your cart.");
		}
    else if (pend=="1")
	    {
        document.getElementById("txtError").style.display="block";
	    if (email==currentemail)
	        {
	        if (qtyflag==1)
	            {
                document.getElementById("txtError").setAttribute("value","This item is already in your cart.  It will stay in your cart for 1 day or until you check out.\nTo change the quantity you must first delete the item from your cart.");
	            }
	        else
	            {
                document.getElementById("txtError").setAttribute("value","This item is already in your cart.  It will stay in your cart for 1 day or until you check out.");
	            }
	        }
	    else
	        {
            document.getElementById("txtError").setAttribute("value","This item is pending a sale.");
            }
        }
    else
        {
        document.getElementById("txtError").style.display="block";
        document.getElementById("txtError").setAttribute("value","There is something wrong with your order.\nPlease 'Contact Us' at Kimberly.Wakeman@RainbowAndWish.com.");
        }
    }

// check out
function CheckOptions()
    {
    if (!document.getElementById('chkTerms').checked)
        {
        var err = document.getElementById('txtError');
        err.value = 'You must agree to the terms and conditions.';
        err.style.display = "block";
        err.style.font.bold = true;
        err.style.color = "#ff6600";
        return false;
        }
    return true;
    }
    
// is numeric test
function isNumeric(vTestValue)
    {
    //alert("isnumeric");
	var sField = new String(vTestValue.replace(/^\s+|\s+$/g, '') );
	if (sField.length==0) 
	    { 
	    return false; 
	    }
    else if (sField.length==1 && (sField.charAt(0) == '.' || sField.charAt(0) == ',' || (sField.charAt(0) == '-'))) 
	    { 
	    return false; 
	    }
    for (var x=0; x < sField.length; x++) 
        {
		if ((sField.charAt(x) >= '0' && sField.charAt(x) <= '9') || sField.charAt(x) == '.' || sField.charAt(x) == ',' || (sField.charAt(x) == '-' && x==0)) 
		    { 
		    //do nothing;
		    }
        else 
		    { 
		    return false; 
		    }
        }
        return true;
    }

// Pour coffee
	var div;
	var lnk;
	var img;
	function coffee()
		{
		div = document.getElementById("pourcoffee");
		img = document.getElementById("imgPourCoffee");
		lnk = document.getElementById("lnkPourCoffee");
		if (div.style.display=="none")
			{
			img.src = img.src.replace("CoffeeSmile","CoffeePour");
			div.style.display="block";
			lnk.innerHTML="MMMMmmmmmmm!";
			self.setTimeout("smilecoffee()",3500);
			}
		return false;		
		}
		
	function smilecoffee()
		{
		if (lnk.innerHTML=="Enjoy!!!")
			{
			return false;
			}
		img.src = img.src.replace("CoffeePour","CoffeeSmile");
		img.style.width='20%';
		lnk.innerHTML="Enjoy!!!"
		self.setTimeout("stoppouring()",8000);
		}

	function stoppouring()
		{
			div.style.display="none";
			lnk.innerHTML="Click here<br />to have a cup of coffee,<br />relax, and enjoy the site!";
			img.style.width='100%';
		}



// Browser detection (not necessary with control adapters?)
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
		//detectFMX();
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
};
BrowserDetect.init();


// Flash Detection
    var verFlash = '';
    
	function detectFMX()
	    {
		var reqVer = 26;
		var pluginChk = false;
		
		if (document.all)
		    {
			pluginChk = chkIe(reqVer); 
			//alert(verFlash);
		    } 
		else 
		    {
			if (navigator.plugins != null && navigator.plugins.length > 0) 
			    {
				var daPlugin = navigator.plugins['Shockwave Flash'];
				if (daPlugin) 
				    {
					for (i=9;i>0;i--)
					    {
						if (daPlugin.description.indexOf(i+'.') != -1)
						    {
							var flashVersion = i;
							break;
						    }
					    }
				    }
				
				if (!daPlugin || flashVersion < reqVer)
				    {
				    pluginChk = false; 
				    } 
				else 
				    {
				    pluginChk = true;     
				    }
			    }
		    }
	  
		if (pluginChk)
		    {
			// do something
			//alert("you have the current plugin");
		    } 
		else 
		    {
			// do something else
			var msg = '';
			msg = 'This site uses the Macromedia Flash Plugin to display content.\n';
			msg += 'Your version of Flash - ' + verFlash + ' - is outdated.\n\n';
			msg += 'You may upgrade to the latest version by going to www.macromedia.com.\n';
			msg += 'The plugin is safe, fast and painless to download.\n\n';
			msg += 'Would you like to go there now?';
			if (confirm(msg)){
				document.location='http://www.macromedia.com/downloads/';
			} 
		}
	}	

function chkIe(reqVer)
    {
    verFlash = '';
    try
        {
        var success = false;
		var flashVer = 0;
		for (var i = 12; i > 0; i--)
		    {
		    try
		        {
			    var oFlash = new ActiveXObject("shockwaveflash.shockwaveflash." + i);
			    }
			catch(err)
			    {
			    }
			if (oFlash)
			    {
			    flashVer = i;
			    verFlash = oFlash.GetVariable("$version");
			    break;
			    }
            }
    	if (flashVer >= reqVer)
    	    {
			success = true;
			}
	    else
	        {
			success = false;
			}
		return success;
        }
    catch(err)
        {
        }
    }

function trim(str)
{
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}    