
/*
	Corner 
*/
var bse_url = 'http://www.silvermetalsuae.com/';

var optgjaks = jakGalleryOptions();

	function jakGalleryOptions(){
	
	var optgjaksArr = {galleryClassName: 'lightBox',
			zIndex: 10,
			useShadow: true,
			imagePath: bse_url+'images/jak/shadow-',
			usePageShader: true,
			components: {
				strip: SZN.LightBox.Strip,
				navigation: SZN.LightBox.Navigation.Basic,
				anchorage: SZN.LightBox.Anchorage.Fixed,
				main: SZN.LightBox.Main.CenteredScaled,
				description: SZN.LightBox.Description.Basic,
				transition: SZN.LightBox.Transition.Fade,
				others: [{name: 'slideshow', part: SZN.SlideShow, setting: {duration: 5, autoplay: false}}]
			},
			navigationOpt : {
				continuous: false,
				showDisabled: true
			},
			transitionOpt: {
				interval: 500,
				overlap: 0.5
			}
		}
		
		return optgjaksArr;
	}

$(document).ready(function() {
	$(".vscroller").jCarouselLite({
		visible: 2,
		scroll:2,
		auto:5000,
		vertical:true,
		circular:true,
		btnNext: ".up",
		btnPrev: ".down"
	});
		
	$(".treeview").treeview({
		collapsed: false
	});
	// arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	var arrayPageSize =_getPageSize();
	var wrapper = $("body > .clearfix.container:first");
	var wrapperHeight = wrapper.height();
	var footerWrapHeight = $('.footerWrap').height();
	if(wrapperHeight < (arrayPageSize[3]-footerWrapHeight)){
		wrapper.css('height',(arrayPageSize[3]-footerWrapHeight)+'px');
	}
});

	function loadProjects(id,url){

		$.post(url+id, function(data) {
			var imagesObj = eval('(' + data + ')');
			generateGallery(imagesObj);
		});
		
		$(".loading").bind("ajaxSend", function(){
		   $(this).show();
		 }).bind("ajaxComplete", function(){
		   $(this).hide();
		 });
	}
	
	function generateGallery(imagesObj){
		var liHtml = '';
		var gjaks = '';
		var Images = imagesObj.data;
		if(Images.length != 0){
			
			for(var i=0;i<Images.length;i++){
				liHtml += '<li><a title="'+Images[i].title+'" class="jaklightbox"  onclick="gjaks.show('+i+'); return false;" href="'+bse_url+Images[i].image+'" ><img src="'+bse_url+'lib/image.php?img='+bse_url+Images[i].image+'&w=107&h=80 " width="107" height="80" /></a></li>';
			}
			var arr = "var dataJakJs = [";
			for(var i=0;i<Images.length;i++){
				if(i !=0)
					arr += ",";
				arr +="{alt: '"+Images[i].title+"',description: '"+Images[i].title+"',small: {url: ''},big: {url: '"+bse_url+Images[i].image+"'} }";
			}
			arr +="];";
			
			var ajObj = "var gjaks = new SZN.LightBox(dataJakJs, optgjaks);";
			$("head").append("<script>"+arr+"\n"+ajObj+"</script>");
		}
		else{
			$(".loading").hide();
			liHtml = 'No gallery images';
		}
		$('.hscroller ul').html(liHtml);
		$('#projectTitle').html(imagesObj.title);
		$('.titlendCleint .pname').html(imagesObj.projectname);
		$('#projectDetails').html(imagesObj.details);
		$('.titlendCleint .pclient').html(imagesObj.client);
		$('.titlendCleint .pstatus').html(imagesObj.status);
		loadScroll();
	}
	
	function loadScrollClick(){
		$('.projectThumbnails li a').click(function(){
			var src = $(this).attr('rel');
			$('.wideImage img').attr('src',src);
			return false;
		});
	}
	
	function loadScroll(){
	
		var isExs = $(".hscroller > ul > li").size();
		if(isExs != 0){
			$(".hscroller").jCarouselLite({
				visible: 4,
				scroll:4,
				circular:false,
				btnNext: ".next",
				btnPrev: ".prev"
			});
		}
	}
	
	function _getPageSize() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	};


