function matchHeight()
{
	if($('content').offsetHeight < 500) {
		$('content').style.height = '500px';
		$('leftNav').style.height = '800px';
	}
	
	$('leftNav').style.height = ($('content').offsetHeight-70) + 'px';
	//$('bodyDiv').style.height = ($('content').offsetHeight) + 'px';
}

function matchHeight2()
{
	if($('content_admin').offsetHeight < 400)
		$('content_admin').style.height = '400px';
	$('menu').style.height = ($('content_admin').offsetHeight-50) + 'px';
}

function matchHeight3()
{
	if($('content_store').offsetHeight < 400)
		$('content_store').style.height = '400px';
//	$('menu').style.height = ($('content_store').offsetHeight-50)+'px';
	$('leftNav').style.height = ($('content_store').offsetHeight-50)+'px';
}

function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function _() {
        var elements = new Array();
        for (var i = 0; i < arguments.length; i++) {
                var element = arguments[i];
                if (typeof element == 'string')
                        element = document.getElementsByName(element);
                if (arguments.length == 1)
                        return element;
                elements.push(element);
        }
        return elements;
}


function printme() {
	print('document');
}

function changeStatus(id) {
// var tn = document.forms[0].trackingnumber.value;
 var tn = $('trackingnumber').value;
 window.location='?action=setshipped&id=' + id + '&tn=' + escape(tn);
}


function showfirsthunt(){
  if ($('permit_type').value == '2') {
   $('firsthunt1').style.display = '';
   $('firsthunt2').style.display = '';
   $('firsthunt3').style.display = 'none';
   $('temporarynotice').style.display = 'none';
  }
  else if ($('permit_type').value == '1') {
   $('temporarynotice').style.display = '';
   $('firsthunt1').style.display = 'none';
   $('firsthunt2').style.display = 'none';
   $('firsthunt3').style.display = '';
  }
  else {
   $('firsthunt1').style.display = 'none';
   $('firsthunt2').style.display = 'none';
   $('temporarynotice').style.display = 'none';
   $('firsthunt3').style.display = '';
  }
}

function changepermitseason(){
}

function samebillingoption($addr,$city,$state,$zip) {
 if (document.forms[0].samebilling.checked == true) {
  document.forms[0].b_address.value = $addr;
  document.forms[0].b_city.value = $city;
  document.forms[0].b_state.value = $state;
  document.forms[0].b_zipcode.value = $zip;
 }
 else {
  document.forms[0].b_address.value = '';
  document.forms[0].b_city.value = '';
  document.forms[0].b_zipcode.value = '';
 }
}

function sameasbilling() {
 if (document.forms[0].sameAsBilling.checked == true) {
  document.forms[0].m_address.value = document.forms[0].address.value;
  document.forms[0].m_city.value = document.forms[0].city.value;
  document.forms[0].m_state.value = document.forms[0].state.value;
  document.forms[0].m_zipcode.value = document.forms[0].zipcode.value;
 }
 else {
  document.forms[0].m_address.value = '';
  document.forms[0].m_city.value = '';
  document.forms[0].m_zipcode.value = '';
 }
}

function hightlightarea(o,set) {
  o.style.backgroundColor=set;
}

function buttonconfirm(cmt) {
 var answer = confirm(cmt);
 if (answer) {
   return true;
  }
  else {
   return false;
  }
}

function itemupdate(ln,id,color,size) {
 var amt = $(ln).value;
 window.location='./cart.php?update=1&id=' + id + '&color=' + color + '&size=' + size + '&amt=' + amt;
}

function itemremove(id,color,size) {
 window.location='./cart.php?remove=1&id=' + id + '&color=' + color + '&size=' + size;
}

String.prototype.Trim = function ()
{
        return this.replace(/^\s+|\s+$/g, '');
}

function getTotal(z,w,st,doTax) {
 	//var m = $(shipping).value;
 	var m = document.forms[0].shipping.options[document.forms[0].shipping.selectedIndex].value
 	var url = 'http://ynwildlife.yakima.net/store/ajax_getShipping.php';
 	var qstr = 'm=' + m + '&z=' + z + '&w=' + w;
 	var res = xmlhttpPost(url,qstr,st,doTax);
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) {
		num = '0';
        }
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10) {
			cents = "0" + cents;
	}
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {
				num = num.substring(0,num.length-(4*i+3))+','+
				num.substring(num.length-(4*i+3));
	}

	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function xmlhttpPost(strURL,strQRY,st,doTax) {
    	var xmlHttpReq = false;
    	var self = this;
    	var tax = 0.00;

    	// Mozilla/Safari
    	if (window.XMLHttpRequest) {
        	self.xmlHttpReq = new XMLHttpRequest();
    	}
    	// IE
    	else if (window.ActiveXObject) {
        	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	self.xmlHttpReq.open('POST', strURL, true);
    	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    	self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            	str = self.xmlHttpReq.responseText;
            	str.Trim();
            	str = parseFloat(str);
            	st = parseFloat(st);
           	if (doTax == 1) {
             		tax = (str + st) * .086;
            	}
            	$('tax').innerHTML = formatCurrency(tax);
            	$('total').innerHTML = formatCurrency(str + st + tax);
    	}
}
    self.xmlHttpReq.send(strQRY);
}

function showCVVdetails() {
        var posx = 0;
        var posy = 0;
        if (!e) var e = window.event;
        if (e.pageX || e.pageY)         {
                posx = e.pageX;
                posy = e.pageY;
        }
        else if (e.clientX || e.clientY)        {
                posx = e.clientX + document.body.scrollLeft
                        + document.documentElement.scrollLeft;
                posy = e.clientY + document.body.scrollTop
                        + document.documentElement.scrollTop;
        }
    //alert(posx + ',' + posy);
        l = 245;
        h = 205;

        $('showcvv').style.width = l + "px";
        $('showcvv').style.height = h + "px";
$('showcvv').className='hintBox';
        $('showcvv').style.left = posx+5 + "px";
        $('showcvv').style.top = posy-30 + "px";
        $('showcvv').style.display = '';

}

function hideCVVdetails() {
		$('showcvv').style.display = 'none';
}

function changeToWaitIcon() {
	$('submit').style.display = 'none';
	$('waiticon').style.display = '';
	return true;
	}
