jQuery.noConflict();

var notesTextAreaText = "Please type any additional information here.";

window.onload = function() {
	//round corners
	roundAllCorners();
	
	//parse the query string
	qs();
	
	//parse Query string and show desired selection
	initAllSelects();
	
	
	//initital Setting events
	flipMaterials();
	flipCoating();
	flipSerialization();
	flipForDomed();
	flipForDestructable();
	enableOtherBoxes();
	ms_miniZoom();
	initIE6Selects();
	initiateQueryString();
	roundMini();
}

jQuery(document).ready(function(){
	//ie6 select box width hack
	
	
	//prepare select boxes for label requestor
	


});


//initAllSelects
var flippedMat = 0;
var fourColorMat = [];
var fourColorMatPlusWhite = [];
var fourColorMatAndPlus = [];
var materials = [];
var allColors = [];
var flippedCoating = 0;
var fourColorCoating = [];
var coatings = [];
var finishes = [];
var domedFinishes = [];
var finishSerialized = [];
var materialSerialized = [];

var coatingWhiteOrSilver = [];
var coatingDestruct = [];
var coatingSerialized = [];
var domedMaterials = [];
var tamperMaterials =[];

//qs
var qsParm = [];
var loaderImg;
var serializationTextAreaText = "Please enter the starting number and barcode symbology.";

function notesTextAreaRemove(){
	if($("notesTextArea").value == notesTextAreaText){
		$("notesTextArea").value = "";
	}
}
function notesTextAreaReturn(){
	if($("notesTextArea").value == ""){
		$("notesTextArea").value = notesTextAreaText;
	}
}



function initIE6Selects(){
	new YAHOO.Hack.FixIESelectWidth("materialDD");
	new YAHOO.Hack.FixIESelectWidth("coatingDD");
	new YAHOO.Hack.FixIESelectWidth("cornersDD");
	new YAHOO.Hack.FixIESelectWidth("numberofitemsDD");
	new YAHOO.Hack.FixIESelectWidth("colorsDD");
	new YAHOO.Hack.FixIESelectWidth("finishDD");
}

function getElementsByClassNameNew(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = [];
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

 
function initAllSelects(){
	materials = $("materialDD").childElements();
	coatings = $("coatingDD").childElements();
	finishes = $("finishDD").childElements();
	allColors = $("colorsDD").childElements();
	domedFinishes = jQuery.makeArray(jQuery(".finishDomed"));

	fourColorMatPlusWhite = (jQuery.makeArray(jQuery("#materialDD .materialOption4colorPlus, #materialDD .materialOption4colorAndPlus")));
							
	fourColorMat = (jQuery.makeArray(jQuery("#materialDD .materialOption4color, #materialDD .materialOption4colorAndPlus")));
	
	fourColorCoating = (jQuery.makeArray(jQuery("#coatingDD .coatingOption4color")));
	finishSerialized = (jQuery.makeArray(jQuery("#finishDD .finishSerialized")));
	materialSerialized = (jQuery.makeArray(jQuery("#materialDD .materialSerialized")));
	coatingSerialized = (jQuery.makeArray(jQuery("#coatingDD .coatingSerialized")));
	coatingWhiteOrSilver = (jQuery.makeArray(jQuery("#coatingDD .coatingWhiteOrSilver")));
	coatingDestruct = (jQuery.makeArray(jQuery("#coatingDD .coatingDestruct")));
	domedMaterials = (jQuery.makeArray(jQuery("#materialDD .materialDomed")));
	tamperMaterials = (jQuery.makeArray(jQuery("#materialDD .materialTamper")));
}

function qs() {
	qsParm['color'] = null;
	qsParm['serialized'] = null;
	qsParm['domed'] = null;
	qsParm['type'] = null;
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
			if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
			}
	}
//alert(qsParm['color']);
}

