var jqVideo = jQuery.noConflict();

function jsimport(url) {
    var newelem = document.createElement("script");
    newelem.setAttribute("language", "javascript");
    newelem.setAttribute("type", "text\/javascript");
    newelem.setAttribute("onload", "");
    newelem.setAttribute("src", url);
    document.getElementsByTagName("head")[0].appendChild(newelem);
}

////////////////////////////////////////////////////sevilenler///////////////////////////////////////////////////////////

var Sevilenler = {
    page: 1,
    cacheArray:[],
    PageSize:3,
    TotalPage:100,
    TotalCount:0,
	TITLE:"",
    nextSevilenler:function() {
		this.page++;
		if (this.page <= this.TotalPage) {
			this.SetPage(this.page);
        }else{
            this.page--;
        }
    },
    prevSevilenler:function() {
        this.page--;
		if (this.page > 0) {
			this.SetPage(this.page);
        }else{
            this.page++;
        }
    },
	ChangeButtonClass:function(){
			if(this.page==1){
				jqVideo('#btnSevilenGeri').attr("class",'leftArrowDeactive'); 
			}else{
				jqVideo('#btnSevilenGeri').attr("class",'leftArrow'); 
			}

			if(this.page==this.TotalPage){
				jqVideo('#btnSevilenIleri').attr("class",'rightArrowDeactive'); 
			}else{
				jqVideo('#btnSevilenIleri').attr("class",'rightArrow'); 
			}
	},
	WriteHtmlStructure:function(){
		var HTML="";
		HTML +="<div class=\"clear\">";
		HTML +="<h2 class=\"blueCornerTitle fLeft\"><span>"+this.TITLE+"</span></h2>";
		HTML +="<span id=\"sevilenlerpager\" class=\"fRight\" style=\"width:60px;\">";
		HTML +="<a id=\"btnSevilenGeri\" onclick=\"Sevilenler.prevSevilenler()\" class=\"leftArrow\"><span><<</span></a>";
		HTML +="<a id=\"btnSevilenIleri\" onclick=\"Sevilenler.nextSevilenler()\" class=\"rightArrow\"><span>>></span></a>";
		HTML +="</span>";
		HTML +="</div>";
		HTML +="<div class=\"rightContentBox clear\">";
		HTML +="<div class=\"hiddenListBox clear\">";
		HTML +="<div class=\"listBox clear\">";
		HTML +="<ul id=\"sevilenler\" class=\"avatarList\">";
		HTML +="</ul>";
		HTML +="</div>";
		HTML +="</div>";
		HTML +="</div>";
		jqVideo('#sevilenlerdiv').html(HTML);

	},
	SetPage:function(pageNo){

		var HTML="";

		var start=(pageNo-1)*this.PageSize;
		var end=start + this.PageSize;

		if(end>this.TotalCount){
			end=this.TotalCount ;
		}

		for(var i=start;i<end;i++){
			HTML +="<li><a href='"+SevilenlerData[i].picLink+"' ><img src='"+SevilenlerData[i].picSrc+"'/>"+SevilenlerData[i].picTitle+"</a></li>";
		}
		
		jqVideo('#sevilenler').html(HTML);
	},
	Init:function(json){

		this.TotalCount=SevilenlerData.length;

		this.TITLE=json.title;

		if(this.TotalCount>0){
			this.WriteHtmlStructure();
			this.TotalPage = parseInt(this.TotalCount / this.PageSize);

			if(this.TotalCount %  this.PageSize>0){
				this.TotalPage++;
			}

			this.SetPage(1);
		}
	}
}




/////////////////////////////////////////SEVENLER ///////////////////////////////////////////////////


var Sevenler = {
	page:1,
    cacheArray:[],
    PageSize:6,
    TotalPage:100,
	SEVENDIV:null,
	CONTENTNAME:'',
	CONTENTMCID:'',
	TITLE:"",
    nextSevenler:function() {
		this.page++;
		if (this.page <= this.TotalPage) {
			this.SetPage(this.page);
        }else{
            this.page--;
        }
    },
    prevSevenler:function() {
        this.page--;
		if (this.page > 0) {
			this.SetPage(this.page);
        }else{
            this.page++;
        }
    },
	SetPage:function(pageNo){
		if(this.cacheArray[this.page]!=undefined ){
			jqVideo('#sevenler').html(this.cacheArray[this.page]);
		}else{
			jqVideo('#sevenler').html('<img src="http://s.mynet.com/eksn1/wishlist/process.gif" />');
			jsimport('http://video.mynet.com/addFavori.php?getContentSevenler=' + this.CONTENTMCID + "&p="+pageNo);
		}
	},
	SetSevenlerHTML:function(jsonCevap) {
			eval(jsonCevap);

			this.TotalCount=jsonCevap.totalcount;

			this.cacheArray[this.page] = jsonCevap.data;

			jqVideo('#sevenler').html(jsonCevap.data);

			this.TotalPage = parseInt(this.TotalCount / this.PageSize);

			if(this.TotalCount %  this.PageSize>0){
			   this.TotalPage++;
			}

			if(this.TotalPage<=1){
				
				jqVideo('#sevenpager').hide();
			}

			if(this.TotalCount==0 || jsonCevap.data==''){
				
				jqVideo('#sevenlerdiv').hide();
			}
	},
	ChangeButtonClass:function(){
			if(this.page==1){
				jqVideo('#btngeri').attr("class",'leftArrowDeactive'); 
			}else{
				jqVideo('#btngeri').attr("class",'leftArrow'); 
			}

			if(this.page==this.TotalPage){
				jqVideo('#btnileri').attr("class",'rightArrowDeactive'); 
			}else{
				jqVideo('#btnileri').attr("class",'rightArrow'); 
			}
	},
	WriteHtmlStructure:function(){
		var HTML="";
		HTML +="<div class=\"clear\">";
		HTML +="<h2 class=\"blueCornerTitle fLeft\"><span>"+ this.TITLE+"</span></h2>";
		HTML +="<span id=\"sevenlerpager\" class=\"fRight\">";
		HTML +="<a id=\"btnSevenGeri\" onclick=\"Sevenler.prevSevenler()\" class=\"leftArrow\"><span><<</span></a>";
		HTML +="<a id=\"btnSevenIleri\" onclick=\"Sevenler.nextSevenler()\" class=\"rightArrow\"><span>>></span></a>";
		HTML +="</span>";
		HTML +="</div>";
		HTML +="<div class=\"rightContentBox clear\">";
		HTML +="<div class=\"hiddenListBox clear\">";
		HTML +="<div class=\"listBox clear\">";
		HTML +="<ul id=\"sevenler\" class=\"avatarList\">";
		HTML +="</ul>";
		HTML +="</div>";
		HTML +="</div>";
		HTML +="</div>";
		jqVideo('#sevenlerdiv').html(HTML);
	},
	Init:function(json){
		
		this.SEVENDIV = 'sevenlerdiv';
		this.TITLE=json.title;
		this.CONTENTNAME=json.contentName;
		this.CONTENTMCID=json.mcId;
		
		this.WriteHtmlStructure();
		this.SetPage(1);
	}
}




