// JavaScript Document
function reset_color_value ()
{
	$('ColorValue').value = '';
	$('darkred').style.opacity = 0.4;
	$('darkred').style.filter = "alpha(opacity:40)";
	$('flame').style.opacity = 0.4;
	$('flame').style.filter = "alpha(opacity:40)";
	$('darkblue').style.opacity = 0.4;
	$('darkblue').style.filter = "alpha(opacity:40)";
	$('lightblue').style.opacity = 0.4;
	$('lightblue').style.filter = "alpha(opacity:40)";
	$('green').style.opacity = 0.4;
	$('green').style.filter = "alpha(opacity:40)";
	$('yellow').style.opacity = 0.4;
	$('yellow').style.filter = "alpha(opacity:40)";
	$('purple').style.opacity = 0.4;
	$('purple').style.filter = "alpha(opacity:40)";
	$('brown').style.opacity = 0.4;
	$('brown').style.filter = "alpha(opacity:40)";
	$('black').style.opacity = 0.4;
	$('black').style.filter = "alpha(opacity:40)";
	$('copper').style.opacity = 0.4;
	$('copper').style.filter = "alpha(opacity:40)";
	$('gold').style.opacity = 0.4;
	$('gold').style.filter = "alpha(opacity:40)";
	$('silver').style.opacity = 0.4;
	$('silver').style.filter = "alpha(opacity:40)";
}

function img_highlight (obj)
{
	obj.style.opacity = 1;
	obj.style.filter = "alpha(opacity:100)"; 
}

function img_dul (obj)
{
	obj.style.opacity = 0.4;
	obj.style.filter = "alpha(opacity:40)"; 
}

function color_appli (obj, color)
{
	reset_color_value ();
	img_highlight (obj);
	$('ColorValue').value = color;
}

function reset_number_value () 
{
	$('Anodized').checked = false;
	$('Traditional').checked = false;
	$('BARCOD').style.display = 'inline';
	$('BCType').style.display = 'none';
	$('Numbering').value = '';
	$('SERIALIZED').style.opacity = 0.4;
	$('SERIALIZED').style.filter = "alpha(opacity:40)";
	$('BARCOD').style.opacity = 0.4;
	$('BARCOD').style.filter = "alpha(opacity:40)";
	$('Blank').style.opacity = 0.4;
	$('Blank').style.filter = "alpha(opacity:40)";
	$('None').style.opacity = 0.4;
	$('None').style.filter = "alpha(opacity:40)";
}

function serial_appli (obj, value)
{
	reset_number_value ();
	img_highlight (obj);
	if (obj.id == "BARCOD")
	{
		$('BARCOD').style.display = 'none';
		$('BCType').style.display = 'inline';
	}
	$('Numbering').value = value;
}

function update_preview ()
{
	//Anodized Aluminum#-#Bar Code 39 (readable)#-#00000001#-#Middle#-#3x1.5#-#darkred#-##-#PROPERTY OF#-#8#-#6 WEST DESIGN#-#14#-##-##-##-##-##-##-#Center#-##-##-#
	//$material, $numbering, $number_start, $number_alignment, $size, $color, $color_style, $line1, $line1_size, $line2, $line2_size, $line3, $line3_size, $line4, $line4_size, $line5, $line5_size, $text_align, $logo, $logo_style
	
	
}

function validate_label_creator ()
{
	material = $("Material").value;
	surface = $("Surface").value;
	numbering = $("Numbering").value;
	number_prefix = $("Prefix").value;
	number_start = $("Starting").value;
	number_alignment = $("NumberAlign").value;
	adhesive = $("Adhesive").value;
	size = $("Size").value;
	color = $("ColorValue").value;
	color_reverse = $("ColorReverse").value;
	line1 = $("Text_Line1").value;
	line1_size = $("Line1_Size").value;
	line2 = $("Text_Line2").value;
	line2_size = $("Line2_Size").value;
	line3 = $("Text_Line3").value;
	line3_size = $("Line3_Size").value;
	line4 = $("Text_Line4").value;
	line4_size = $("Line4_Size").value;
	line5 = $("Text_Line5").value;
	line5_size = $("Line5_Size").value;
	text_align = $("Text_Align").value;
	logo = $("Logo").value;
	logo_style = $("Logo_Style").value;
	
	quantity = $("Quantity").value;
	sku = $("SKU").value;
	
	if (material == "")
	{
		alert ("Please select material in Step 02");
		$("Material").focus ();
		return false;
	}
	else if (numbering == "")
	{
		alert ("Please select numbering in Step 04");
		$("Numbering").focus ();
		return false;
	}
	else if (adhesive == "")
	{
		alert ("Please select adhesive in Step 02");
		$("Adhesive").focus ();
		return false;
	}
	else if (size == "")
	{
		alert ("Please select size in Step 01");
		$("Size").focus ();
		return false;
	}
	else if (color == "")
	{
		alert ("Please select color in Step 03");
		$("ColorValue").focus ();
		return false;
	}
	else if (quantity == "")
	{
		alert ("Please enter quantity of packs in Step 06");
		$("Quantity").focus ();
		return false;
	}
	else if (!validate_data (quantity, 'int', ''))
	{
		alert ("Please enter correct Quantity of packs on Step 06");
		$("Quantity").select ();
		$("Quantity").focus ();
		return false;
	}
	else if (parseInt (quantity) <= 0)
	{
		alert ("Please enter correct Quantity of packs on Step 06");
		$("Quantity").select ();
		$("Quantity").focus ();
		return false;
	}
	else if (parseInt (quantity) == 0)
	{
		alert ("Please enter correct Quantity of packs on Step 06");
		$("Quantity").select ();
		$("Quantity").focus ();
		return false;
	}
	return true;
}

