//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).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');
	});
	
	//CMS contents show/hide
	$("#cms #tabul #contrexxmenu").click(function(){
		$(".cmspagecontent").css('display','none');
		$("#contrexxcontent").css('display','block');
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
	});
	$("#cms #tabul #joomlamenu").click(function(){
		$(".cmspagecontent").css('display','none');
		$("#joomlacontent").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');
	});
	
	$("#openflashplayer #tabul .tabli").click(function(){
		$(".videopagecontent").css('display','none');
		var ab ="#"+this.id+"content";
		$(ab).css('display','block');	
		$(this).css('color','purple');
		$("#tabul .tabli").css('font-weight','normal');
		$(this).css('font-weight','bold');
		if(ab=="#downloadcontent"){			
		}
	});
});

//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"), ""); 
}