function roundAllCorners(){
      /*ROUND THE TOP OF THE FORM*/
      var settings1 = {
          tl: { radius: 10 },
          tr: { radius: 10 },
          bl: { radius: 0 },
          br: { radius: 0 },
          antiAlias: true,
          autoPad: false,
          validTags: ["div"]
      };

      var myBoxObject1 = new curvyCorners(settings1, "tempClass");
      myBoxObject1.applyCornersToAll();
      
      /*ROUND THE BOTTOM OF THE FORM*/
      var settings2 = {
          tl: { radius: 3 },
          tr: { radius: 3 },
          bl: { radius: 10 },
          br: { radius: 10 },
          antiAlias: true,
          autoPad: true,
          validTags: ["form"]
      };

      var myBoxObject2 = new curvyCorners(settings2, "formRegister");
      myBoxObject2.applyCornersToAll();
      
	/*ROUND THE CALCULATOR */
      var settings3 = {
          tl: { radius: 10 },
          tr: { radius: 10 },
          bl: { radius: 10 },
          br: { radius: 10 },
          antiAlias: true,
          autoPad: false,
          validTags: ["div"]
      };

      var myBoxObject3 = new curvyCorners(settings3, "labelCalc");
      myBoxObject3.applyCornersToAll();
      
      
     //if(!isIE){
     /*ROUND THE MINI SLIDER */ 
	
	//}
}

function roundMini(){
 var settings4 = {
	 tl: { radius: 8 },
	 tr: { radius: 8 },
	 bl: { radius: 8 },
	 br: { radius: 8 },
	 antiAlias: true,
	 autoPad: false,
	 validTags: ["div"]
	 };
	
	 var myBoxObject4 = new curvyCorners(settings4, "labSlide");
		myBoxObject4.applyCornersToAll();
}

function initiateQueryString(){
	 if(qsParm['color'] == '4ColorProcess')
	 	{ var fourColorIndex = 0;
	 	for(var i=0; i < allColors.length; i++){
	 		if( $("colorsDD")[i].innerHTML =="4 color process")
	 			fourColorIndex = i;
	 	}
	 	$("colorsDD")[fourColorIndex].selected = true;
		flipMaterials();
		flipCoating();
	}
	else if(qsParm['serialized'] == 'true'){
		jQuery("#serializeTrue").attr("checked","checked");
		jQuery(".serializationNotes").show();
	}
	else if(qsParm['domed'] == 'true'){
		jQuery("#coatingDD option").each(function(){ 			
				if(jQuery(this).html()=="Domed")
				jQuery(this).attr("selected","selected");
			});
		 flipForDomed();
		}
	else if(qsParm['type'] == 'tamperEvident'){
		jQuery("#materialDD option").each(function(){ 			
					jQuery(this).remove();
			});
		
		$("materialDD").insert("<option value='none'></option>");	
		for(var i=0; i<tamperMaterials.length; i++){
			$("materialDD").insert(tamperMaterials[i]);
		}
		$("materialDD").insert("<option value=''>Other (Please Specify)</option>");
		$("materialDD")[0].selected = true;
		
		jQuery("#finishDD option").each(function(){ 			
					if(jQuery(this).html()!="Rolls")
						jQuery(this).remove();
		});
	}
	else if(qsParm['type'] == 'assetTags'){
			jQuery("#serializeTrue").attr("checked","checked");
			showSerialization(true);
		}		

}