function add_label_to_cart (AJAX, callfor)
{
	material = $("Material").value;
	surface = $("Surface").value;
	numbering = $("Numbering").value;
	number_prefix = $("Prefix").value;
	number_start = $("Starting").value;
	number_alignment = $("NumberAlign").value;
	adhesive = $("Adhesive").value;
	size = $("Size").value;
	color = $("ColorValue").value;
	color_reverse = $("ColorReverse").value;
	line1 = escape ($("Text_Line1").value);
	line1_size = $("Line1_Size").value;
	line2 = escape ($("Text_Line2").value);
	line2_size = $("Line2_Size").value;
	line3 = escape ($("Text_Line3").value);
	line3_size = $("Line3_Size").value;
	line4 = escape ($("Text_Line4").value);
	line4_size = $("Line4_Size").value;
	line5 = escape ($("Text_Line5").value);
	line5_size = $("Line5_Size").value;
	text_align = $("Text_Align").value;
	logo = $("Logo").value;
	logo_style = $("Logo_Style").value;
	quantity = $("Quantity").value;
	
	var validate = true;

	if (callfor != "getSKU" && callfor != "getIMG")
	{
		validate = validate_label_creator ();
		if (!validate)
		{
			callfor = "";
		}
	}
	
	
	
	
	loadData (AJAX + "labelcreator.ajax.php", "RESULT", "form_action=UPDATE_OPTIONS&callfor=" + callfor + "&quantity=" + quantity + "&label_string=" + escape (material + "|-|" + surface + "|-|" + numbering + "|-|" + number_prefix + "|-|" + number_start + "|-|" + number_alignment + "|-|" + adhesive + "|-|" + size + "|-|" + color + "|-|" + color_reverse + "|-|" + line1 + "|-|" + line1_size + "|-|" + line2 + "|-|" + line2_size + "|-|" + line3 + "|-|" + line3_size + "|-|" + line4 + "|-|" + line4_size + "|-|" + line5 + "|-|" + line5_size + "|-|" + text_align + "|-|" + logo + "|-|" + logo_style));

	
	//update_preview (AJAX, callfor);
}

