function resizescreen(){
	
	var pantalla_ancho = $(window).width();
		
	if((pantalla_ancho > 979)&&(pantalla_ancho < 1221)){
		
		$("#page").css('width', 942);
		$(".col.cone, .col.ctwo, .col.cthree, .col.cfour").hide();

	}else if((pantalla_ancho > 1221)&&(pantalla_ancho < 1462)){
		
		$("#page").css('width', 1182);
		$(".col.cone, .col.ctwo, .col.cthree, .col.cfour").hide();
		$(".col.cone").show();

	}else if(pantalla_ancho > 1462){
		
		$("#page").css('width', 1423);
		$(".col.cone, .col.ctwo, .col.cthree, .col.cfour").show();

	}
	
}

$(window).resize(function () {

//	resizescreen();

});

var viewIncart={
		num:function(){
            $.ajax({
                url:"/user/postData/userIncartNum.asp?"+Math.random(),
                type:"GET",
                success:function(result){
                    $('#strcartnum').html(result);
				 }	
            })
			 }
		}	
		

$(document).ready(function() {
	
//	resizescreen();
	
/* GALLERY */




	 var altofotogallery = $("#thegallery .picture img").height();
	 var margenthumb = (altofotogallery/2)-95;
	 $("#thegallery .previous, #thegallery .next").css('margin-bottom', ''+margenthumb+'px');

/* RANKING HOME */

	$(".rankinghome .more").hide();
	
	$(".rankinghome .item").mousedown(function() {

		if(this.className.indexOf("active") != -1) {
			$(this).next().slideUp(200);
			$(this).removeClass("active");
		}
		else {
			$(".rankinghome .item").removeClass("active");
			$(this).addClass("active");
			$(".rankinghome .item").next().slideUp(200);
			$(this).next().slideDown(200);
		}
		return false;
	});
	
	$(".more .close").click(function() {
			$(".rankinghome .item").removeClass("active");
			$(this).addClass("active");
			$(".rankinghome .item").next().slideUp(200);
			$(this).next().slideDown(200);
		return false;
	});
	

	
/* OPEN TAG */

	$('.opentag em').click(function(){	

		$('.taginfo').animate({ height: 'toggle' }, 1000 );
	});
	
	$('.closetag').click(function(){
		$('.taginfo').animate({ height: 'toggle' }, 1000 );
		setTimeout("$('.taginfo').css('display','none');",2000);
	});
	
/* OPEN ABOUT US */

	$('.openaboutus').click(function(){	
		$(this).removeAttr("href");
		$('#aboutus').css('display','block');	
		$('#header').animate({ marginTop: "-100px" }, 1000 );
	});
	
	$('.closeaboutus').click(function(){
		$(this).removeAttr("href");
		$('#header').animate({ marginTop: "-600px" }, 1000 );
		setTimeout("$('#aboutus').css('display','none');",2000);
	});
	
/* TABS ABOUT US */

	$(".tab_content").hide();
	$("ul.tabs li:first").addClass("active").show();
	$(".tab_content:first").show();

	$("ul.tabs li").mousedown(function(){
									   
		$("ul.tabs li").removeClass("active");
		$(this).addClass("active");
		$(".tab_content").hide();
	
		var activeTab = $(this).find("a").attr("id");
		$(activeTab).fadeIn();
		
		return false;
		
	});

	
$(function(){
		   
	$.fn.scrollToTop=function(){
		
		$("#toTop").hide().removeAttr("href");
		$("#toFavourites").hide();
		
		if($(window).scrollTop()!="0"){
			$(this).fadeIn("slow")
		}
		var scrollDiv=$(this);
		
		$(window).scroll(function(){
								  
			if($(window).scrollTop()=="0"){
				$(scrollDiv).fadeOut("slow")
			}else{
				$(scrollDiv).fadeIn("slow")
			}
		
		});
		
		$(this).click(function(){
			$("html, body").animate({scrollTop:0},"slow");
		});
	
	}
			
});

$(function() {
	$("#toTop, #toFavourites").scrollToTop();
});
	
/* FOCUS INPUT */
	
	$('input.focus').focus(function() {
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input.focus').blur(function() {
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});

/* HEIGHT COLUMNS BLOG */

	var height_content = $('#content').height();
	
	/* clear both */
	
	$('.listpost li:nth-child(2n+2)').after('<div class="clear"></div>');
	
	/* Caja sidebar productos */
	
	var inside_ancho = $('.inside').width();
	
	if(inside_ancho < 1182){

		$("#otherproducts").css('width', 0);

	}else if((inside_ancho > 1181)&&(inside_ancho < 1423)){
		
		$("#otherproducts").css('width', 218);

	}else if(inside_ancho > 1422){
		
		$("#otherproducts").css('width', 459);

	}

});