function flipMaterials(){
	var selectedVal = '';
	var found = false;
	var isSerialized = jQuery("#serializeTrue").attr("checked") ? true : false;
	var isDomed =  jQuery("#coatingDD option:selected").html() == "Domed";
	var selectedMaterial = jQuery("#materialDD option:selected").val();
	
	//before we flip see if its set to a selected value.
	jQuery("#materialDD option").each(function(){
	if(jQuery(this).attr('selected') == true){
			selectedVal =  jQuery(this).val();
		}
	})
	
	if($("colorsDD")[$("colorsDD").selectedIndex].innerHTML == "4 color process"){
		 var temp = $("materialDD").childElements();
		 for(var i=0; i < temp.length; i++){
			temp[i].remove();
		 }
		 $("materialDD").insert("<option value='none'></option>");
		 for(var i=0; i < fourColorMat.length; i++){
			
			if(isSerialized){
				if(jQuery(fourColorMat[i]).hasClass("materialSerialized")){
					$("materialDD").insert(fourColorMat[i]);
				}
			}
			else if(isDomed){
				if(jQuery(fourColorMat[i]).hasClass("materialDomed")){
					$("materialDD").insert(fourColorMat[i]);
				}
			}
			else{
				$("materialDD").insert(fourColorMat[i]);
			}
			

			
		 }
		 $("materialDD").insert("<option value=''>Other (Please Specify)</option>"); 
		 //$("materialDD")[0].selected = true;
		jQuery("#materialDD option").each(function(){
		if(jQuery(this).val() == selectedVal){
				jQuery(this).attr('selected',true);
				found = true;
			}
		})
		if(!found)
			$("materialDD")[0].selected = true;
		 flippedMat = 1;
	}
	else if($("colorsDD")[$("colorsDD").selectedIndex].innerHTML == "4 color process plus white"){
		 var temp = $("materialDD").childElements();
		 for(var i=0; i < temp.length; i++){
			temp[i].remove();
		 }
		 $("materialDD").insert("<option value='none'></option>");
		 for(var i=0; i < fourColorMatPlusWhite.length; i++){
			if(isSerialized){
				if(jQuery(fourColorMatPlusWhite[i]).hasClass("materialSerialized")){
					$("materialDD").insert(fourColorMatPlusWhite[i]);
				}
			}
			else if(isDomed){
				if(jQuery(fourColorMatPlusWhite[i]).hasClass("materialDomed")){
					$("materialDD").insert(fourColorMatPlusWhite[i]);
				}
			}
			else{
				$("materialDD").insert(fourColorMatPlusWhite[i]);
			}	
			
			
		 }
		 $("materialDD").insert("<option value=''>Other (Please Specify)</option>"); 
		 //$("materialDD")[selectedVal].selected = true;
		jQuery("#materialDD option").each(function(){
		if(jQuery(this).val() == selectedVal){
				jQuery(this).attr('selected',true);
				found = true;
			}
		})
		if(!found)
			$("materialDD")[0].selected = true;
		 flippedMat = 1;
	}
	else if(flippedMat==1){
		 var temp = $("materialDD").childElements();
		 for(var i=0; i < temp.length; i++){
			temp[i].remove();
		 }
		if(isSerialized)
			$("materialDD").insert("<option value='none'></option>");
		 for(var i=0; i < materials.length; i++){
			if(isSerialized){
				if(jQuery(materials[i]).hasClass("materialSerialized")){
					$("materialDD").insert(materials[i]);
				}
			}
			else if(isDomed){
				if(jQuery(materials[i]).hasClass("materialDomed")){
					$("materialDD").insert(materials[i]);
				}
			}
			else{
				$("materialDD").insert(materials[i]);
			}

				
			//$("materialDD")[selectedVal].selected = true;
			if(jQuery(materials[i]).val() == selectedMaterial){
				found = true;
			}
			
		 }
		if(isSerialized || isDomed){
			$("materialDD").insert("<option value=''>Other (Please Specify)</option>");
			$("materialDD")[0].selected = true;
		}
		if(found)
			jQuery("#materialDD option[value='"+selectedMaterial+"']").attr("selected","selected");
		else
			$("materialDD")[0].selected = true;
		 flippedMat=0;
		 }
  			 
}
		
function flipCoating(){
	var selectedVal = '';
	var found = false;
	var selectedCoating = jQuery("#coatingDD option:selected").val();
	var isSerialized = jQuery("#serializeTrue").attr("checked") ? true : false;
	
	//before we flip see if its set to a selected value.
	jQuery("#coatingDD option").each(function(){
	if(jQuery(this).attr('selected') == true){
			selectedVal =  jQuery(this).val();
		}
	})
	if(  ($("colorsDD")[$("colorsDD").selectedIndex].innerHTML == "4 color process") || ($("colorsDD")[$("colorsDD").selectedIndex].innerHTML == "4 color process plus white") ){
		 var temp = $("coatingDD").childElements();
		 for(var i=0; i < temp.length; i++){
			temp[i].remove();
		 }
		 $("coatingDD").insert("<option value='none'></option>");
		 for(var i=0; i < fourColorCoating.length; i++){
			if(isSerialized){
				if(jQuery(fourColorCoating[i]).hasClass("coatingSerialized")){
					$("coatingDD").insert(fourColorCoating[i]);
				}
			}
			else{
				$("coatingDD").insert(fourColorCoating[i]);
			}	
		 }
		 $("coatingDD").insert("<option value=''>Other (Please Specify)</option>"); 
		 jQuery("#coatingDD option").each(function(){
			if(jQuery(this).val() == selectedVal){
					jQuery(this).attr('selected',true);
					found = true;
				}
			})
		if(!found)
			$("coatingDD")[0].selected = true;
		 flippedCoating = 1;
	}
	else if(flippedCoating==1){
		 var temp = $("coatingDD").childElements();
		 for(var i=0; i < temp.length; i++){
			temp[i].remove();
		 }
		if(isSerialized)
			$("coatingDD").insert("<option value='none'></option>");
		 for(var i=0; i < coatings.length; i++){
			if(isSerialized){
				if(jQuery(coatings[i]).hasClass("coatingSerialized")){
					$("coatingDD").insert(coatings[i]);
				}
			}
			else{
				$("coatingDD").insert(coatings[i]);
			}	
			//$("materialDD")[selectedVal].selected = true;
			if(jQuery(coatings[i]).val() == selectedCoating){
				found = true;
			}
			
		 }
		 try{
		if(isSerialized)
			$("coatingDD").insert("<option value=''>Other (Please Specify)</option>");
		if(found)
			jQuery("#coatingDD option[value='"+selectedCoating+"']").attr("selected","selected");
		else
			$("coatingDD")[0].selected = true;
		 flippedCoating=0;
		}
		catch(e){
			$("coatingDD")[0].selected = true;
		}
		 }
}

