//<!-- design and programming by viaden inc | http://www.viaden.com/ -->
//============================================================================
//var SITE_PATH = "/home/suharev/public_html/477_logo_script_order";
//var WEB_SITE_PATH = "http://suharev.dev.local/477_logo_script_order";
var SITE_PATH = "/home/desietdd/public_html";
var WEB_SITE_PATH = "http://www.boatletteringdesign.com";
//============================================================================
var PHPwidth=20;
var font_pos = 5;

function mysetcolor(red, green, blue, type,color_name)
{
  if (type == 3)
  {
    //Outline Color
    o1 = red; o2 = green; o3 = blue;
    document.mainform.o1.value = o1
    document.mainform.o2.value = o2
    document.mainform.o3.value = o3
  }
  else if (type == 2)
  {
    //Drop Shadow Color
    s1 = red; s2 = green; s3 = blue;
    document.mainform.s1.value = s1
    document.mainform.s2.value = s2
    document.mainform.s3.value = s3
    if (document.mainform.same_outline.value == 3){
        document.mainform.o1.value = s1
        document.mainform.o2.value = s2
        document.mainform.o3.value = s3
        o1 = s1; o2 = s2; o3 = s3;
    }
  }
  else if (type == 1)
  {
    // Lettering Color
    f1 = red; f2 = green; f3 = blue;
    document.mainform.f1.value = f1
    document.mainform.f2.value = f2
    document.mainform.f3.value = f3
    if (document.mainform.same_shadow.value == 1){
        document.mainform.s1.value = f1
        document.mainform.s2.value = f2
        document.mainform.s3.value = f3
        s1 = f1; s2 = f2; s3 = f3;
    }
    if (document.mainform.same_outline.value == 1){
        document.mainform.o1.value = f1
        document.mainform.o2.value = f2
        document.mainform.o3.value = f3
        o1 = f1; o2 = f2; o3 = f3;
    }
  }
  else
  {
    //Hull Color
    b1 = red; b2 = green; b3 = blue;
    document.mainform.b1.value = b1
    document.mainform.b2.value = b2
    document.mainform.b3.value = b3
    if (document.mainform.same_shadow.value == 2){
        document.mainform.s1.value = b1
        document.mainform.s2.value = b2
        document.mainform.s3.value = b3
        s1 = b1; s2 = b2; s3 = b3;
    }
    if (document.mainform.same_outline.value == 2){
        document.mainform.o1.value = b1
        document.mainform.o2.value = b2
        document.mainform.o3.value = b3
        o1 = b1; o2 = b2; o3 = b3;
    }
  }
preview();
}

function preview()
{
  var fsize = document.mainform.font_size.options[document.mainform.font_size.selectedIndex].value;
  var font_height = document.mainform.font_height.options[document.mainform.font_height.selectedIndex].value;
  var st_width = document.mainform.st_width.value ;
  var font_width = document.mainform.font_width.options[document.mainform.font_width.selectedIndex].value;
//  var delta = parseInt(fsize) * (parseInt(st_width) - parseInt(font_width)) / parseInt(font_height);
  if (st_width != ""){
    var delta = parseInt(font_width) / parseInt(st_width) ;
    document.mainform.delta.value = delta
  }
  else{
    var delta =  ""
  }
  //====================================================
  var shadow = document.mainform.shadow.value ;
  var outline = document.mainform.outline.value;
  var osize = document.mainform.outline_size.value;
  document.mainform.shadow_ck.value = shadow
  document.mainform.outline_ck.value = outline
  var font_ttf = document.mainform.font_ttf.value;
  if(document.images) {
//     document.images["previewimg"].src = "http://www.viaden.com/boat/img.php?"+
     document.images["previewimg"].src = ""+WEB_SITE_PATH+"/include/img1.php?"+
	 "f1="+f1+
	"&f2="+f2+
	"&f3="+f3+
	"&b1="+b1+
	"&b2="+b2+
	"&b3="+b3+
	"&s1="+s1+
	"&s2="+s2+
	"&s3="+s3+
	"&o1="+o1+
	"&o2="+o2+
	"&o3="+o3+
    "&font_ttf="+font_ttf+
	"&text_line="+escape(document.mainform.text_line.value)+
	"&shadow="+shadow+
	"&outline="+outline+
	"&font_size="+fsize+
	"&outline_size="+osize+
    "&delta="+delta
    ;
  } 
}

function invert_image(){
  var fsize = document.mainform.font_size.options[document.mainform.font_size.selectedIndex].value;
  var font_height = document.mainform.font_height.options[document.mainform.font_height.selectedIndex].value;
  var st_width = document.mainform.st_width.value ;
  var font_width = document.mainform.font_width.options[document.mainform.font_width.selectedIndex].value;
  if (st_width != ""){
    var delta = parseInt(font_width) / parseInt(st_width) ;
    document.mainform.delta.value = delta
  }
  else{
    var delta =  ""
  }
  //====================================================
  //-------------------------------------------------------------
  var shadow = document.mainform.shadow.value ;
  var outline = document.mainform.outline.value;
  var osize = document.mainform.outline_size.value;
  //-------------------------------------------------------------  
  document.mainform.shadow_ck.value = shadow
  document.mainform.outline_ck.value = outline
  var font_ttf = document.mainform.font_ttf.value;
  var fsize = document.mainform.font_size.options[document.mainform.font_size.selectedIndex].value;
  if(document.images) {
     document.images["previewimg"].src = ""+WEB_SITE_PATH+"/include/invert_image.php?"+
	 "f1="+f1+
	"&f2="+f2+
	"&f3="+f3+
	"&b1="+b1+
	"&b2="+b2+
	"&b3="+b3+
	"&s1="+s1+
	"&s2="+s2+
	"&s3="+s3+
	"&o1="+o1+
	"&o2="+o2+
	"&o3="+o3+
    "&font_ttf="+font_ttf+
	"&text_line="+escape(document.mainform.text_line.value)+
	"&shadow="+shadow+
	"&outline="+outline+
	"&font_size="+fsize+
	"&outline_size="+osize+
    "&delta="+delta
    ;
  } 
}

