/**
 * calculate and return prices.
 * @param wnd link to main wnd (index page of layout)
 * @return object with all prices
 */
 
function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00' 
              : ( (mnt*10 == Math.floor(mnt*10)) ? 
                       mnt + '0' : mnt);
} 


function calculatePrices(wnd) {
	
	

  if(wnd.needTurnImage) {
    sizex = Number(Number(wnd.image.imageSizeY) - wnd.cropPos2 - wnd.cropPos4);
    sizey = Number(Number(wnd.image.imageSizeX) - wnd.cropPos1 - wnd.cropPos3);
  } else {
    sizex = Number(Number(wnd.image.imageSizeX) - wnd.cropPos2 - wnd.cropPos4);
    sizey = Number(Number(wnd.image.imageSizeY) - wnd.cropPos1 - wnd.cropPos3);
  }

  var price = new Object();
  price.art = wnd.image.price;
  price.total = Number(wnd.image.price);
  if(wnd.c_transfer==1) {
    price.c_transfer=wnd.c_transferPrice*(sizex+sizey);
    price.total += price.c_transfer;
  }
  if(wnd.c_transfer==2) {
    price.c_transfer=wnd.image.price/2+2.2*(sizex+sizey);
    wnd.c_transferPrice=price.c_transfer;
    price.total += price.c_transfer;
  }
  if(wnd.brushstrokes>0) {
    price.brushstrokes=wnd.brushstrokesPrice*(sizex+sizey);
    price.total += price.brushstrokes;
  }
  if(wnd.gal_wrap>0) {
    price.gal_wrap=wnd.gal_wrapPrice*(sizex+sizey);
    price.total += price.gal_wrap;
  }
  if(wnd.museum_wrap>0) {
    price.museum_wrap=wnd.museum_wrapPrice*(sizex+sizey);
    price.total += price.museum_wrap;
  }

  var tmpX = sizex;
  var tmpY = sizey;
  eval( prepareFrameDeltaString("fillet") );
  sizex = tmpX;
  sizey = tmpY;
  sizex += 2*wnd.bottomMatWidth+2*wnd.middleMatWidth+2*wnd.topMatWidth;
  sizey += 2*wnd.bottomMatWidth+2*wnd.middleMatWidth+2*wnd.topMatWidth;
  eval( prepareMatDeltaString("bottomMat") );
  eval( prepareMatDeltaString("middleMat") );
  eval( prepareMatDeltaString("topMat") );
  eval( prepareFrameDeltaString("liner") );

  //calculate frame price
  if(wnd.frame.type=='cframe')
  {
    if(wnd.frame.width){
    price.frame = wnd.frame.price;
  sizex += 2 * wnd.frame.width - 0.5;
  sizey += 2 * wnd.frame.width - 0.5;
  price.total += price.frame;}
  }
  else
    eval( prepareFrameDeltaString("frame") );

//set minimum charge by RJZ
	 if (price.frame < 5) {
	 price.frame = 5 ;
 }

  //calculate glass price
  if( wnd.glass && wnd.glass.id ) 
  {
    var divisor = wnd.inchesInSquareFoot;
    if(wnd.measureUnit=='cm')
    divisor = wnd.cmInSquareMetre;  
    //var divisor = wnd.
    var glassW = sizex;
    var glassH = sizey;
    
    if(wnd.frame.width > 0 && (wnd.frame.type == 'cframe' || wnd.frame.type == 'frame')) {
      glassW -= 2 * wnd.frame.width;
      glassH -= 2 * wnd.frame.width;
    }

    if(wnd.pricing['glass']==1)
      price.glass = roundPrice((goToMeterOrFoot(glassW, cur_measure_system) + goToMeterOrFoot(glassH, cur_measure_system)) * wnd.glass.price);
    else
      price.glass = roundPrice(((goToMeterOrFoot(glassW, cur_measure_system) * goToMeterOrFoot(glassH, cur_measure_system)) * wnd.glass.price));
    price.total += price.glass;
  }
   else if(includeNoGlass && wnd.frame.width > 0)
  {
    var glassNW = sizex - (2 * wnd.frame.width);
    var glassNH = sizey - (2 * wnd.frame.width);
    price.noglass = - roundPrice(((goToMeterOrFoot(glassNW, cur_measure_system) * goToMeterOrFoot(glassNH, cur_measure_system)) * wnd.pricing['noglass']));
    price.total += price.noglass;
  }

  if(wnd.framing_kit ) {
    price.crop = wnd.cropPrice;
    price.total += price.crop;
  }

  if(wnd.cropPos1!=0 || wnd.cropPos2!=0 || wnd.cropPos3!=0 || wnd.cropPos4!=0 ) {
    price.crop = wnd.cropPrice;
    price.total += price.crop;
  }

  if(wnd.groove > 0) {
    price.groove = wnd.groovePrice;
    price.total += price.groove;
  }
  
  
  price.art = roundPrice( price.art );
  //price.total = (price.total / 100) * 37.5 + price.total;
  price.total = roundPrice( price.total );
  sizex = roundSize(sizex);
  sizey = roundSize(sizey);
  
  


 
 //set minimum charge by RJZ
 if (price.total < 5) {
	 price.total = 5 ;
 }

return price;
}




