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;
		case "formbutton":
			DyBoxObject.linkObject = new formButtonLink(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;
    },
	
	buttonLinkClicked: function(){
		switch (this.options.properties.buttonType) {
            case "close":
				this.options.properties.buttonBind = this.linkClicked_CloseLink.bindAsEventListener(this);
                Event.observe(this.options.properties.id, "click", this.options.properties.buttonBind);
                //Event.stopObserving(this.options.properties.id, "click", backgroundObjectBind);
                break;
            case "stopClick":
                disableVideoPlayerSelect(this.options.properties.dyBox);
                break;
            case "options":
                openOptionsFields();
                break;
        }
	},
	
	linkClicked_CloseLink: function(){
		this.linkClicked_DisableCloseLink();
		closeLightboxContainer(this.options.properties.dyBox);
	},
	
	linkClicked_DisableCloseLink: function(){
		for(var i = 0; i < closeButtonList.length; i++){
			Event.stopObserving($(closeButtonList[i].options.properties.id), 'click', closeButtonList[i].options.properties.buttonBind);
		}
		//Event.stopObserving($(this.options.properties.id), 'click', this.options.properties.buttonBind);
		Event.stopObserving($("dyBox_overlay"));
	}
};

/*== Image link ===============================================================*/
var imageLink = Class.create();
	imageLink.prototype = {
		name : "",
		linkImage : "",
		linkImageALT : "",
		linkText : "",		
		currentLinkLocation : "",
		id : "",
		imageID : "",
		dyboxObject : "",
		contentType : "",
		linkBind : "",
		rolloverBind : "",
		itemClass : "",
		
		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;
			this.itemClass = dyBoxObject.options.compulsory.itemClass;
		},
		
		createImageLink: function(dyBoxObject){
			var dyBoxSectionDiv, dyBoxText, linkObjectParent, imageLinkTag, imageTag, currentLinkObject;
			this.itemClass = dyBoxObject.options.compulsory.itemClass;	
			dyBoxSectionDiv = document.createElement("div");
			dyBoxSectionDiv.className = "dyBox_ImageLinkContainer";
			dyBoxSectionDiv.setAttribute("id", "dyBox_ImageLinkContainer_" + this.name);
			
			if(this.linkText != ""){
				dyBoxText = document.createElement("span");
				if(this.itemClass){
					if(this.itemClass.length > 0){
						dyBoxText.className = this.itemClass;
					}else{
					dyBoxText.className = "dyBox_CustomLink clear";
					}
				}else{
					dyBoxText.className = "dyBox_CustomLink clear";
				}
				//createTextSectionOfLink(this, dyBoxText);
				dyBoxText.innerHTML = this.linkText;
			}
			imageLinkTag = document.createElement("a");
			imageLinkTag.setAttribute("href", "javascript:void(0)");
			imageLinkTag.className = "dyBox_ImageLink";
			imageLinkTag.id = "dyBox_ImageLink_" + this.name;
			imageTag = document.createElement("img");
			imageTag.setAttribute("src", this.linkImage);
			imageTag.setAttribute("alt", this.linkImageALT);
			imageTag.setAttribute("id", "dyBox_ImageLinkImg_" + this.name);
			this.imageID = imageTag.id;
			
			if(this.linkText != ""){
				if(dyBoxObject.options.imageLink.textPos){
					if(dyBoxObject.options.imageLink.textPos.toLowerCase() == "bottom"){
						imageLinkTag.appendChild(imageTag);
						imageLinkTag.appendChild(dyBoxText);
						dyBoxSectionDiv.appendChild(imageLinkTag);
						
					}else{
						imageLinkTag.appendChild(dyBoxText);
						imageLinkTag.appendChild(imageTag);
						dyBoxSectionDiv.appendChild(imageLinkTag);
					}
				}else{
					imageLinkTag.appendChild(dyBoxText);
					imageLinkTag.appendChild(imageTag);
					dyBoxSectionDiv.appendChild(imageLinkTag);
				}
			}else{
				imageLinkTag.appendChild(imageTag);
				dyBoxSectionDiv.appendChild(imageLinkTag);
			}
			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);
			};
			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);
		},
		
		disableClick: function(){
			Event.stopObserving($(this.id), 'click', this.linkBind);
		},
		
		enableClick: function(){
			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 : "",
		itemClass : "",
		
		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;
			this.itemClass = dyBoxObject.options.compulsory.itemClass;
		},
		
		createTextOnlyLink: function(dyBoxObject){
			this.itemClass = dyBoxObject.options.compulsory.itemClass;
			var dyBoxSectionDiv, dyBoxSectionTxt, linkObjectParent,  currentLinkObject, linkBind;

			dyBoxSectionDiv = document.createElement("a");
		    dyBoxSectionDiv.setAttribute("href", "javascript:void(0)");
			if(dyBoxObject.options.compulsory.mediaType == "video"){
				if(this.itemClass){
					if(this.itemClass.length > 0){
						dyBoxSectionDiv.className = this.itemClass;
					}else{
					dyBoxSectionDiv.className = "dyBox_VideoLink clear";
					}
				}else{
					dyBoxSectionDiv.className = "dyBox_VideoLink clear";
				}
				dyBoxSectionDiv.id = "dyBox_VideoLink_" + this.name;
			}else{	
				if(this.itemClass){
					if(this.itemClass.length > 0){
						dyBoxSectionDiv.className = this.itemClass;
					}else{
					dyBoxSectionDiv.className = "dyBox_TextOnlyLink clear";
					}
				}else{
					dyBoxSectionDiv.className = "dyBox_TextOnlyLink clear";
				}
				dyBoxSectionDiv.id = "dyBox_TextOnlyLink_" + this.name;
			}
			dyBoxSectionDiv.setAttribute("title", this.linkTitle);
			
			if(this.linkText != ""){
				//createTextSectionOfLink(this, dyBoxSectionDiv);
				dyBoxSectionDiv.innerHTML = this.linkText;
			}
						
			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);
		},
		
		disableClick: function(){
			Event.stopObserving($(this.id), 'click', this.linkBind);
		},
		
		enableClick: function(){
			Event.observe($(this.id), 'click', this.linkBind);
		}
	};
	/*== End - Text only link ===============================================================*/
	
	/*== Form Button link ===============================================================*/	
	var formButtonLink = Class.create();
	formButtonLink.prototype = {
		name : "",
		linkText : "",
		currentLinkLocation : "",
		id : "",
		dyboxObject : "",
		contentType : "",
		linkTitle : "",
		buttonType : "",
		
		initialize: function(dyBoxObject){
			this.name = dyBoxObject.options.compulsory.name;
			this.currentLinkLocation = dyBoxObject.options.compulsory.originalLinkID;
			this.dyboxObject = dyBoxObject;
			this.contentType = dyBoxObject.options.compulsory.mediaType;
			this.buttonType = dyBoxObject.options.formButton.buttonType;
			this.buttonClass = dyBoxObject.options.formButton.buttonClass;
			this.buttonName = dyBoxObject.options.formButton.buttonName;
			this.buttonValue = dyBoxObject.options.formButton.buttonValue;
			this.id = this.createFormButtonLink(dyBoxObject);
		},
				
		createFormButtonLink: function(dyBoxObject){
			var dyBoxSectionDiv, linkObjectParent,  currentLinkObject, linkBind;
						
		    dyBoxSectionDiv = document.createElement("input");
		    dyBoxSectionDiv.setAttribute("type", this.buttonType);
			dyBoxSectionDiv.setAttribute("class", this.buttonClass);
			dyBoxSectionDiv.setAttribute("name", this.buttonName);
			dyBoxSectionDiv.id = this.buttonName;
			dyBoxSectionDiv.setAttribute("value", this.buttonValue);
			
			currentLinkObject = $(this.currentLinkLocation);
			if(currentLinkObject.parentNode){
				linkObjectParent = currentLinkObject.parentNode;
				linkObjectParent.insertBefore(dyBoxSectionDiv, currentLinkObject.nextSibling);
			}
			
			this.linkBind = this.linkClicked_FormButton.bindAsEventListener(this);
			Event.observe(dyBoxSectionDiv.id, 'click', this.linkBind);
			return dyBoxSectionDiv.id;
		},
		
		linkClicked_FormButton: function(){
			selectContentViewingType(this);
		},
		
		disableClick: function(){
			Event.stopObserving($(this.id), 'click', this.linkBind);
		},
		
		enableClick: function(){
			Event.observe($(this.id), 'click', this.linkBind);
		}
	};
	/*== End - Form Button link ===============================================================*/