// JavaScript Document
function copywhenmountclicked(id,price,artworkno)
	{
						
						
		document.getElementById('frameid').value=id;
		document.buyArtWorkForm.framename.value=document.getElementById('frame'+id).alt;
					
		document.buyArtWorkForm.frameprice.value=price;
							
							//document.buyArtWorkForm.artworkframeid.value=artworkno + "&" + id;
							
		document.buyArtWorkForm.artworkframeid.value=document.buyArtWorkForm.prodNo.value + "&" + document.buyArtWorkForm.frameid.value + "&" + document.buyArtWorkForm.slipFrame.value ;
							
						

	}//end of coypwhenmountlclicked
						
						
function basketDisplayFrameImage(frameid, width1, height1, filenames , id, artworkno, allmount, bottommount, allgap, bottomgap,  topcolor, leftcolor , rightcolor, bottomcolor, params, intW, intH, slipid, slipwidth, count, thirdmountcolor,thirdmountwidth)
{
	//alert(count);
	//alert(params);
	var temp=params.split ('&');
	
	var mounttype=temp[3];
	//alert (mounttype);
							
	
	topcolor    = '#'+topcolor;
	leftcolor   = '#'+leftcolor;						
	rightcolor  = '#'+rightcolor;
	bottomcolor = '#'+bottomcolor;
	
	
	var org_frame_width=width1;
	var org_frame_height=height1;
							
	var displayDimension;
	var displayAfterResults;
			
	var TotalWidth;
	var TotalHeight;
							
							
	var _allBorder;
	var _bottomBorder;
	var _allGap;
	var _bottomGap;

	var _allMount;
	var _bottomMount;
	
	var intAll;
	var intB;
	
	var border_style="";
	var border_color="";
	var border_width="";
	
	//size to make adjustments to
	var fitSize=200;
	
	var frametype='';
	
	//alert(frameid);
	
	
	
			
	if (mounttype=='double mount')
	{
		_allBorder = '3';
		_bottomBorder = '3';
		//border_color="#D9D9D9 #D9D9D9 #D9D9D9 #D9D9D9";
		
		border_color= topcolor + " " + rightcolor  + " " + bottomcolor  + " " + leftcolor;
		
		border_width= "5px 5px 5px 5px";

		border_style="double double double double";				
					
		//if mount is zero, then increase it to show the border
		allmount== 0? allmount=allmount+1:'';
		bottommount==0?	bottommount=bottommount+2:'';
						
	}
	else if(mounttype=='mounted')
	{
		_allBorder = '3';
		_bottomBorder = '3';
		//border_color="#D9D9D9 #D9D9D9 #D9D9D9 #D9D9D9";
		border_color= topcolor + " " + rightcolor  + " " + bottomcolor  + " " + leftcolor;
		border_width= "3px 3px 3px 3px";

		
		if (thirdmountwidth!="") {
			border_style="solid solid solid solid";
		}
		else{
			border_style="double double double double";
		}
				
		//if mount is zero, then increase it to show the border	
		allmount==0?	allmount=allmount+1:'';
		bottommount==0?	bottommount=bottommount+2:'';

	}
	else if(mounttype=='unmounted')
	{	
		mount=0;
		_allBorder = '0';
		_bottomBorder = '0';
		document.getElementById('img2' + count).style.border="";
		border_color="";
		border_width= "";

		border_style="";
		//alert('gap: ' + allgap + ':'+ bottomgap);
		//alert('mount: ' + allmount + ':'+ bottommount);
		
	}
	else if(mounttype=='boxed canvas')
	{	
		
		mount=0;
		_allBorder = '0';
		_bottomBorder = '0';
		document.getElementById('img2'+ count).style.border="";
		border_color="";
		border_width= "";

		border_style="";
		
		document.getElementById('pic1'+count).style.background='#333333';
		
	}
	
	var filename=new Array();
	filename= filenames.split (',');
	document.getElementById('img1'+count).style.display='none';
	
	
	//alert('slip id: ' +	slipid);
	
	if (document.getElementById(slipid).value==0)
	{
		frametype='img2'+count;
	}
	else
	{
		frametype='img2_slip'+count;
	}
	//alert(frametype);
	//alert(document.getElementById('img1'+count).src);
	document.getElementById(frametype).src=document.getElementById('img1'+count).src;
	
	
	
	intAll=_allGap=allgap;//intAll;

	intAll=intAll+width1;
	
	intB=_bottomGap=bottomgap;//intB;
	intB=intB+height1;

	_allMount=allmount;//6;
	_bottomMount=bottommount;//12;
			
	var totalWidth;
	var totalHeight;
							
	
	totalWidth=  Number(intW)  +  (Number(_allBorder) + Number(_allGap) + Number(_allMount)  + Number(width1) )*2;

	//first plus calculations are for bottom side and second one is for top

	totalHeight= Number(intH)  + (Number(_bottomBorder) + Number(_bottomGap)+ Number(_bottomMount) + Number(height1)) + (Number(_allBorder) + Number(_allGap)+ Number(_allMount) + Number(height1));
	
	
//	alert ("total Width: " + totalWidth) ;
	
//	alert ("total Height: " + totalHeight) ;
	
	if ( mounttype=='mounted' && mounttype=='double mount' )
	{
		totalWidth=totalWidth-3;	
		totalHeight=totalHeight-3;	
	}
	
	
	var multiply_width_by  =	fitSize/totalWidth;
	var multiply_height_by =    fitSize/totalHeight;
							
	//whatever amount is lower consider that as multiply factor
	if (multiply_width_by<multiply_height_by)
	{										
		multiply_height_by=multiply_width_by;
	}
	else if (multiply_height_by<multiply_width_by)
	{
		multiply_width_by=multiply_height_by;
	}
			
			//alert(width1);
			//			alert ('multiply factor width: '+ multiply_width_by);
			//			alert ('multiply factor height: '+ multiply_height_by);
			//			alert ('Frame width : ' + width1);
						
	width1= Math.round(width1* multiply_width_by);
	//alert ('Frame width adjusted: ' + width1);
	// alert(width1 + ':' + multiply_width_by);
	height1=Math.round(height1 * multiply_height_by );
	//alert (width1 + ":" + height1);
	_allBorder=Math.round(_allBorder * multiply_width_by);
	_bottomBorder=Math.round(_bottomBorder * multiply_height_by );
	
	
	_allMount= Math.round(_allMount * multiply_width_by);
								
	_bottomMount = Math.round(_bottomMount * multiply_height_by) ;
	
	_allGap = Math.round(_allGap * multiply_width_by);
	
	_bottomGap=Math.round(_bottomGap * multiply_height_by);
	
	
	intAll= (_allGap + width1).toFixed(2);
	intB =(_bottomGap + height1).toFixed(2);
	
	
	if (document.getElementById(slipid).value==0)		
	{
		//no slip frame
		document.getElementById(frametype).style.borderColor=border_color;
		
		document.getElementById(frametype).style.borderWidth=border_width;
		document.getElementById(frametype).style.borderStyle =border_style;
	
		//no padding for unmounted and no margin

		
		if(mounttype=='double mount' || mounttype=='mounted' ) {
			//for double or single mount
			document.getElementById(frametype).style.padding = _allMount +"px "+ _allMount +"px "+ _bottomMount +"px " + _allMount + "px";
			
			
			if (thirdmountwidth!="") {
				document.getElementById(frametype).style.backgroundColor = '#ffffff';
				document.getElementById(frametype).style.margin ='1px';
				document.getElementById('new1'+count).style.margin=intAll + "px " +  intAll +"px " + intB +"px " +  intAll + "px ";
				document.getElementById('new2'+count).style.borderColor = '#' + thirdmountcolor;
				document.getElementById('new2'+count).style.border = thirdmountwidth + 'px solid';
			}
			else
			{
				document.getElementById(frametype).style.margin=intAll + "px " +  intAll +"px " + intB +"px " +  intAll + "px ";
				document.getElementById('new1'+count).style.margin='0px';
			}
			
			
			
			
			
		}
		else if(mounttype=='unmounted')
		{//for unmount
			document.getElementById(frametype).style.padding ="0px";

			document.getElementById(frametype).style.margin=width1 + "px " +  width1 +"px " + height1 +"px " +  width1 + "px ";

		//document.getElementById(frametype).style.margin=intAll + "px " +  intAll +"px " + intB +"px " +  intAll + "px ";
		}
		
		else if(mounttype=='boxed canvas')
		{
			//for box canvas
			intAll= ( width1+4).toFixed(2);
			intB =( height1+4).toFixed(2);
			//alert('canvas else: '+intAll + (width1+4));
			document.getElementById(frametype).style.padding ="0px";
			//alert(document.getElementById(frametype).style.padding);
			document.getElementById(frametype).style.margin=intAll + "px " +  intAll +"px " + intB +"px " +  intAll + "px ";
			//alert (document.getElementById(frametype).style.margin);
			//document.getElementById(frametype).style.margin=intAll + "px " +  intAll +"px " + intB +"px " +  intAll + "px ";
		}

	}	
	else
	{
		//alert(frametype);
		document.getElementById(frametype).style.margin=document.getElementById(slipwidth).value +"px";
	}
			
	document.getElementById(frametype).style.width=Math.round(intW*multiply_width_by)+"px";//Math.round (totalWidth* multiply_width_by) + "px";
	
	document.getElementById(frametype).style.height=Math.round(intH*multiply_height_by)+"px";//Math.round (totalHeight* multiply_height_by) + "px";
				
				

	var varWidth=((intW  * multiply_width_by)/.4).toFixed(2);
	
	var varHeight=((intH  * multiply_height_by)/.4).toFixed(2);

		
			
	document.getElementById("left" + count).style.background=" ";
							
	document.getElementById("bottom"+ count).style.background=" ";
	//alert(document.getElementById("bottom").style.background);
	document.getElementById("right"+ count).style.background=" ";
	document.getElementById("top"+ count).style.background=" ";
	document.getElementById("left2"+ count).style.background=" ";
					
					
				
	if (document.getElementById(slipid).value==0)
	{
	//no slip is selected. 
			
		showFrameBasketImage(id,artworkno,width1,height1, count);
		
		document.getElementById('frame2'+ count).style.display='none';
		document.getElementById('divNoSlip'+ count).style.display='block';	
	}
	else
	{
	//slip with frame.
	//		alert('slip first frame');
		//var slipid=document.getElementById(slipid).value;
		document.getElementById('frame2'+ count).style.display='block';
		document.getElementById('divNoSlip'+ count).style.display='none';
		
		
		showFrameSlip(document.getElementById(slipid).value, id,artworkno,width1,height1 , slipwidth,count ,multiply_width_by);		
	}		
	
	
//end of basketDisplayFrameImage
}