function goToMeterOrFoot(value, cur_measure_system)
{
    var result_q = 0 ;
    
    switch (cur_measure_system) 
    {
       case "mm" : 
        result_q = value/1000;
          break; 
       case "cm" :
        result_q = value/100;
          break;
       case "inch" : 
        result_q = value/12;
        break; 
    }
    return result_q;
}

function prepareFrameDeltaString(obj) {
 var sub;
  if(obj!="fillet")sub=1;
  else sub=0;
 return "if( wnd."+obj+".width  > 0 ){\n"+
  "var wasteP=0;"+
  "if(wnd.pricing['"+obj+"']==1){if(wnd.waste==1&&'"+obj+"'=='frame')wasteP=(goToMeterOrFoot(wnd."+obj+".width, cur_measure_system))*8*wnd."+obj+".price/2;price."+obj+" = 2*((goToMeterOrFoot(sizex, cur_measure_system)) + (goToMeterOrFoot(sizey, cur_measure_system))) * wnd."+obj+".price + wasteP;}\n"+
  "else price."+obj+" = 2*((goToMeterOrFoot(sizex, cur_measure_system)) + (goToMeterOrFoot(sizey, cur_measure_system)) + (goToMeterOrFoot(wnd."+obj+".width, cur_measure_system))*4) * wnd."+obj+".price + wasteP;\n"+
  "sizex += 2*wnd."+obj+".width;\n"+
  "sizey += 2*wnd."+obj+".width;\n"+
  "price.total += Number(price."+obj+")*9;\n"+
  "price."+obj+" = roundPrice(price."+obj+")*9;"+
  "}\n";
}
function prepareMatDeltaString(obj) {
  return "if( wnd."+obj+"Width  > 0 ){\n"+
  "price."+obj+" = calculateSquare(sizex,sizey,wnd.pricing['"+obj+"']) * wnd."+obj+".price;\n"+
  "if (Number(price."+obj+") < 1.50){price.total += 1.50;}"  +
  "else {price.total += Number(price."+obj+");}\n"+
  "if (roundPrice(price."+obj+") < 1.50){price."+obj+" = 1.50;}"+
  "else {price."+obj+" = roundPrice(price."+obj+");}"+
  "}\n";
}
function calculateSquare(bigX,bigY,pricing) {

    bigX = goToMeterOrFoot(bigX, cur_measure_system);
    bigY = goToMeterOrFoot(bigY, cur_measure_system);

    return pricing == 1 ? (bigX+bigY) : (bigX*bigY);
}

/** round double value to 2 value after coma. */
function roundPrice(val) {
  return Math.round(val*100)/100;
}
/** round double value to 2 value after coma. */
function roundSize(val) {
  return Math.round(val*100)/100;
}

function arrayToParams(arr, name, startSimbolIfNoEmpty) {
    var str = "";
    for(var i=0; i<arr.length; i++){
        if( ! arr[i] )
            continue;
        if( i>0 )
            str += "&";
        str += name+"["+i+"]="+arr[i];
    }
    return str.length>0 ? startSimbolIfNoEmpty+str : str;
}

function extractArrayFromParamsArray(parArr, name) {
    var i=1;
    var arr = new Array();
    while( true ){
        if( parArr[name+"["+i+"]"] ){
            arr[i] = parArr[name+"["+i+"]"];
        }else{
            break;
        }
        i++;
    }
    return arr;
}

