		
function isNumeric(inputVal, allowDec) { 
   oneDec = (!allowDec); //false;
   inputX = inputVal.toString(); 
   for (var i = 0; i < inputX.length; i++)  {
       var oneChar = inputX.charAt(i); 
       if (i == 0 && oneChar == " - ") { 
           continue 
       } 
       if (oneChar == "." && !oneDec) { 
           oneDec = true; 
           continue 
       } 
       if (oneChar < "0" || oneChar > "9" ) { 
           return false; 
       } 
   } 
   return true; 
} 


	
function openItemNotify(itemno){
	window.open("/item/ItemNotify.aspx?itemno=" + itemno,"notifywin","width=500,height=400");
}

function openWarranty(itemno) {
	window.open('/item/warranty.aspx?itemno=' + itemno, 'myname', 'width=600,height=200');
}	

function openOversizeRestrictions() {
	window.open("/item/OversizeRestrictions.aspx","win","width=400,height=200");
}

function openReviewForm() {
	var rating = document.forms['rateform'].rating.value;
	var prodid = document.forms['rateform'].p.value;
	var uid = document.forms['rateform'].uid.value;
	var itemno = document.forms['rateform'].itemno.value;
	window.open('/reviews/review.aspx?p=' + prodid + '&uid=' + uid + '&rating=' + rating + '&itemno=' + itemno ,'myname','width=600,height=800,scrollbars=yes');
	return false;
}
function openReviewFormP(prodid,itemno,uid,rating) {
	window.open('/reviews/review_item.asp?p=' + prodid + '&uid=' + uid + '&rating=' + rating + '&itemno=' + itemno ,'myname','width=600,height=800,scrollbars=yes');
}
function openReviewForm2(prodid,uid) {
	window.open('/reviews/review_item.asp?p=' + prodid + '&uid=' + uid + '&rating=5','myname','width=600,height=800,scrollbars=yes');
}
function openExtraImages(prodid,image) {
	window.open('/item/extraimages.aspx?p=' + prodid + '&i=' + image,'myname','width=1050,height=800');
}
function openLargeImage(s) {
	window.open('/item/expandedimage.aspx?img=' + escape(s), 'myname', 'width=600,height=600');
}
function openOptionImage(s) {
	window.open('/item/expandedimage.aspx?t=4&img=' + escape(s), 'myname', 'width=800,height=800,scrollbars=yes,resizable=yes');
}
function openZoomImage(s) {
	window.open('/item/expandedimage.aspx?t=5&img=' + escape(s), 'myname', 'width=800,height=800,scrollbars=yes,resizable=yes');
}
function openBlem() {
	window.open('blemished.html', 'myname', 'width=400,height=150');
}
function itemIndex(itm, itms) {
	if (itms.length == 1)
		return 0;
	
	for (var n =0; n<itms.length; n++) {
		if (itm == itms[n])
			return n;
	}
	return -1;
}
function optionCheck(chk, ix, type) {
	var qty;
	var index;

	index = itemIndex(chk, document.forms['available_options'].poadd);
 	
	if (document.forms['available_options'].poadd.length > 1) {
		qty = document.forms['available_options'].qty[index];
	} else {
		qty = document.forms['available_options'].qty;
	}
	if (chk.checked)
		qty.value = "1";
	else
		qty.value = "";
	
}
function qtyChange(txt, ix, type) {

	var index;

	index = itemIndex(txt, document.forms['available_options'].qty);

//	if (document.forms['available_options'].qty.length > 1)
//		var chk = document.forms['available_options'].poadd[index];
//	else
//		var chk = document.forms['available_options'].poadd;
//
//	if (txt.value != '')
//		chk.checked =true;
//	else
//		chk.checked = false;
}





function addToWishList() {
	var frm = document.forms['available_options'];
	
		frm.action = "/MyAccount/wishadd.aspx";
		frm.method = "POST";
		frm.submit();
	
}

function openCustomShopDef(){
	self.name = 'parentwindow';
	window.open("/item/CustomDef.aspx","win","width=450,height=600");
}


function cycleProductSwatches()
{
    var i = 0;
    while (true)
    {
        var ctrlid = "productswatch" + i++;
        if (document.getElementById(ctrlid))
        {
            if (document.getElementById(ctrlid).style.display == '')
            {
                document.getElementById(ctrlid).style.display = 'none';
                
                // set next set of swatches to visible
                ctrlid = "productswatch" + i++;
                if (document.getElementById(ctrlid))
                {
                    loadSwatchImagesByContainerId(ctrlid);
                    document.getElementById(ctrlid).style.display = '';
                }
                else            
                {                
                    // user already cycled through all swatches, go back to begining
                    document.getElementById('productswatch0').style.display = '';
                }
            }
        }
        else        
        {
            break;
        }                
    }    
}
// loads all of the images for the section with the given containerid
function loadSwatchImagesByContainerId(containerid)
{
    var i = 0;
    while (true)
    {
        var ctrlid = containerid + "image" + i++;
        if (document.getElementById(ctrlid))
        {
            document.getElementById(ctrlid).src = document.getElementById(ctrlid).getAttribute("tag");
        }
        else        
        {
            break;
        }                
    }    
}



function selectByValue(select, value)
{
for (var i = 0; i < select.options.length; i++) {
   if (value == select.options[i].value) {
        select.options[i].selected = true;
      break;
   }   
}
return;
}
function doPaging(page,pageprefix)
{
    var i = 0;
    while (true)
    {
        var ctrlid = pageprefix + i;
        if (document.getElementById(ctrlid))
        {
            if(++i == page)
            {
                var pgctrl = document.getElementById(ctrlid);        
                pgctrl.style.display = '';     
                setImages(pgctrl);           
            }
            else
            {
                document.getElementById(ctrlid).style.display = 'none';
            }            
        }
        else        
        {
            break;
        }                
    }    
        
    i = 0;
    while (true)
    {        
        var linkctrlid = pageprefix + "p" + i;
        var hrefLinkCtrlId = document.getElementById(linkctrlid);

        if (document.getElementById(linkctrlid))
        {                                                      
            if(++i == page)
            {
                hrefLinkCtrlId.removeAttribute('href');
                hrefLinkCtrlId.className = "selectedPage";            
            }
            else
            {
                document.getElementById(linkctrlid).href = document.getElementById(linkctrlid).getAttribute("tag");  
                hrefLinkCtrlId.className = "unSelectedPage";            
                              
            }            
        }
        else        
        {
            break;
        }                
    }       
}
function setImages(ctrl)
{    
    if (ctrl.tagName)
    {
    var tg = ctrl.getAttribute("tag");
    }
    if (tg)
    {
        if(tg != '')
        {            
            ctrl.src = tg;
        }
    }
    var i=0;
    while (ctrl.childNodes[i])
    {
        setImages(ctrl.childNodes[i]);
        i++;
    }
}
function prevSwatch(imgid)
{
    var img = document.getElementById(imgid);
    if (img.className != "swatchSel")
    {
        img.className="swatchPrev";        
        document.getElementById("lastimgprev").value=img.id;
    }
}
function undoPrevSwatch()
{
var lastPrev = document.getElementById(document.getElementById('lastimgprev').value);
if (lastPrev && lastPrev.className != "swatchSel")
{
    lastPrev.className='swatchUnSel';
}
}
function clearZoom()
{
document.getElementById('lastimgzoom').value="";
}