function selectLinkType(DyBoxObject){
	switch(DyBoxObject.options.compulsory.linkType.toLowerCase()){
		case "image":
			DyBoxObject.linkObject = new imageLink(DyBoxObject);
			break;
		case "text":
			DyBoxObject.linkObject = new textOnlyLink(DyBoxObject);
			break;
	}
}

var dyBoxButton = Class.create();
dyBoxButton.prototype = {
    initialize: function(options) {
        this.options = Object.extend({
            properties: {
                text: "",
                href: "",
                id: "",
                itemClass: "",
                title: "",
                buttonType: "",
                dyBox: "",
                buttonBind: ""
            }
        }, options || {});
    },

    createButton: function() {
        var anchorLink, anchorLinkText;

        anchorLink = document.createElement("a");
        anchorLinkText = document.createTextNode(this.options.properties.text);
        anchorLink.setAttribute("href", this.options.properties.href);
        if (this.options.properties.id) {
            anchorLink.setAttribute("id", this.options.properties.id);
        }
        if (this.options.properties.itemClass) {
            anchorLink.setAttribute("class", this.options.properties.itemClass);
        }
        if (this.options.properties.title) {
            anchorLink.setAttribute("title", this.options.properties.title);
        }
        anchorLink.appendChild(anchorLinkText);

        return anchorLink;
    },

    buttonClick: function() {
        switch (this.options.properties.buttonType) {
            case "close":
                Event.stopObserving(this.options.properties.id, "click", this.buttonBind);
                //Event.stopObserving(this.options.properties.id, "click", backgroundObjectBind);
                closeLightboxContainer(this.options.properties.dyBox);
                break;
            case "stopClick":
                disableVideoPlayerSelect(this.options.properties.dyBox);
                break;
            case "options":
                openOptionsFields();
                break;
        }
    }
};