function URLEncode( plaintext ) {
    // The Javascript escape and unescape functions do not correspond
    // with what browsers actually do...
    var SAFECHARS = "0123456789" +                  // Numeric
                    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +  // Alphabetic
                    "abcdefghijklmnopqrstuvwxyz" +
                    "-_.!~*'()";                    // RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";

    var encoded = "";
    for (var i = 0; i < plaintext.length; i++ ) {
        var ch = plaintext.charAt(i);
        if (ch == " ") {
            encoded += "+";             // x-www-urlencoded, rather than %20
        } else if (SAFECHARS.indexOf(ch) != -1) {
            encoded += ch;
        } else {
            var charCode = ch.charCodeAt(0);
            if (charCode > 255) {
                alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
                          "(URL encoding only supports 8-bit characters.)\n" +
                          "A space (+) will be substituted." );
                encoded += "+";
            } else {
      if(ch!='/')
      {
                encoded += "%";
                encoded += HEX.charAt((charCode >> 4) & 0xF);
                encoded += HEX.charAt(charCode & 0xF);
      }
      else
        encoded += "/";
            }
        }
    } // for

    return encoded;
}

function createWnd(url, name) {   
    if(!name) name='';
    var wnd = window.open(url, name,'scrollbars=yes, menubar=yes, toolbar=no, status=yes, directories=yes, resizable=yes, location=yes, width=780, height=450, top=0, left=0');
    wnd.focus();
}
function getDesc(p) {
//Generation string
  var frameName = '';

  var prices = calculatePrices(p);
  var is_even = '';
  var sX = !p.waste?sizex:(sizex-2*frame.width);
  var sY = !p.waste?sizey:(sizey-2*frame.width);
  
  var Strgen = "<table border=0 cellspacing=2 cellpadding=2 width=100%>";
  
Strgen += "<tr><td align='center' style='font-size: 18px; font-weight: bold;'><b>from: " + "£"+
                            format_price(prices.total) +
                        " </td>" +
                      "</tr>";
 
Strgen +="<tr><td><p align='center' style='cursor:pointer; font-size: 12px; font-weight: bold;' onclick='loadTab(5);'>Click For Full Order Review</p>" +
                "</td>"+
            "</tr>";
			

            
  Strgen += "</table>";


  return Strgen;
}


