/**
* @author Nivaria Innova Team
*/
function StaticAlbum() {
this.id = null;
this.simplefields = new Array();      //Simple fields
this.items = new Array();		      //Items of Medialibrary
this.Static = null;			      //Reference to Static object instance
this.itemsMap = new Array();	      //Relate index and id of item
this.subcategoryId = null;		      //Subcategory selected by user
}
StaticAlbum.prototype = {
initialize: function(objectId,json) {
	      this.id = objectId;
	      //Getting component simple fields values
	      ncm.initSimpleFields(StaticAlbum,this,json);
	      //Init Static
	      this.initStatic();
},
initStatic: function() {
	      var isVertical = this.simplefields["VERTICAL"]?this.simplefields["VERTICAL"]:false;
	      var scrollStep = this.simplefields["SCROLL_STEP"]?parseInt(this.simplefields["SCROLL_STEP"]):3;
	      var animationSpeed = this.simplefields["ANIMATION"]?this.simplefields["ANIMATION"]:"fast";
	      var m_reg = /[0-9]+/g;
	      if(animationSpeed.match(m_reg)) animationSpeed = parseInt(animationSpeed);
	      var scrollAuto = this.simplefields["SCROLL_AUTO"]?parseInt(this.simplefields["SCROLL_AUTO"]):0;
	      var wrapping = this.simplefields["WRAP"]?this.simplefields["WRAP"]:"null";
	      if(wrapping=="null") wrapping=null;
	      $jq(this.getStaticSelector()).jcarousel({
		      vertical: isVertical,
		      scroll: scrollStep,
		      animation: animationSpeed,
		      auto: scrollAuto,
		      wrap: wrapping
	      });
  this.initImageCSS();
},

initImageCSS: function() {
var init_carousel = "0";
var height;
var width;
$jq(this.getStaticSelector()).find(".jcarousel-item img").each(function (i){  
 if (init_carousel=="0"){  
  height=$jq(this).css("height");
  width=$jq(this).css("width");
 }else{
  $jq(this).css("height",height);
  $jq(this).css("width",width);
 }
 init_carousel="1";
});
},
getStaticSelector: function() {
	      var selector = "#Static";
	      selector += this.id;
	      return selector;
}, 
setSelectedItem: function(index) {
	      var selector = this.getStaticSelector();
	      selector += " li";
	      $jq(selector).removeClass("jcarousel-item-selected").eq(index).addClass("jcarousel-item-selected");
}
};
StaticAlbum.instances = new Array();
StaticAlbum.properties = new Array();
StaticAlbum.datatype = null;
StaticAlbum.jsp_utils = null;
StaticAlbum.language = null;
StaticAlbum.pageUrl = null;
StaticAlbum.channel = null;
StaticAlbum.inPreview = false;
StaticAlbum.issueId = null;
StaticAlbum.skin = null;
StaticAlbum.register = function(objectId,json) {
var aObject = new StaticAlbum();
aObject.initialize(objectId,json);
StaticAlbum.instances[""+objectId] = aObject;
}
StaticAlbum.getRegistered = function(objectId) {
return StaticAlbum.instances[""+objectId];
}
StaticAlbum.get = function(objectId) {
return StaticAlbum.getRegistered(objectId);
}
StaticAlbum.initProperties = function(options) {
ncm.initProperties(StaticAlbum,options);
}
StaticAlbum.getProperty = function(propName) {
var res = StaticAlbum.properties[propName];
if(res==null) res="";
if(typeof(res)=="undefined") res="";
return res;
}