/*== Image link ===============================================================*/
var imageLink = Class.create();
	imageLink.prototype = {
		name : "",
		linkImage : "",
		linkImageALT : "",
		linkText : "",		
		currentLinkLocation : "",
		id : "",
		imageID : "",
		dyboxObject : "",
		contentType : "",
		linkBind : "",
		rolloverBind : "",
		
		initialize: function(dyBoxObject){
			this.name = dyBoxObject.options.compulsory.name;
			this.linkImage = dyBoxObject.options.imageLink.imageSRC;
			this.linkImageALT = dyBoxObject.options.imageLink.imageALT;
			this.linkText = dyBoxObject.options.imageLink.linkText;
			this.currentLinkLocation = dyBoxObject.options.compulsory.originalLinkID;
			this.dyboxObject = dyBoxObject;
			this.id = this.createImageLink(dyBoxObject);
			this.contentType = dyBoxObject.options.compulsory.mediaType;
		},
		
		createImageLink: function(dyBoxObject){
			var dyBoxSectionDiv, dyBoxSectionP, linkObjectParent, dyBoxSectionP_Text, imageDiv, imageLinkTag, imageTag, currentLinkObject;
			
			dyBoxSectionDiv = document.createElement("div");
			dyBoxSectionDiv.className = "dyBox_ImageLinkContainer clear";
			dyBoxSectionDiv.setAttribute("id", "dyBox_ImageLinkContainer_" + this.name);
			if(this.linkText != ""){
				dyBoxSectionP = document.createElement("p");
				dyBoxSectionP.className = "textColour1";
				dyBoxSectionP_Text = document.createTextNode(this.linkText);
			}
			imageDiv = document.createElement("div");
			imageDiv.className = "dyBox_ImageLinkContent";
			imageDiv.setAttribute("id", "dyBox_ImageLinkContent_" + this.name);
			imageLinkTag = document.createElement("a");
			imageLinkTag.setAttribute("href", "javascript:void(0)");
			imageLinkTag.className = "dyBox_ImageLink";
			imageLinkTag.id = "dyBox_ImageLink_" + this.name;
			imageTag = document.createElement("img");
			//alert(this.linkImage);
			imageTag.setAttribute("src", this.linkImage);
			imageTag.setAttribute("alt", this.linkImageALT);
			imageTag.setAttribute("id", "dyBox_ImageLinkImg_" + this.name);
			this.imageID = imageTag.id;
			imageLinkTag.appendChild(imageTag);
			imageDiv.appendChild(imageLinkTag);
			
			if(this.linkText != ""){
				dyBoxSectionP.appendChild(dyBoxSectionP_Text);
				if(dyBoxObject.options.imageLink.textPos){
					if(dyBoxObject.options.imageLink.textPos.toLowerCase() == "bottom"){
						dyBoxSectionDiv.appendChild(imageDiv);
						dyBoxSectionDiv.appendChild(dyBoxSectionP);
						
					}else{
						dyBoxSectionDiv.appendChild(dyBoxSectionP);
						dyBoxSectionDiv.appendChild(imageDiv);
					}
				}else{
					dyBoxSectionDiv.appendChild(dyBoxSectionP);
					dyBoxSectionDiv.appendChild(imageDiv);
				}
			}else{
				dyBoxSectionDiv.appendChild(imageDiv);
			}
			currentLinkObject = $(this.currentLinkLocation);
			if(currentLinkObject.parentNode){
				linkObjectParent = currentLinkObject.parentNode;
				linkObjectParent.insertBefore(dyBoxSectionDiv, currentLinkObject.nextSibling);
			}
			
			if(dyBoxObject.options.imageLink.rolloverAvailable.toLowerCase() == "true"){
				this.setRollover_imageLink(imageLinkTag.id);
			};
			//alert(imageLinkTag.id);
			this.linkBind = this.linkClicked_imageLink.bindAsEventListener(this);
			Event.observe(imageLinkTag.id, 'click', this.linkBind);
			return imageLinkTag.id;
		},
		
		setRollover_imageLink: function(imageLinkTagId){
			var buttonBind_MouseRollover = this.imageRollover_imageLink.bindAsEventListener(this, "over");
			var buttonBind_MouseRollout = this.imageRollover_imageLink.bindAsEventListener(this, "out");
			Event.observe($(imageLinkTagId), 'mouseover', buttonBind_MouseRollover);
			Event.observe($(imageLinkTagId), 'mouseout', buttonBind_MouseRollout);
		},
		
		imageRollover_imageLink: function(buttonObject, rollType){
			if(rollType == "over"){
				$(this.imageID).setAttribute("src", this.linkImage.replace(".jpg","_Alt.jpg"));
			}else{
				$(this.imageID).setAttribute("src", this.linkImage.replace("_Alt.jpg",".jpg"));
			}
		},
		
		linkClicked_imageLink: function(){
			selectContentViewingType(this);
			//alert(this.dyboxObject.options.product.productID);	
		},
		
		disableClick: function(){
			//alert("off");
			Event.stopObserving($(this.id), 'click', this.linkBind);
		},
		
		enableClick: function(){
			//alert(this.id);
			Event.observe($(this.id), 'click', this.linkBind);
		}
	};
/*== End - Image link ===============================================================*/	
	