function enableOther(id){
	if($(id)[$(id).selectedIndex].innerHTML == "Other (Please Specify)"){
	 jQuery("#"+id+"Other").parent(".form-row").show();
	 }
	 else {
	 jQuery("#"+id+"Other").val("");
	 jQuery("#"+id+"Other").parent(".form-row").hide();
	 }
}

function enableOtherBoxes(){
	jQuery(".othersBox").each(function(){
		if(jQuery(this).val() != ""){
			jQuery(this).parent(".form-row").show();
		}
	});

}

function moreQuantities(){
	jQuery(".moreQtyBox input").val("");
	jQuery(".moreQtyBox").toggle();
}

function showToolTip(id){
	if(id == "numberOfItems"){
	var top = parseInt($(id+"Label").offsetTop) - (jQuery("."+id+"ToolTip").height()) - parseInt($(id+"Label").offsetHeight) - 10;
	var left = -210;
	jQuery("."+id+"ToolTip").css("top",top+"px");
	jQuery("."+id+"ToolTip").css("left",left+"px");
		jQuery("."+id+"ToolTip").toggle();
	}
	else if(id == "checkordersImg"){
	var top = 10;
	var left = 600;
	jQuery("."+id+"ToolTip").css("top",top+"px");
	jQuery("."+id+"ToolTip").css("left",left+"px");
		jQuery("."+id+"ToolTip").toggle();	
	}
} 
function showSerialization(value){
	if(value==true){
		jQuery(".serializationNotes").show();
		flipSerialization();
	}
	else{
		jQuery(".serializationNotes").hide();
		flipSerialization();
	}
}