function update_preview (AJAX, callfor)
{
	material = $("Material").value;
	surface = $("Surface").value;
	numbering = $("Numbering").value;
	number_prefix = $("Prefix").value;
	number_start = $("Starting").value;
	number_alignment = $("NumberAlign").value;
	adhesive = $("Adhesive").value;
	size = $("Size").value;
	color = $("ColorValue").value;
	color_reverse = $("ColorReverse").value;
	line1 = escape ($("Text_Line1").value);
	line1_size = $("Line1_Size").value;
	line2 = escape ($("Text_Line2").value);
	line2_size = $("Line2_Size").value;
	line3 = escape ($("Text_Line3").value);
	line3_size = $("Line3_Size").value;
	line4 = escape ($("Text_Line4").value);
	line4_size = $("Line4_Size").value;
	line5 = escape ($("Text_Line5").value);
	line5_size = $("Line5_Size").value;
	text_align = $("Text_Align").value;
	logo = $("Logo").value;
	logo_style = $("Logo_Style").value;
	quantity = $("Quantity").value;
	
	loadData (AJAX + "labelcreator.ajax.php", "Step6Right", "form_action=LABEL_IMAGE&label_string=" + escape (material + "|-|" + surface + "|-|" + numbering + "|-|" + number_prefix + "|-|" + number_start + "|-|" + number_alignment + "|-|" + adhesive + "|-|" + size + "|-|" + color + "|-|" + color_reverse + "|-|" + line1 + "|-|" + line1_size + "|-|" + line2 + "|-|" + line2_size + "|-|" + line3 + "|-|" + line3_size + "|-|" + line4 + "|-|" + line4_size + "|-|" + line5 + "|-|" + line5_size + "|-|" + text_align + "|-|" + logo + "|-|" + logo_style));
	
	loadData (AJAX + "labelcreator.ajax.php", "SixSteps", "form_action=LABEL_IMAGE&label_string=" + escape (material + "|-|" + surface + "|-|" + numbering + "|-|" + number_prefix + "|-|" + number_start + "|-|" + number_alignment + "|-|" + adhesive + "|-|" + size + "|-|" + color + "|-|" + color_reverse + "|-|" + line1 + "|-|" + line1_size + "|-|" + line2 + "|-|" + line2_size + "|-|" + line3 + "|-|" + line3_size + "|-|" + line4 + "|-|" + line4_size + "|-|" + line5 + "|-|" + line5_size + "|-|" + text_align + "|-|" + logo + "|-|" + logo_style));
	
	$('SixSteps').style.background = '#FFFFFF';
	
	if (material != "" && numbering != "" && size != "")
	{
		//$material, $numbering, $number_prefix, $number_start, $number_alignment, $size, $color, $color_style, $line1, $line1_size, $line2, $line2_size, $line3, $line3_size, $line4, $line4_size, $line5, $line5_size, $text_align, $logo, $logo_style
			loadData (AJAX + "labelcreator.ajax.php", "RESULT", "form_action=GetSKU&callfor=" + callfor + "&quantity=" + quantity + "&parameter=" + escape (material + "|-|" + surface + "|-|" + numbering + "|-|" + number_prefix + "|-|" + number_start + "|-|" + number_alignment + "|-|" + adhesive + "|-|" + size + "|-|" + color + "|-|" + color_reverse + "|-|" + line1 + "|-|" + line1_size + "|-|" + line2 + "|-|" + line2_size + "|-|" + line3 + "|-|" + line3_size + "|-|" + line4 + "|-|" + line4_size + "|-|" + line5 + "|-|" + line5_size + "|-|" + text_align + "|-|" + logo + "|-|" + logo_style));
	}
}

function check_step_consecutive (step)
{
	return true;
	reset_steps (step);
	if (step >= 1)
	{
		//==== no action
	}
	
	if (step >= 2)
	{
		if ($('Material').value == "")
		{
			alert ("Please go through the steps consecutively and complete all previous steps.");
			reset_number_value ();
			$('Material').focus ();
			return false;
		}
	}
	
	if (step >= 3)
	{
		if ($('Numbering').value == "")
		{
			alert ("Please go through the steps consecutively and complete all previous steps.");
			$("Adhesive").options[0].selected = true;
			$('SERIALIZED').focus ();
			return false;
		}
	}
	
	if (step >= 4)
	{
		if ($('Adhesive').value == "")
		{
			alert ("Please go through the steps consecutively and complete all previous steps.");
			$("Size").options[0].selected = true;
			$('Adhesive').focus ();
			return false;
		}
	}
	
	if (step >= 5)
	{
		if ($('Size').value == "")
		{
			alert ("Please go through the steps consecutively and complete all previous steps.");
			reset_color_value ();
			$('Size').focus ();
			return false;
		}
	}
	
	if (step >= 6)
	{
		if ($('ColorValue').value == "")
		{
			alert ("Please go through the steps consecutively and complete all previous steps.");
			$('ColorRow1').focus ();
			return false;
		}
	}
	
	if (step >= 7)
	{
		if ($('Text_Line1').value == "" && $('Text_Line2').value == "" && $('Text_Line3').value == "" && $('Text_Line4').value == "" && $('Text_Line5').value == "")
		{
			alert ("Please go through the steps consecutively and complete all previous steps.");
			$('Text_Line1').focus ();
			return false;
		}
	}
	
	if (step >= 8)
	{
		if ($('Quantity').value == "")
		{
			alert ("Please go through the steps consecutively and complete all previous steps.");
			$('Quantity').focus ();
			return false;
		}
	}
	return true;
}

function reset_steps (step)
{
	$("Step6Right").innerHTML = "";
	
	if (step <= 7)
	{
		// Do nothing
	}
	
	if (step <= 6)
	{
		$("Quantity").value = 0;
	}
	
	if (step <= 5)
	{
		$('UploadLogoText').style.display = 'inline';
		$('LogoFile').style.display = 'none';
		$('UploadLogoText').innerHTML = 'Upload Logo';
		$('Logo').value = '';
		$('LogoFile').value = '';
		$('UploadLogoProgress').style.display = 'none';
	}
	
	if (step <= 4)
	{
		reset_color_value ();
	}
	
	if (step <= 3)
	{
		$("Size").options[0].selected = true;
	}
	
	if (step <= 2)
	{
		$("Adhesive").options[0].selected = true;
	}
	
	if (step <= 1)
	{
		reset_number_value ();
	}
}