/*== Text only link ===============================================================*/	
	var textOnlyLink = Class.create();
	textOnlyLink.prototype = {
		name : "",
		linkText : "",
		currentLinkLocation : "",
		id : "",
		dyboxObject : "",
		contentType : "",
		linkTitle : "",
		
		initialize: function(dyBoxObject){
			this.name = dyBoxObject.options.compulsory.name;
			this.linkText = dyBoxObject.options.textLink.linkText;
			this.currentLinkLocation = dyBoxObject.options.compulsory.originalLinkID;
			this.dyboxObject = dyBoxObject;
			this.id = this.createTextOnlyLink(dyBoxObject);
			this.linkTitle = dyBoxObject.options.textLink.linkTitle;
			this.contentType = dyBoxObject.options.compulsory.mediaType;
		},
		
		createTextOnlyLink: function(dyBoxObject){
			var dyBoxSectionDiv, dyBoxSectionTxt, linkObjectParent,  currentLinkObject, linkBind;
						
		    dyBoxSectionDiv = document.createElement("a");
		    dyBoxSectionDiv.setAttribute("href", "javascript:void(0)");
			if(dyBoxObject.options.compulsory.mediaType == "video"){
				dyBoxSectionDiv.className = "dyBox_VideoLink clear";
				dyBoxSectionDiv.id = "dyBox_VideoLink_" + this.name;
			}else{		
				dyBoxSectionDiv.className = "dyBox_TextOnlyLink clear";
				dyBoxSectionDiv.id = "dyBox_TextOnlyLink_" + this.name;
			}
			dyBoxSectionDiv.setAttribute("title", this.linkTitle);
			dyBoxSectionTxt = document.createTextNode(this.linkText);
			dyBoxSectionDiv.appendChild(dyBoxSectionTxt);
						
			currentLinkObject = $(this.currentLinkLocation);
			if(currentLinkObject.parentNode){
				linkObjectParent = currentLinkObject.parentNode;
				linkObjectParent.insertBefore(dyBoxSectionDiv, currentLinkObject.nextSibling);
			}
			this.linkBind = this.linkClicked_TextOnly.bindAsEventListener(this);
			Event.observe(dyBoxSectionDiv.id, 'click', this.linkBind);
			return dyBoxSectionDiv.id;
		},
		
		linkClicked_TextOnly: function(){
			
			selectContentViewingType(this);
			//alert(this.dyboxObject.options.product.productID);	
		},
		
		disableClick: function(){
			//alert("off");
			Event.stopObserving($(this.id), 'click', this.linkBind);
		},
		
		enableClick: function(){
			//alert("on");
			Event.observe($(this.id), 'click', this.linkBind);
		}
	};
	/*== End - Text only link ===============================================================*/

	/*== Slider link ===============================================================*/
	var sliderLink = Class.create();
	sliderLink.prototype = {
	    initialize: function(options) {
	        this.options = Object.extend({
	            properties: {
	                name: "",
	                sliderNumber: "",
	                sliderImage: "",
	                sliderImageALT: "",
	                sliderText: "",
	                currentLinkLocation: "",
	                id: "",
	                linkBind: "",
	                currentSliderPosition: ""
	            }
	        }, options || {});
	    },

	    createSlider: function() {
	        var dyBoxSectionDiv, dyBoxSectionP, linkObjectParent, dyBoxSectionP_Text, imageDiv, imageLinkTag, imageTag, currentLinkObject;


	        var sliderContainer, sliderText, sliderText_Text, sliderControl, sliderImage, sliderImageId;

	        sliderContainer = document.createElement("div");
	        sliderContainer.setAttribute("id", this.options.name);

	        sliderText = document.createElement("span");
	        //sliderLabel.setAttribute("for", "backOpacity");
	        sliderText_Text = document.createTextNode(this.options.sliderText);

	        sliderControl = document.createElement("span");
	        sliderControl.setAttribute("id", "slider" + this.options.sliderNumber);
	        sliderControl.setAttribute("class", "slider");
	        sliderControl.style.width = "100px";
	        sliderControl.style.height = "5px";
	        sliderControl.style.display = "block";
	        sliderControl.style.background = "#FFFFFF";
	        sliderControl.style.position = "relative";

	        sliderImage = document.createElement("img");
	        sliderImage.setAttribute("src", "/images/dyBox/slider.gif");
	        sliderImageId = "sliderImage" + this.options.sliderNumber
	        sliderImage.setAttribute("id", sliderImageId);
	        sliderImage.style.position = "absolute";
	        sliderImage.style.display = "block";
	        sliderImage.style.width = "9px";
	        sliderImage.style.height = "12x";
	        sliderImage.style.left = "80px";
	        this.options.currentSliderPosition = sliderImage.style.left;
	        sliderImage.style.top = "0px";

	        sliderText.appendChild(sliderText_Text);
	        sliderControl.appendChild(sliderImage);
	        sliderContainer.appendChild(sliderText);
	        sliderContainer.appendChild(sliderControl);
	        $(this.options.currentLinkLocation).appendChild(sliderContainer);

	        this.options.linkBind = this.sliderMoving.bindAsEventListener(this);
	        Event.observe($(sliderImageId), 'click', this.options.linkBind);
	    },

	    sliderMoving: function(event) {
	        var posX = Event.pointerX(event);
	        Event.observe($("sliderImage" + this.options.sliderNumber), 'mousemove', function() { this.setSliderPos(posX, event);});

	        //Event.observe(window, 'mousemove', function() { alert(this.options.currentSliderPosition); });

	        //alert(this.dyboxObject.options.product.productID);
	    },

	    setSliderPos: function(posX, event) {
	        var startingPoint = posX;
	        var nextPos = Event.pointerX(event);

	        alert(startingPoint);
	        alert(nextPos);
	    }
	};
	/*== End - Image link ===============================================================*/	