function fchange()
{
  open("fchange.php?pos="+font_pos, "fchange", "left=50,top=50,width=600 height=485")
}
function subm()
{
  preview();
  return false;
}
function zoom_in(){
    if (document.mainform.font_size.selectedIndex < document.mainform.font_size.options.length - 1){
        document.mainform.font_size.options[(document.mainform.font_size.selectedIndex + 1)].selected = "true";
    }
    preview();
    return false;
}
function zoom_out(){
    if (document.mainform.font_size.selectedIndex > 0){
        document.mainform.font_size.options[(document.mainform.font_size.selectedIndex - 1)].selected = "true";
    }
    preview();
    return false;
}
function reload_preview(){
    if (document.mainform.font_height.options[document.mainform.font_height.selectedIndex].value != "-1"){
    var f1 = document.mainform.f1.value;
    var f2 = document.mainform.f2.value;
    var f3 = document.mainform.f3.value;
    var b1 = document.mainform.b1.value;
    var b2 = document.mainform.b2.value;
    var b3 = document.mainform.b3.value;
    var s1 = document.mainform.s1.value;
    var s2 = document.mainform.s2.value;
    var s3 = document.mainform.s3.value;
    var o1 = document.mainform.o1.value;
    var o2 = document.mainform.o2.value;
    var o3 = document.mainform.o3.value;
    var same_outline = document.mainform.same_outline.value
    var same_shadow = document.mainform.same_shadow.value
    var font_ttf = document.mainform.font_ttf.value;
    var outline = document.mainform.outline.value;
    var outline_size = document.mainform.outline_size.value;
    var shadow = document.mainform.shadow.value;
    var act = document.mainform.act.value;
    var text_line = document.mainform.text_line.value;
    var st_width = document.mainform.st_width.value;
    var delta = document.mainform.delta.value;
    var font_width = document.mainform.font_width.value;
//    if (document.mainform.mirror.checked)
//        var mirror = 1;
//    else
        var mirror = 0;
    var distortion = document.mainform.distortion.options[document.mainform.distortion.selectedIndex].value;
    var font_height = document.mainform.font_height.options[document.mainform.font_height.selectedIndex].value;
    var font_size = document.mainform.font_size.options[document.mainform.font_size.selectedIndex].value;

     var URL = "DD_BoatLettering.php?do=reload_preview"+
	 "&f1="+f1+
	"&f2="+f2+
	"&f3="+f3+
	"&b1="+b1+
	"&b2="+b2+
	"&b3="+b3+
	"&s1="+s1+
	"&s2="+s2+
	"&s3="+s3+
	"&o1="+o1+
	"&o2="+o2+
	"&o3="+o3+
    "&font_ttf="+font_ttf+
	"&text_line="+escape(text_line)+
	"&shadow="+shadow+
	"&outline="+outline+
	"&font_size="+font_size+
	"&outline_size="+outline_size+
    "&act="+act+
    "&mirror="+mirror+
    "&distortion="+distortion+
    "&font_height="+font_height+
    "&same_outline="+same_outline+
    "&same_shadow="+same_shadow+
    "&st_width="+st_width+
    "&id="+document.mainform.id.value
    ;
    document.location.href = URL;
    }else{
        preview();
    }

}
function submit_valid(){
    if (document.mainform.font_height.options[document.mainform.font_height.selectedIndex].value == "-1" || document.mainform.font_width.options[document.mainform.font_width.selectedIndex].value == "None"){
        alert("Select Lettering Height and Lettering Width.");
        return false;
    }
    else{
        document.mainform.submit();
    }
}
function unset_height(){
    document.mainform.font_height.selectedIndex = 0;
}
function set_sh_type(){
    var sh_type_curr = document.getElementById("sh_type").options[document.getElementById("sh_type").selectedIndex].value;
    var sh_type = new Array();
    sh_type["Int'l Orders: Rates vary"] = 0;   
    sh_type["Overnight: $30"] = 30;   
    sh_type["2nd Day Air: $20"] = 20;   
    sh_type["Ground: $10"] = 10;
    var new_price = parseFloat(document.getElementById("price_total").value)+parseFloat(sh_type[sh_type_curr]);
    if (document.getElementById("tax").checked == true){
        var tax_curr = parseFloat(document.getElementById("tax_curr").value);
        new_price = new_price + new_price / 100 * tax_curr;
        var price1 = new_price*Math.pow(10,2)
		var price2 = Math.round(price1)
		new_price = price2 / Math.pow(10,2)
    }
    
    document.getElementById("price_total_show1").value = "$"+new_price;
    document.getElementById("price_total_show").value = "$"+new_price;
}
//<!-- design and programming by viaden inc | http://www.viaden.com/ -->