function showBarcode(value){
	if(value==true){
		jQuery(".barcodeNotes").show();
	}
	else{
		jQuery(".barcodeNotes").hide();
	}
}
function flipSerialization(){
	var selectedColor = jQuery("#colorsDD option:selected").html();
	var selectedFinish = jQuery("#finishDD option:selected").val();
	var selectedMaterial = jQuery("#materialDD option:selected").val();
	var selectedCoating = jQuery("#coatingDD option:selected").val();
	var selectedMatOther = jQuery("#materialDD option:selected").html() == "Other (Please Specify)";
	var selectedCoatOther= jQuery("#coatingDD option:selected").html() == "Other (Please Specify)";
	
	var flipVal = jQuery("#serializeTrue").attr("checked");
	var foundMat = false;
	var foundCoating = false;
	
	if(flipVal){
		
		//Flip finishes
		$("finishDD").insert("<option value='none'></option>");
		jQuery("#finishDD option").remove();
		for(var i=0; i<finishSerialized.length; i++){
				$("finishDD").insert(finishSerialized[i]);
		
		}
		//Don't eliminate the element that may be have selected when the drop downs changed
		jQuery("#finishDD option[value='"+selectedFinish+"']").attr("selected","selected");
		enableOther("finishDD");
		
		//-------
		
		//Flip materials
		jQuery("#materialDD option").remove();
		$("materialDD").insert("<option value='none'></option>");
		for(var i=0; i<materialSerialized.length; i++){
			
			if(selectedColor == "4 color process"){
				if(jQuery(materialSerialized[i]).hasClass("materialOption4colorAndPlus")
				|| jQuery(materialSerialized[i]).hasClass("materialOption4color")){
					$("materialDD").insert(materialSerialized[i]);
				}
			}
			else if(selectedColor == "4 color process plus white"){
				if(jQuery(materialSerialized[i]).hasClass("materialOption4colorPlus")
				|| jQuery(materialSerialized[i]).hasClass("materialOption4colorAndPlus")){
					$("materialDD").insert(materialSerialized[i]);
				}
			}
			else{
				$("materialDD").insert(materialSerialized[i]);
			}	
			
			if(jQuery(materialSerialized[i]).val() == selectedMaterial){
				foundMat = true;
			}
		
		}
		$("materialDD").insert("<option value=''>Other (Please Specify)</option>"); 
		//Don't eliminate the element that may be have selected when the drop downs changed
		if(foundMat)
			jQuery("#materialDD option[value='"+selectedMaterial+"']").attr("selected","selected");
		else if(selectedMatOther)
			jQuery("#materialDD option:last").attr("selected","selected")	
		else
			$("materialDD")[0].selected = true;
			
		//-------
		
		//Flip coating
		jQuery("#coatingDD option").remove();
		$("coatingDD").insert("<option value='none'></option>");
		for(var i=0; i<coatingSerialized.length; i++){

			if(selectedColor == "4 color process" || selectedColor == "4 color process plus white"){
				if(jQuery(coatingSerialized[i]).hasClass("coatingOption4color")){
					$("coatingDD").insert(coatingSerialized[i]);
				}
			}
			else{
				$("coatingDD").insert(coatingSerialized[i]);
			}	

			if(jQuery(coatingSerialized[i]).val() == selectedCoating){
				foundCoating = true;
			}
		
		}

		$("coatingDD").insert("<option value=''>Other (Please Specify)</option>"); 
		//Don't eliminate the element that may be have selected when the drop downs changed
		if(foundCoating){
			jQuery("#coatingDD option[value='"+selectedCoating+"']").attr("selected","selected");
		
		}
		else if(selectedCoatOther)
			jQuery("#coatingDD option:last").attr("selected","selected")
		else
			$("coatingDD")[0].selected = true;



	}
	else{
	
		//revert back finishes
		jQuery("#finishDD option").remove();
		for(var i=0; i<finishes.length; i++){
			$("finishDD").insert(finishes[i]);
		}
		
		//Don't eliminate the element that may be have selected when the drop downs changed
		try{
			jQuery("#finishDD option[value='"+selectedFinish+"']").attr("selected","selected");
		}
		catch(e){
			$("finishDD")[0].selected = "selected";
		}
		
		//---------
		
		//revert back materials
		jQuery("#materialDD option").remove();
		if(selectedColor == "4 color process" || selectedColor == "4 color process plus white")
			$("materialDD").insert("<option value='none'></option>");
		for(var i=0; i<materials.length; i++){
			if(selectedColor == "4 color process"){
				if(jQuery(materials[i]).hasClass("materialOption4colorAndPlus")
				|| jQuery(materials[i]).hasClass("materialOption4color")){
					$("materialDD").insert(materials[i]);
				}
			}
			else if(selectedColor == "4 color process plus white"){
				if(jQuery(materials[i]).hasClass("materialOption4colorPlus")
				|| jQuery(materials[i]).hasClass("materialOption4colorAndPlus")){
					$("materialDD").insert(materials[i]);
				}
			}
			else{
				$("materialDD").insert(materials[i]);
			}	
			
			if(jQuery(materials[i]).val() == selectedMaterial){
				foundMat = true;
			}
		
		}
		if(selectedColor == "4 color process" || selectedColor == "4 color process plus white")
			$("materialDD").insert("<option value=''>Other (Please Specify)</option>");
		//Don't eliminate the element that may be have selected when the drop downs changed
		if(foundMat){
			try{
				jQuery("#materialDD option[value='"+selectedMaterial+"']").attr("selected","selected");
			}
			catch(e){
				$("materialDD")[0].selected = "selected";
			}
		}
		else
			$("materialDD")[0].selected = true;
			
		//---------
		
		//revert back coatings
		jQuery("#coatingDD option").remove();
		if(selectedColor == "4 color process" || selectedColor == "4 color process plus white")
			$("coatingDD").insert("<option value='none'></option>");		
		for(var i=0; i<coatings.length; i++){
			if(selectedColor == "4 color process" || selectedColor == "4 color process plus white"){
				if(jQuery(coatings[i]).hasClass("coatingOption4color")){
					$("coatingDD").insert(coatings[i]);
				}
			}
			else{
				$("coatingDD").insert(coatings[i]);
			}	
			
			if(jQuery(coatings[i]).val() == selectedCoating){
				foundCoating = true;
			}

		}
		if(selectedColor == "4 color process" || selectedColor == "4 color process plus white")
			$("coatingDD").insert("<option value=''>Other (Please Specify)</option>");	
		//Don't eliminate the element that may be have selected when the drop downs changed
		if(foundCoating){
				try{
					jQuery("#coatingDD option[value='"+selectedCoating+"']").attr("selected","selected");
				}catch(e){
					$("coatingDD")[0].selected = "selected";
				}
			}
		else
			$("coatingDD")[0].selected = true;
	}

}
function flipForDomed(){
	var selected = jQuery("#coatingDD option:selected").html();
	var selectedFinish = jQuery("#finishDD option:selected").val();
	var selectedColor = jQuery("#colorsDD option:selected").html();
	var selectedMaterial = jQuery("#materialDD option:selected").val();
	var isSerialized = jQuery("#serializeTrue").attr("checked") ? true : false;
	
	if(selected == "Domed"){
		jQuery("#finishDD option").remove();
		for(var i=0; i<domedFinishes.length; i++){
			$("finishDD").insert(domedFinishes[0]);
		
		}
		//Select the first entry
		jQuery(jQuery("#finishDD option")[0]).attr("selected","selected");
		enableOther("finishDD");
		
		jQuery("#materialDD option").remove();
		$("materialDD").insert("<option value='none'></option>")
		for(var i=0; i<domedMaterials.length; i++){
			if(selectedColor == "4 color process"){
					if(jQuery(domedMaterials[i]).hasClass("materialOption4colorAndPlus")
					|| jQuery(domedMaterials[i]).hasClass("materialOption4color")){
						$("materialDD").insert(domedMaterials[i]);
					}
				
				
				
			}
			else if(selectedColor == "4 color process plus white"){

					
				
			}
			else{
					$("materialDD").insert(domedMaterials[i]);
				
			}
			
			
		}
		$("materialDD").insert("<option value=''>Other (Please Specify)</option>");
		try{
			//Don't eliminate the element that may be have selected when the drop downs changed
			jQuery("#materialDD option[value='"+selectedMaterial+"']").attr("selected","selected");
		}
		catch(e){
			$("materialDD")[0].selected = true;
		}
		enableOther("materialDD");
	}
	else{
		jQuery("#finishDD option").remove();
		for(var i=0; i<finishes.length; i++){
			$("finishDD").insert(finishes[i]);
		}
		
		
		$("finishDD")[0].selected = "selected";
		
		jQuery("#materialDD option").remove();
		if(selectedColor == "4 color process" || selectedColor == "4 color process plus white")
			$("materialDD").insert("<option value='none'></option>");
		for(var i=0; i<materials.length; i++){
			if(selectedColor == "4 color process"){
				if(!isSerialized){
					if(jQuery(materials[i]).hasClass("materialOption4colorAndPlus")
					|| jQuery(materials[i]).hasClass("materialOption4color")){
						$("materialDD").insert(materials[i]);
					}
				}
				else{
					if((jQuery(materials[i]).hasClass("materialOption4colorAndPlus")
					|| jQuery(materials[i]).hasClass("materialOption4color")) && jQuery(materials[i]).hasClass("materialSerialized")){
						$("materialDD").insert(materials[i]);
					}
				}
				
				
			}
			else if(selectedColor == "4 color process plus white"){
				if(!isSerialized){
					if(jQuery(materials[i]).hasClass("materialOption4colorAndPlus")
					|| jQuery(materials[i]).hasClass("materialOption4colorPlus")){
						$("materialDD").insert(materials[i]);
					}
				}
				else{
					if((jQuery(materials[i]).hasClass("materialOption4colorAndPlus")
					|| jQuery(materials[i]).hasClass("materialOption4colorPlus")) && jQuery(materials[i]).hasClass("materialSerialized")){
						$("materialDD").insert(materials[i]);
					}
				}
			}
			else{
				if(!isSerialized){
					$("materialDD").insert(materials[i]);
				}
				else{
					if(jQuery(materials[i]).hasClass("materialSerialized")){
						$("materialDD").insert(materials[i]);
					}
				}
			}
			
			
		}
		if(selectedColor == "4 color process" || selectedColor == "4 color process plus white")
			$("materialDD").insert("<option value=''>Other (Please Specify)</option>");
			
try{
			//Don't eliminate the element that may be have selected when the drop downs changed
			jQuery("#materialDD option[value='"+selectedMaterial+"']").attr("selected","selected");
		}
		catch(e){
			$("materialDD")[0].selected = true;
		}
		enableOther("materialDD");
	}
}