function getDescJSON(p) {
//Generation string
  var prices = calculatePrices(p);
  var is_even = '';
  var StrgenJSON_temp = '';
  var sX = !p.waste?sizex:(sizex-2*frame.width);
  var sY = !p.waste?sizey:(sizey-2*frame.width);
  
  var StrgenJSON = '[' + 
                '{"products_options_name": "' +LANGUAGE_CONFIG["size"]+ '","products_options_values_name":"'+ sX + ' x ' + sY +'","options_values_price":"'+ format_price(prices.total) + p.moneySuffix +'"},' +
                
                
                '{"products_options_name":"'+ LANGUAGE_CONFIG['art'] + ": " + p.image.imageSizeX + ' x ' + p.image.imageSizeY+'","products_options_values_name":"'+ p.image.title+'","options_values_price":"'+ format_price(prices.art) + p.moneySuffix +'"}';
                
  if(p.c_transfer > 0) 
  {
    is_even = is_even == '' ? '1' : '';
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['size']+ '","products_options_values_name":"","options_values_price":"'+ format_price(prices.c_transfer) + p.moneySuffix + '"}';
  }
                
  if(p.brushstrokes > 0) 
  {
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['brushsrtrokes']+ '","products_options_values_name":"","options_values_price":"'+ format_price(prices.brushstrokes) + p.moneySuffix + '"}';
  }
  
  if(p.museum_wrap > 0) 
  {
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['museumwrap']+ '","products_options_values_name":"","options_values_price":"'+ format_price(prices.museum_wrap) + p.moneySuffix + '"}';
  }
  
  if(p.gal_wrap > 0) 
  {
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['gallerywrap']+ '","products_options_values_name":"","options_values_price":"'+ format_price(prices.gal_wrap) + p.moneySuffix + '"}';
  }
  
  if(p.frame.width > 0)
  {
  
    if(p.frame.type=='cframe') 
    {
        is_even = is_even == '' ? '1' : '';
        StrgenJSON_temp = ' (' + p.frame.frameWidth +'x'+ p.frame.frameHeight + " " + p.frame.width + cur_measure_unit + ')';
    } 
    else 
    {
        is_even = is_even == '' ? '1' : '';
        StrgenJSON_temp = ' (' + p.frame.width + cur_measure_unit + ')';
    }
  
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['frame']+ StrgenJSON_temp.replace('"', 'inch') +'","products_options_values_name":"'+p.frame.name +'","options_values_price":"'+  format_price(prices.frame) + p.moneySuffix + '"}';

  }
  
  if(p.liner.width > 0) 
  {
    StrgenJSON_temp = ' (' + p.liner.width + cur_measure_unit + ')';
    
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['liner']+ StrgenJSON_temp.replace('"', 'inch')+'","products_options_values_name":"'+p.liner.name +'","options_values_price":"'+  format_price(prices.liner) + p.moneySuffix + '"}';
  }
  
  if(p.topMatWidth > 0)
  {
    StrgenJSON_temp = ' (' + p.topMatk*p.topMatdelta + cur_measure_unit + ')';
    
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['topmat']+ StrgenJSON_temp.replace('"', 'inch')+'","products_options_values_name":"'+p.topMat.name +'","options_values_price":"'+  format_price(prices.topMat) + p.moneySuffix + '"}';
  }
  
  if(p.middleMatWidth > 0) 
  {
    StrgenJSON_temp = ' (' + p.middleMatk*p.middleMatdelta + cur_measure_unit + ')';
    
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['middlemat']+ StrgenJSON_temp.replace('"', 'inch')+'","products_options_values_name":"'+p.middleMat.name +'","options_values_price":"'+  format_price(prices.middleMat) + p.moneySuffix + '"}';
  }

  if(p.bottomMatWidth > 0) 
  {
    StrgenJSON_temp = ' (' + p.bottomMatk*p.bottomMatdelta + cur_measure_unit + ')';
    
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['bottommat']+ StrgenJSON_temp.replace('"', 'inch')+'","products_options_values_name":"'+p.bottomMatMat.name +'","options_values_price":"'+  format_price(prices.bottomMat) + p.moneySuffix + '"}';
  }

  if(p.fillet.width > 0) 
  {
    StrgenJSON_temp = ' (' + p.fillet.width + cur_measure_unit + ')';
    
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['fillet']+ StrgenJSON_temp.replace('"', 'inch')+'","products_options_values_name":"'+p.fillet.name +'","options_values_price":"'+  format_price(prices.fillet) + p.moneySuffix + '"}';
  }
  
  if(p.groove > 0) 
  {
  
  if(prices.groove > 0)
    StrgenJSON_temp_price = '' + format_price(prices.groove) + p.moneySuffix;
  else
    StrgenJSON_temp_price = '';
  
    StrgenJSON_temp = ' (' + (p.grooveDeltaX*0.125) + cur_measure_unit + ')';
    
    StrgenJSON +=   '{"products_options_name": "' +LANGUAGE_CONFIG['vgroove']+ StrgenJSON_temp.replace('"', 'inch')+'","products_options_values_name":"'+p.fillet.name +'","options_values_price":"'+  StrgenJSON_temp_price+ '"},';
  }
  
  if((p.cropPos1!=0 || p.cropPos2!=0 || p.cropPos3!=0 || p.cropPos4!=0) && p.cropPrice>0) 
  {
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['crop']+'","products_options_values_name":"","options_values_price":"'+  format_price(prices.crop) + p.moneySuffix+ '"}';
  }
  
  if(p.glass && p.glass.id && p.frame.width > 0) 
  {
    StrgenJSON +=   ',{"products_options_name": "' +LANGUAGE_CONFIG['glass']+'","products_options_values_name":"'+p.glass.name +'","options_values_price":"'+  format_price(prices.glass)+ '"}';
  }
  
    StrgenJSON += ']';
  return StrgenJSON;
}


