// JavaScript Document

window.onload = init ; 

function init () {
	//alert(window.location)
	obj = document.getElementsByName("dup_link");
	//if its there init it 
	for(var x =0;x<obj.length;x++) {
		obj[x].onmouseover = disp_thumb ;
		obj[x].onmouseout = hide_disp_thumbs ;
	}
	// if theres a form init it 
	var strx = document.getElementsByName("confirm_cancel[]") ;
	if(document.getElementById("cancel_form")) {
		document.getElementById("cancel_form").onsubmit = check_cancel_form ;
	}
	
}
function disp_thumb() { // from the row we can determine the picid ie pic_0 pic_1 etc
	document.getElementById("mo_thumb").src= 'http://www.radfordjewellery.com/shop-photos/'+ this.id+'_thumb_125.jpg' ;
	document.getElementById("mo_thumb").style.display= "block" ;
	var arr = YAHOO.util.Dom.getXY(this.id) ;
	arr[0] = arr[0]+80;
	arr[1] = (arr[1]+10);
	var str = YAHOO.util.Dom.setXY("mo_thumb", arr);
	//alert(document.getElementById("mo_thumb").src);
	//document.getElementById("msg_c").innerHTML = " id="+this.id;
    var attributes = { 
	   height: { from: 25, to: 168 }, 
        width: {from: 25, to: 125 } 
    }; 
    var anim = new YAHOO.util.Anim('mo_thumb', attributes); 
	anim.animate(); 
	return false;

	//var str = YAHOO.util.Dom.setXY("mo_thumb", arr);

}
function hide_disp_thumbs() {
	var attributes = {
        width: { from: 125, to: 50 }
    };
    var anim = new YAHOO.util.Anim('mo_thumb', attributes);
	anim.animate(); 
	document.getElementById("mo_thumb").style.display= "none" ;
}

function check_cancel_form() {
	var c_count=0 ;
	var arr = document.getElementsByName("confirm_cancel[]") ; // get the number of tick boxes on page
	for(var i=0; i < arr.length; i++ ) {
		if(arr[i].checked) {c_count ++ ;} 
	}
	if(c_count<1) { 
		alert("You have no items ticked to cancel.") ;
		 return false ;
	} else { return true ; }
}
		
function show_cancel() {
	var strx = document.getElementsByName("confirm_cancel[]") ; // get the number of tick boxes on page
	var c_count=0 ;
	for(var i=0; i < strx.length; i++ ) {
		if(strx[i].checked) {
		c_count ++ ;
			document.getElementById("qty_to_cancel_"+i).style.display = "block" ;
		} else {
			document.getElementById("qty_to_cancel_"+i).style.display = "none" ;
		}
	}
	//document.getElementById("msg_c").innerHTML = "Cancelling "+ c_count +" lines." ;
}
		