function flipForDestructable(){
	var selected = jQuery("#materialDD option:selected").html();
	var selectedFinish = jQuery("#finishDD option:selected").val();
	var selectedCoating = jQuery("#coatingDD option:selected").val();
	var foundCoating = false;
	if(selected == "Destructible Vinyl"){

		//Flip coating
		jQuery("#coatingDD option").remove();
		for(var i=0; i<coatingDestruct.length; i++){
			
				$("coatingDD").insert(coatingDestruct[i]);
				
			if(jQuery(coatingDestruct[i]).val() == selectedCoating){
				foundCoating = true;
			}
		
		}
		//Don't eliminate the element that may be have selected when the drop downs changed
		if(foundCoating)
			jQuery("#coatingDD option[value='"+selectedCoating+"']").attr("selected","selected");
		else if(selectedCoating)
			jQuery("#coatingDD option:last").attr("selected","selected")	
		else
			$("coatingDD")[0].selected = true;
			
	}
	else if(selected == "White Void with Void Adhesive"
		|| selected == "Silver Void with Void Adhesive"){

		//Flip coating
		jQuery("#coatingDD option").remove();
		for(var i=0; i<coatingWhiteOrSilver.length; i++){
				
				$("coatingDD").insert(coatingWhiteOrSilver[i]);

			if(jQuery(coatingWhiteOrSilver[i]).val() == selectedCoating){
				foundCoating = true;
			}
		
		}
		//Don't eliminate the element that may be have selected when the drop downs changed
		if(foundCoating)
			jQuery("#coatingDD option[value='"+selectedCoating+"']").attr("selected","selected");
		else if(selectedCoating)
			jQuery("#coatingDD option:last").attr("selected","selected")	
		else
			$("coatingDD")[0].selected = true;
			
	}
	else if( ($("colorsDD")[$("colorsDD").selectedIndex].innerHTML != "4 color process") && ($("colorsDD")[$("colorsDD").selectedIndex].innerHTML != "4 color process plus white")){
		jQuery("#coatingDD option").remove();
		for(var i=0; i<coatings.length; i++){
			$("coatingDD").insert(coatings[i]);
		}
		
		//This is to prevent the error "Could not set the selected property. Unspecified error." in IE.
		try{
			//Don't eliminate the element that may be have selected when the drop downs changed
			jQuery("#coatingDD option[value='"+selectedCoating+"']").attr("selected","selected");
		}
		catch(e){
			$("coatingDD")[0].selected = true;
		}
	}
}

function ms_sliderClick(index){


	if(ms_currentImage < ms_totalImages -1){
		ms_currentImage = index;
		newTop = index * sliderMove * -1;
		jQuery("#miniSliderCounter ul").animate({marginTop: newTop}, 150);//css("margin-top",newTop+"px");
		jQuery("#miniSliderCounter ul li a").css("color","#79A3BB");
		jQuery("#miniSliderCounter ul li a:eq("+ms_currentImage+")").css("color","white");
		//jQuery("#labelImage a img").attr("src",ms_imgPath[ms_currentImage]);
		jQuery("#labelSliderImg").attr("src",ms_imgPath[ms_currentImage]);
		
		return true;
	}
	else{
		return false;
	}



}