function showFrameBasketImage( id,artworkno,width1,height1, count)
{
	//	alert('artworkno'+ artworkno);				
	var img_top;
	var img_outertop;
	var img_right;					
	var img_bottom;	
	var img_left;

	img_top="http://www.collect-art.com/frame-stream-allframes.asp?frameside=1&frameid=" +id +"&artworkno=" + artworkno
		
	img_right ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=2&frameid=" +id +"&artworkno=" + artworkno
	
	img_bottom ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=3&frameid=" +id +"&artworkno=" + artworkno
	
	img_left ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=4&frameid=" +id +"&artworkno=" + artworkno
							
	document.getElementById("left" + count).style.background=" transparent url("+img_left+") no-repeat left top";				
	document.getElementById("bottom" + count).style.background=" transparent url("+img_bottom+")  no-repeat bottom left";
	
	document.getElementById("right" + count).style.background=" transparent url("+img_right+") no-repeat right bottom";

	document.getElementById("top" + count).style.background=" transparent url("+img_top+") no-repeat top right";
	document.getElementById("left2" + count).style.background=" transparent url("+img_left+")  no-repeat left top";
					
	document.getElementById("right" + count).style.width=width1+"px";
			
	document.getElementById("left" + count).style.width=width1+"px";
	document.getElementById("left2" + count).style.width=width1+"px";
										
					
	document.getElementById("bottom" + count).style.height=height1+"px";
	document.getElementById("top"+ count).style.height=height1+"px";
	document.getElementById("pic1"+ count).style.display='block';
	
	//frame_price ( id ,artworkno , <%=getShopNo() %> );

}//end of function showFrameBasketImage()



