//get the resolution of the viewer to load the corresponding css

var slideWidth =435; 	//set the default width of the slider 

function findResolution(base,css)
{
    var sWidth = screen.width;
    var resolution = 1024;
    if (sWidth <= 1100) {
       resolution = 1024;
    }
    else if (sWidth > 1100 && sWidth <= 1300) {
      resolution = 1280;
	  slideWidth = 535;
    }
    else if (sWidth > 1300 && sWidth <= 1500) {
      resolution = 1440;
	  slideWidth = 570;	
    }
    else if (sWidth > 1500) {
      resolution = 1600;
	  slideWidth = 635;
    }
	css = base+resolution+css;
	document.write('<link rel="stylesheet" type="text/css" href="'+ css +'" />');
}

$(document).ready(function(){
	var t = 0;
	var title = document.title.split(" ").pop();
	
	//show loaders until the page loads
	$("#loader").css("display","none");
	$("#wrapper").css("display","block");
	
	if(title != "Careers" && title != "Contactus" && title != "Testimonials" && title != "Projectsoffered"){
		$("#"+title).parent().parent().css('display','block');
		$("#"+title).parent().css('margin-top','0');
		if($.browser.msie){
			$("#"+title).parent().animate({'marginTop' : '50'},1500);
		} else {
			$("#"+title).parent().animate({'marginTop' : '20'},1500);
		}
		$("#"+title).parent().css('padding-top','0');
		$("#"+title).parent().parent().parent().css('color','orange');
	}
	$("#"+title+" a").css('color','orange');
	
	//Portfolio slidershow
	var currentPosition = 0;
	var slides = $('.slides');	//gets all the elements with class slides to a array
	var numberOfSlides = slides.length;	//number images in the slideshow
	var padding = 200;
	
	//$(document).pngFix();
	
	slides.wrapAll('<div id="slideInner"></div>')
		// Float left to display horizontally, readjust .slides width
		.css({
			'width' : slideWidth
		});
	
	// Set #slideInner width equal to total width of all slides
	$('#slideInner').css('width', (slideWidth+padding) * (numberOfSlides));
	$('.slides').css('width', slideWidth);

	$('.arrowimg')
    .click(function(){
		clearTimeout(t);
		
		if(currentPosition == 0 && $(this).attr('id')=='previous'){
			currentPosition = numberOfSlides - 1;
			time=0;
		}else if(currentPosition == (numberOfSlides-1) && $(this).attr('id')=='next'){
			currentPosition = 0;
			time=0;
		}else{
			// Determine new position
			currentPosition = ($(this).attr('id')=='next') ? currentPosition+1 : currentPosition-1;
			time=2500;
		}
			
		// Move slideInner using margin-left
		$('#slideInner').animate({
			'marginLeft' : (slideWidth+padding)*(-currentPosition)
		},time);
		
		t = setTimeout(function(){$('#next').click();}, 15000);
	});
	
	setTimeout(function(){$('#next').click();}, 15000);
	
	//Business model contents show/hide
	$("#matmenu").click(function(){
		$(".businesscontent").css('display','none');
		$("#matmodel").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});
	$("#fixmenu").click(function(){
		$(".businesscontent").css('display','none');
		$("#fixmodel").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});
	$("#hiremenu").click(function(){
		$(".businesscontent").css('display','none');
		$("#hiremodel").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});

	//PHP contents show/hide
	$("#sitecontent #php #tabul #phpmenu").click(function(){
		$(".phppagecontent").css('display','none');
		$("#phpcontent").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});
	$("#sitecontent #php #tabul #solutionmenu").click(function(){
		$(".phppagecontent").css('display','none');
		$("#solutioncontent").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});
	$("#sitecontent #php #tabul #benifitmenu").click(function(){
		$(".phppagecontent").css('display','none');
		$("#benifitcontent").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});
	
		
	//downloadplayer click message show
	$("#downloadplayer").click(function(){
		$("#"+this.id).css('display','none');
		$(".downloadplayer").css('display','block');
	});
	
	//Video Player contents show/hide
	$("#videostreaming #tabul #featuremenu").click(function(){
		$(".videopagecontent").css('display','none');
		$("#featurecontent").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});
	$("#videostreaming #tabul #advantagemenu").click(function(){
		$(".videopagecontent").css('display','none');
		$("#advantagecontent").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});
	
	//SS4UPlayer contents show/hide
	$("#openflashplayer #tabul .tabli").click(function(){
		var ab ="#"+this.id+"content";
		$("#tabul .tabli").css('font-weight','normal').css('color','blue');
		$("#tabul .tabli a").css('font-weight','normal').css('color','blue');
		$(this).css('color','purple').css('font-weight','bold');
		if(ab!="#installationcontent"){
			$(".ss4uplayercontent").css('display','none');
			$(ab).css('display','block');
		}
	});
	
	//CMS contents show/hide
	$("#cmspage #tabul .tabli").click(function(){
		var ab ="#"+this.id+"content";
		$("#tabul .tabli").css('font-weight','normal').css('color','blue');
		$("#tabul .tabli a").css('font-weight','normal').css('color','blue');
		$(this).css('color','purple').css('font-weight','bold');
		if(ab!="#portfoliocontent" && ab!="#industrialcontent" && ab!="#churchcontent" && ab!="#commercecontent"){
			$(".cmspagecontent").css('display','none');
			$(ab).css('display','block');
		}
	});
	//E-Commerce contents show/hide
	$("#ecommerce #tabul  .tabli").click(function(){	
		var ab ="#"+this.id+"content";
		$("#tabul .tabli").css('font-weight','normal').css('color','blue');
		$("#tabul .tabli a").css('font-weight','normal').css('color','blue');
		$(this).css('color','purple').css('font-weight','bold');
		if(ab!="#portfoliocontent" && ab!="#commercecontent"){
			$(".ecommercepagecontent").css('display','none');
			$(ab).css('display','block');
		}
	});
	jQuery.exists = function(selector) {return ($(selector).size() > 0);}


});
function showCommercePage(page){
	$("#tabul .tabli").css('font-weight','normal').css('color','blue');
	$("#"+page).css('color','purple').css('font-weight','bold');	
	$("#"+page+" a").css('color','purple').css('font-weight','bold');
	page = trim("#"+page+"content");
	if ($.exists(page)) {
		$(".ecommercepagecontent").css('display','none');
		$(page).css('display','block');
	}
}
function showme(page){
	$("#tabul .tabli").css('font-weight','normal').css('color','blue');
	$("#"+page).css('color','purple').css('font-weight','bold');	
	$("#"+page+" a").css('color','purple').css('font-weight','bold');
	page = trim("#"+page+"content");
	if ($.exists(page)) {
		$(".cmspagecontent").css('display','none');
		$(".ss4uplayercontent").css('display','none');
		$(page).css('display','block');
	}
	else if($.exists("#cmscontent")) {
		$(".cmspagecontent").css('display','none');
		$("#cms").css('color','purple').css('font-weight','bold');
		$("#cms a").css('color','purple').css('font-weight','bold');
		$("#cmscontent").css('display','block');
	}
	else if($.exists("#featurecontent")) {
		$("#feature").css('color','purple').css('font-weight','bold');
		$("#feature a").css('color','purple').css('font-weight','bold');
		$(".ss4uplayercontent").css('display','none');
		$("#featurecontent").css('display','block');
	}	
}
function compareAndChangeHeight(e1,e2){
	h1 = $(e1).css('height');
	h2 = $(e2).css('height');
	if(h1>h2)
		$(e2).css('height',h1);
	else
		$(e1).css('height',h2);
}
//String trim
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); 
}