function ajustaVentana() { 

	var ancho_content = $("#page").width();
	if((ancho_content > 941)&&(ancho_content < 1181)){
	 // var ancho_li = 459;
	 // var alto_li = 287;
	 	var	ancho_li = 338;
		var	alto_li = 211;
	}else if((ancho_content > 1181)&&(ancho_content < 1422)){
		 var  ancho_li = 378;
		  var alto_li = 236;
	}else if(ancho_content > 1422){
		var	ancho_li = 338;
		var	alto_li = 211;
	}

	$(".listsites.awards.view2 li img, .listsites.awards.view2 li .info").css('width', ancho_li+'px');
	$(".listsites.awards.view2 li img, .listsites.awards.view2 li .info").css('height', alto_li+'px');
	
	$(".listsites.awards.view2 li").css('width', ancho_li+'px');
	$(".listsites.awards.view2 li").css('height', alto_li+50+'px');
	
	$(".listsites.awards.view2 li .website").css('top', alto_li-30+'px');

}

$(window).resize(function() {

	//ajustaVentana();

});

$(document).ready(function() {
						   
	//ajustaVentana();	

}); 

function poluoluoshare(type)
{
	var link = '';
	switch(type)
	{
		case 'qqweibo': link = 'http://v.t.qq.com/share/share.php?title={title}&url={url}&appkey=&site={title}'; break;
		case 'sina': link = 'http://v.t.sina.com.cn/share/share.php?appkey=1129579542&url={url}&title={title}&content=gb2312'; break;
		case 'kaixin': link = 'http://www.kaixin001.com/repaste/share.php?rtitle={title}&rcontent={url}'; break;
		case 'qqkoujian': link = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={url}&title={title}&pic={pic}'; break;
		case 'qqxiaoyou': link = 'http://pengyou.qq.com/index.php?mod=usershare&act=onekey&to=xiaoyou&url={url}&title={title}'; break;
		case '163weibo': link = 'http://t.163.com/article/user/checkLogin.do?source={site}&info={title}'; break;
		case 'moptui': link = 'http://tk.mop.com/api/post.htm?url={url}&title={title}&desc={content}'; break;
		case 'feixin': link = 'http://space.feixin.10086.cn/api/share?source={site}&title={title}&url={url}'; break;
		case 'sohu': link = 'http://t.sohu.com/third/post.jsp?&url={url}&title={title}&content=utf-8'; break;
		case 'renren': link = 'http://share.renren.com/share/buttonshare.do?link={url}&title={title}'; break;
		case 'baidu': link = 'http://apps.hi.baidu.com/share/?url={url}&title={title}&content={content}'; break;
		case 'taojianghu': link = 'http://share.jianghu.taobao.com/share/addShare.htm?url={url}&title={title}&content={content}'; break;
		//case 'baidu': link = 'http://tieba.baidu.com/i/sys/share?type=text&title={title}&link={url}'; break;
		//case 'douban': link = 'http://www.douban.com/recommend/?url={url}&title={title}'; break;
		//case 'qq': link = 'http://shuqian.qq.com/post?from=3&title={title}&uri={url}'; break;
	}
	link = link.replace('{title}', encodeURIComponent(document.getElementsByTagName('title')[0].innerHTML));
	link = link.replace('{url}', encodeURIComponent(window.location.href));
	link = link.replace('{source}', 'gescc.com');
	window.open(link);
}