function showFrameSlip(slipid, id,artworkno,width1,height1,slipwidth , count,multiply_width_by)
{
						
			//alert ('width for frame: '+ width1);
	var img_top;
	var img_outertop;
	var img_right;					
	var img_bottom;	
	var img_left;

	img_top_inner="http://www.collect-art.com/frame-stream-allframes.asp?frameside=1&frameid=" +slipid +"&artworkno=" + artworkno
	
	img_right_inner ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=2&frameid=" +slipid+"&artworkno=" + artworkno
	
	img_bottom_inner ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=3&frameid=" +slipid+"&artworkno=" + artworkno
	
	img_left_inner ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=4&frameid=" +slipid +"&artworkno=" + artworkno
	
	img_top="http://www.collect-art.com/frame-stream-allframes.asp?frameside=1&frameid=" +id +"&artworkno=" + artworkno
	
	img_right ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=2&frameid=" +id +"&artworkno=" + artworkno
	
	img_bottom ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=3&frameid=" +id +"&artworkno=" + artworkno
	
	img_left ="http://www.collect-art.com/frame-stream-allframes.asp?frameside=4&frameid=" +id +"&artworkno=" + artworkno
	
	
	var reduced_div_width_height;	
	//  alert('slip width: '+ document.getElementById(slipwidth).value);
	//	alert('multiply factor : ' + multiply_width_by);
	
	if ( document.getElementById(slipwidth).value>0) 
	{
	//alert(document.buyArtWorkForm.slipWidth.value);
		reduced_div_width_height=parseFloat(document.getElementById(slipwidth).value) - 2.8;
		//alert('slip before adjusted: ' + reduced_div_width_height);
			//reduced_div_width_height=	Math.round(reduced_div_width_height * multiply_width_by);
	//	alert('slip after adjusted: ' + reduced_div_width_height);
		document.getElementById("bottom_inner" + count).style.height=reduced_div_width_height +"px";
		document.getElementById("top_inner" + count).style.height=reduced_div_width_height +"px";
		
		document.getElementById("left_inner" + count).style.width=reduced_div_width_height +"px";
		document.getElementById("left2_inner" + count).style.width=reduced_div_width_height +"px";
		
		document.getElementById("right_inner" + count).style.width=reduced_div_width_height +"px";
		document.getElementById("img2_slip" + count).style.margin=reduced_div_width_height +"px";
	//alert(document.getElementById("img2_slip").style.margin);
	
	}
	
	document.getElementById("left_outer" + count).style.background=" transparent url("+img_left+") no-repeat left top";
		
	document.getElementById("bottom_outer"+ count).style.background=" transparent url("+img_bottom+")  no-repeat bottom left";
					
	document.getElementById("right_outer"+ count).style.background=" transparent url("+img_right+") no-repeat right bottom";
						
	document.getElementById("top_outer"+ count).style.background=" transparent url("+img_top+") no-repeat top right";
	
	
	document.getElementById("left_inner"+ count).style.background=" transparent url("+img_left_inner+") no-repeat left top";
					
	document.getElementById("bottom_inner"+ count).style.background=" transparent url("+img_bottom_inner+")  no-repeat bottom left";				
		
	document.getElementById("right_inner"+ count).style.background=" transparent url("+img_right_inner+") no-repeat right bottom";			
									
	document.getElementById("top_inner"+ count).style.background=" transparent url("+img_top_inner+") no-repeat top right";

	document.getElementById("left2_outer"+ count).style.background=" transparent url("+img_left+")  no-repeat left top";
	document.getElementById("left2_inner"+ count).style.background=" transparent url("+img_left_inner+")  no-repeat left top";

					
	document.getElementById("right_outer"+ count).style.width=width1+"px";
			
	document.getElementById("left_outer"+ count).style.width=width1+"px";
	document.getElementById("left2_outer"+ count).style.width=width1+"px";
					
	document.getElementById("bottom_outer"+ count).style.height=height1+"px";
	document.getElementById("top_outer"+ count).style.height=height1+"px";
	
	document.getElementById("pic1_slip"+ count).style.margin=width1+"px";
	document.getElementById("pic1_slip"+ count).style.display='block';
		//		getSlipWidth(slipid, <%=artWorkID%>,2);		
//	frame_price (id,artworkno , <%=getShopNo() %>);
					
}//end of function showFrameSlip()



