// JavaScript Document

var myWidth = 0;
var myHeight = 0;
var blockwidth=100;
		function reportSize() {
		  
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = window.innerWidth;
		    myHeight = window.innerHeight;
		  } else {
		    if( document.documentElement &&
		        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		      //IE 6+ in 'standards compliant mode'
		      myWidth = document.documentElement.clientWidth;
		      myHeight = document.documentElement.clientHeight;
		    } else {
		      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		        //IE 4 compatible
		        myWidth = document.body.clientWidth;
		        myHeight = document.body.clientHeight;
		      }
		    }
		  }
		}
		
		function doTest(){
			reportSize();

			scrollToWindow();
			if(myWidth>=1024)
			{
				document.body.style.overflowX = 'hidden';
				document.body.style.overflowY = 'visible';
				
				
			}else{
				document.body.style.overflowX = 'visible';
				document.body.style.overflowY = 'visible';
				
			}
		}
		function init(){
			window.onresize = doTest;
			doTest();
	//------------------------for index.html and product.html---------------------------------------------------
	$(function(){
		 
	var hsort_flg = false;

	//setup
	var vg = $("#grid-content").vgrid({
		easeing: "easeOutQuint",
		time: 400,
		delay: 20,
		fadeIn: {
			time: 500,
			delay: 50
		},
		onStart: function(){
			$("#message1")
				.css("visibility", "visible")
				.fadeOut("slow",function(){
					$(this).show().css("visibility", "hidden");
				});
				
		},
		onFinish: function(){
			$("#message2")
				.css("visibility", "visible")
				.fadeOut("slow",function(){
					$(this).show().css("visibility", "hidden");
				});
			
		}
	});
	
	//add item
	$("#additem").click(function(e){
		var _item = $('<div>\
				<h3>New Item</h3>\
				<p>Foo</p>\
				<p><a href="#">January 19, 2010</a></p>\
			</div>')
			.hide()
			.addClass(Math.random() > 0.3 ? 'wn' : 'wl')
			.addClass(Math.random() > 0.3 ? 'hn' : 'hl');
		vg.prepend(_item);
		vg.vgrefresh(null, null, null, function(){
			_item.fadeIn(300);
		});
		hsort_flg = true;
	});

	//delete
	//vg.find("a").live('click', function(e){
//		$(this).parent().parent().fadeOut(200, function(){
//			$(this).remove();
//			vg.vgrefresh();
//		});
//		return false;
//	});

	//sort
	$("#hsort").click(function(e){
		hsort_flg = !hsort_flg;
		$("#grid-content").vgsort(function(a, b){
			var _a = $(a).find('h3').text();
			var _b = $(b).find('h3').text();
			var _c = hsort_flg ? 1 : -1 ;
			return (_a > _b) ? _c * -1 : _c ;
		}, "easeInOutExpo", 300, 0);
		return false;
	});
	$("#rsort").click(function(e){
		$("#grid-content").vgsort(function(a, b){
			return Math.random() > 0.5 ? 1 : -1 ;
		}, "easeInOutExpo", 300, 20);
		hsort_flg = true;
		return false;
	});
});

		}
		
		function scrollToWindow()
		{
		  if(myWidth<1188)
		  {
			  var goto=(1188-myWidth)/2;
			 window.scrollTo(goto,0); 
			 }else{
			  window.scrollTo(0,0);
			  }
		   
		}

		