var sPath = window.location.pathname;
var selected;
function createMarker(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(html);
        });
        return marker;
    }

function cart_price_adjust(obj) {
    var priceNode = obj.parentNode.previousSibling.firstChild;
    if( priceNode == null ) { // ie skullduggery
        priceNode = obj.parentNode.previousSibling.previousSibling.firstChild;
    }
    var price = priceNode.data.substr(1);
    var subtotalNode = document.getElementById("cart_subtotal_price").firstChild;
    var totalNode = document.getElementById("cart_total_price").firstChild;
    try {
        var subtotal = subtotalNode.data.substr(1);
        subtotal = subtotal.replace(",","");
        var newPrice = parseFloat(subtotal) + parseFloat(price);
        totalNode.data = "$" + newPrice;
    } catch(err) {
        alert("Error: "+err.message);
    }
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function load() {
    MM_preloadImages('/images/nav_menu_left.jpg','/images/nav_menu_right.jpg','/images/cart_active.jpg','/images/checkout_active.jpg');
    if( document.getElementById('flash')){
	setTimeout("document.getElementById('flash').style.background = 'none'", 1500);
    }
    if( document.getElementById('productNEWprice')) {
	
        var priceSink = null;
        var template = null;
        var root = null;

	/* Test all possible templates for 
           style of price element in DOM */
	priceSink = document.getElementById( "mattress size" );
        template = "mattress size";
        if( priceSink == null ) {
            priceSink = document.getElementById( "Pillow Size" );
            template = "Pillow Size";
        }
	if( priceSink == null ) {
	    priceSink = document.getElementById( "Duvet Size" );
            template = "Duvet Size";
	}
	if( priceSink == null ) {
	    priceSink = document.getElementById( "Choose One" );
            template = "Choose One";
	}
	if( priceSink == null ) {
            priceSink = document.getElementById( "Choose Color" );
            template = "Choose Color";
	}
	if( priceSink == null ) {
	    priceSink = document.getElementById( "" );
            template = "unknown";
	}

	root = priceSink.childNodes[0].childNodes[0].childNodes[0].childNodes[0];
        if( document.getElementById('add_to_cart_container') ) {
          showPrice2( root, template );
        } else {
          showPrice( root, template );
        }
    }

    if( sPath=='/contact.php'){
	if (GBrowserIsCompatible()) {
         
        var clemsonInfo = '<div><h3>Clemson Showroom</h3><div>139 Anderson Hwy Suite 190<br />Clemson, SC 29631</div></div>';
        var columbiaInfo = '<div><h3>Columbia Showroom</h3><div>1219 Wayne Street<br />Columbia, SC 29201</div></div>';
        var map = new GMap2(document.getElementById ("map"));
        var point = new GLatLng(34.688043, -82.826252);
        map.setCenter(point, 13);
        var zoomControl = new GSmallMapControl();
        map.addControl(zoomControl);
        var marker = createMarker(point, clemsonInfo);
	// var marker = createMarker(point);
        map.addOverlay(marker);
        //marker.openInfoWindowHtml(clemsonInfo);
       
       
       
      }
    }
}

function selectRowEffect(object, buttonSelect) {
  if (!selected) {
    if (document.getElementById) {
      selected = document.getElementById('defaultSelected');        
    } else {
      selected = document.all['defaultSelected'];
    }
  }

  if (selected) selected.className = 'moduleRow';
  object.className = 'moduleRowSelected';
  selected = object;

// one button is not an array
/*
  if (document.checkout_payment.payment[0]) {
    document.checkout_payment.payment[buttonSelect].checked=true;     
  } else {
    document.checkout_payment.payment.checked=true;
  }
*/
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

function newwindow()
{
window.open('cvv_help.php','jav','width=500,height=550,resizable=no,toolbar=no,menubar=no,status=no');
}
function idSwap(idOne, idTwo){
	if(document.getElementById(idOne))
		document.getElementById(idOne).id = idTwo;
}
function makeVisible(tabID, buttonID){
	document.getElementById("tabOne").style.display = "none";
	document.getElementById("tabTwo").style.display = "none";
	document.getElementById("tabThree").style.display = "none";
	idSwap("tabButtonOne_A", "tabButtonOne");
	idSwap("tabButtonTwo_A", "tabButtonTwo");
	idSwap("tabButtonThree_A", "tabButtonThree");
	document.getElementById(buttonID).id = buttonID + "_A";
	document.getElementById(tabID).style.display = "block";
}
$(document).ready(function () {
    $('h1.copy_head').click(function () {
        $('div.copy').slideToggle('medium');
    });
});

