var busy=false;

function openShipping(){
    link_stat=true;
    var newwindow = window.open(sitename + "help_s.cfm?mid=113#rates", 'shipping', 'width=502,height=678,scrollbars=yes,dependent=yes,resizable=no');
}


function openLargeImage(imageID){
    var newwindow=window.open(sitename + 'LargeImage.cfm?itemID=' + imageID, 'large', 'width=500,height=460,scrollbars=no,dependent=yes,resizable=no');
}

function openSendToFriend(pgType, itemID){
	var theType = (pgType == 'item') ? 'p=item&' : 'p=wishlist&';
	var thisURL = sitename + 'emailtofriend.cfm?'+ theType;
	width = 450;
	height= 400;
	x = screen.width/2 - width/2;
	y = screen.height/2 - height/2;
	if(itemID != ""){ 
		thisURL = thisURL + 'itemid=' + itemID;
	}
	var newwindow = window.open(thisURL,'tellfriend','width='+width+',height='+height+',left='+x+',top='+y+',screenx='+x+',screeny='+y+',status=yes,scrollbars=yes');
}


function NewVideoWindow(mypage,myname,h,w,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.availWidth)?Math.floor(Math.random()*(screen.availWidth-w)):300;TopPosition=(screen.availHeight)?Math.floor(Math.random()*((screen.availHeight-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.availWidth)?(screen.availWidth-w)/2:300;TopPosition=(screen.availHeight)?(screen.availHeight-h)/2:100;}
	if(pos=="default"){LeftPosition=50;TopPosition=50}
	else if((pos!="center" && pos!="random" && pos!="default") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
	if(win.focus){win.focus();}
}


function Add2ShopCart(form)
{
        link_stat=true;
        var ispersonalized = true;
        var isvarselected  = true;

        if(form.peronalize && !form.peronalize.checked){
            ispersonalized = false;
            alert("Please verify your personalization is correct and check 'Click here to confirm personalization is correct' in order to add this product to your shopping cart.");
        }

        if(form.itemID && form.itemID.value.length == 0){
            isvarselected = false;
            alert("Please select an option to add to the cart.");
			return false;
        }

        if (!busy && ispersonalized && isvarselected) {
                busy = true;
                
                form.action="cart.cfm";
                
              
               return true;
        }
		
		return false;
}


function updateImage(imageSelect) {
 var theImageIndex = imageSelect.selectedIndex;
 var imageSource = sitename + "images/products/medium/" + eval("img" + theImageIndex) + ".jpg";
 if (document.getElementById("productImage"))
     document.getElementById("productImage").src = imageSource;
 
 if(document.getElementById("viewLargeImage"))
 	document.getElementById("viewLargeImage").href = "javascript:openLargeImage('" + eval("img" + theImageIndex) + "')";
 
 if(document.getElementById("largeImageLink"))
 	document.getElementById("largeImageLink").href = "javascript:openLargeImage('" + eval("img" + theImageIndex) + "')";

}