function getDescORDER(p) {
//Generation string
  var frameName = '';

  var prices = calculatePrices(p);
  var is_even = '';
  var sX = !p.waste?sizex:(sizex-2*frame.width);
  var sY = !p.waste?sizey:(sizey-2*frame.width);
  var totalsX = sizex-10;
  var totalsY = sizey-10;
  var barrier_board = sX * sY / 1000000 * 15;
  var sqmeter = sX + sY; 
  var oil_stretching = 0
  if (sqmeter < 750){oil_stretching = 10;}
  
 else if (sqmeter >=751 && sqmeter < 1000){oil_stretching = 15;}
 else if (sqmeter >=1001 && sqmeter < 1250){oil_stretching = 20;}
  else if (sqmeter >=1251 && sqmeter < 1500){oil_stretching = 25;}
   else if (sqmeter >=1501 && sqmeter < 1750){oil_stretching = 30;}
   else if (sqmeter <1751){oil_stretching = 35;}
  
  
  var heatsealing = sX * sY / 1000000 * 20;
 
  var oil_stretching = oil_stretching+prices.total;
  
  

  

 
  var Strgen = "<table border=1 cellspacing=0 cellpadding=2 width=100% class='grayfont' align=center>" +
                    "<tr class='mainText' nowrap='nowrap'>" ; 
                        
				if(p.frame.width > 0) 
                 {Strgen +=	 "<td style='font-size: 14px; padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>Frame Size(Internal):";}
				 
				 else if(p.frame.width ==0 && p.topMatWidth == 0) 
                 {Strgen +=	 "<td style='font-size: 14px; padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>Image Size(Mount opening size):";}
				 
				 else {Strgen +=	 "<td style='font-size: 14px;padding:0px 5px 0px 5px;font-weight: bold; color: #006699;'>Mount To Fit Frame Size:";}
				 
				 
                   Strgen +="</td>"+
                        "<td align='right' style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                            " " + sX + cur_measure_system + " X " + sY +cur_measure_system + 
                        "</td>"  +
                    "</tr>" ;
                
				
				
				
				   
				if (p.topMatWidth > 0) 
                  {  Strgen +=	 "<tr class='mainText" + is_even + "' nowrap>" +
                        "<td style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>Image Size(Mount opening size):</td>" +
                        "<td align='right' style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>"+
                              " " + p.image.imageSizeX + cur_measure_system + " X " + p.image.imageSizeY + cur_measure_system +
                                "</td>" + "</tr>"; }
								
				if(p.frame.width > 0) 
                 {Strgen +=	 "<tr class='mainText' nowrap='nowrap'><td style='font-size: 12px; width:50%;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>Approx External Frame Size:" +
				 "<td align='right' style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                            " " + totalsX + cur_measure_system + " X " + totalsY +cur_measure_system + 
                        "</td>"  +
                    "</tr>"  ;}	
					
						if(p.frame.width > 0) 
                 {Strgen +=	 "<tr class='mainText' nowrap='nowrap'><td style='font-size: 12px; width:50%;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>Moulding Number:" +
				 "<td align='right' style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                            " " + p.frame.item_number + 
                        "</td>"  +
                    "</tr>"  ;}	
							  
			
			
			
       
    if(p.frame.width >=1) 
          {
            is_even = is_even == '' ? '1' : '';
            Strgen += "<tr nowrap='nowrap'>" +
                        "<td style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" + LANGUAGE_CONFIG['frame'] +" "+ LANGUAGE_CONFIG['description'] +
                        ":</td>";
            
            is_even = is_even == '' ? '1' : '';
             Strgen += "<td style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;' align='right'>";
             
          
                is_even = is_even == '' ? '1' : '';
                Strgen +=  p.frame.width + cur_measure_unit;
                frameName = " (" + p.frame.width + cur_measure_unit + ")";
            }
			
	
           if(p.frame.width >=1){ 
            Strgen += " " + p.frame.name + 
                  
                       "</td>" +
                    "</tr>";}
          
        
      
          
           if(p.topMatWidth > 0) 
          {
            is_even = is_even == '' ? '1' : '';
            Strgen += "<tr nowrap='nowrap'>" +
                        "<td style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                            LANGUAGE_CONFIG['topmat']+ 
                        ":</td>" +
                        "<td align='right' style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'> " +
                            p.topMatk*p.topMatdelta + cur_measure_unit + " " +
                            p.topMat.name +"("+ p.topMat.item_number + ")"+
                         
                        "</td>" +
                       "</tr>";
          }
         
           if(p.middleMatWidth > 0) 
          {
            is_even = is_even == '' ? '1' : '';
            Strgen += "<tr nowrap='nowrap'>" +
                        "<td style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                            LANGUAGE_CONFIG['middlemat']+ p.middleMatk*p.middleMatdelta + cur_measure_unit + 
                        "</td>" +
                        "<td style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;' align='right'>" +
                            p.middleMatk*p.middleMatdelta + cur_measure_unit + " " +
                            p.middleMat.name + 
                           
                       "</td>" +
                      "</tr>";
          }
       
          
          if(p.bottomMatWidth > 0) 
          {
            is_even = is_even == '' ? '1' : '';
            Strgen += "<tr nowrap='nowrap'>" +
                        "<td style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                            LANGUAGE_CONFIG['bottommat'] + 
                        ":</td>" +
                        "<td align='right' style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                           p.bottomMatk*p.bottomMatdelta + cur_measure_unit + " " +
                            p.bottomMat.name + 
                           
                        "</td>" +
                      "</tr>";
          }
  
      if(p.glass && p.glass.id && p.frame.width > 0)
          {
            is_even = is_even == '' ? '1' : '';
            Strgen += "<tr nowrap='nowrap'>" +
                         "<td style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>"+
                            LANGUAGE_CONFIG['glass']+
                         ":</td>" +
                         "<td align='right' style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                                p.glass.name +
                             
                        "</td>" +
                      "</tr>";
          }
        
            else if (includeNoGlass && p.frame.width > 0)
          {
            is_even = is_even == '' ? '1' : '';
            Strgen += "<tr nowrap='nowrap'>" +
                         "<td style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>Glazing:</td>" +
                         "<td align='right' style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>" +
                                "No Glazing Required"+
                              "<input type='hidden' name='optionprodlist[]' id='optionprodlist9' value='noglass|Glazing|HIDDEN|0' />" +
                              "<input type='hidden' name='noglass' id='noglass' value='No Glazing Required|||||||STANDARD|STANDARD|STANDARD' />" +
                        "</td>" +
                      "</tr>";
          }
		  
		  
	if(p.frame.width > 0) 
                 {Strgen +=	 "<tr class='mainText' nowrap='nowrap'><td style='font-size: 12px; width:50%;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>Backing:" +
				 "<td align='right' style='font-size: 12px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>2.5mm MDF Backing Board</td>"  +
                    "</tr>"  ;}				
							  
        
     
					  
	  
	  
	 
		

			  Strgen += "<tr nowrap='nowrap'>" + 
                         "<td colspan='2' align='center' style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>"+
                            "<b><br />Standard Framing Services:<\/b>"+
                         " </td>" +
                      "</tr>";
		
		
		      Strgen += "<tr nowrap='nowrap'>" + 
                         "<td style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #f00;'>"+
                            "<b>Frame/Frame &amp; Mount Price<\/b><br />Add Heatsealing.<br />Add Barrier Board."+
                         " </td>" +
                         "<td align='right' style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #f00;'> <b>" + "£"+
                            format_price(prices.total) +
                        "</b><br />+ £"+
                            format_price(heatsealing) +
                        "<br />+ £"+
                            format_price(barrier_board) +
                        "</td>" +
                      "</tr>";

					  
					   Strgen += "<tr nowrap='nowrap'>" + 
                         "<td colspan='2' align='center' style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #006699;'>"+
                            "<b><br />Additional Framing Services:<\/b>"+
                         " </td>" +
                      "</tr>";
					  
					  
					      Strgen += "<tr nowrap='nowrap'>" + 
                         "<td style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #f00;'>"+
                            "<b>Frame/Frame &amp; Mount Price inc Stretching:<\/b>"+
                         " </td>" +
                         "<td align='right' style='font-size: 14px;padding:0px 5px 0px 5px; font-weight: bold; color: #f00;'> <b>" + "£"+
                            format_price(oil_stretching) +
                        "</b></td>" +
                      "</tr>";
					  
					     Strgen += "<tr>" + 
                         "<td colspan='2' width='100%' style='clear:all; font-size: 14px; padding:0px 5px 0px 5px; font-weight: bold; text-align:right; color: #006699;'>"+
                            "<br /><a  href='javascript:printReport()'>Print</a>"+
                         " </td>" +
                      
                      "</tr>";
		
		
		
		
  Strgen += "</table>";
  Strgen += "</table>";
  Strgen += "</form>";

  return Strgen;
}

function printReport()
{
  this.focus();
  this.print();
}



function format_price(price) {
  var zero='';
  var intP=Math.floor(price);
  var realP=Math.round((price-intP)*100);
  if(realP<10)
    zero='0';
  return intP+"."+zero+realP;
}


