var aURL = "'"+window.location+"'";
var aPosition = aURL.indexOf("192.168.10.3");
if(aPosition > 0){
	var local = true;
}else{
	var local = false;
}
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery.easing.easeOutBack=function (x, t, b, c, d, s) {
		if (s == undefined) s = 0.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	};
jQuery(function( $ ){
	
	$('#pageNavigationOne li').click(function(){
		var postId = $(this).attr('id');
		var splitPostId = postId.split('_');
		var postIndex = '#postTabs_'+splitPostId[2]+'_'+splitPostId[3];
		var content = $(postIndex).html();
		$("#homeContainer").fadeIn("slow", function() {
			$(this).html(content);
		});
		
	});


});

jQuery(function( $ ){
	$('#SearchPostDiv').serialScroll({
		target:'#searchNavigation',
		items:'li', 
		prev:'img.searchRight',
		next:'img.searchLeft',
		axis:'xy',
		navigation:'#searchNavigationOne li',
		duration:700,
		force:false, 
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
		var nextId = elem.id;
		var imagePath = '';
		var templateName = $('#templateName').attr('rel')+'/images/buttons/';
		$('#searchNavigationOne li').each(function() {

			var liId = this.id;
			var imageId = '#'+liId+' img';
			var imageSource = $(imageId).attr('src');
			var splitImage = imageSource.split('/');
			var imageOther = templateName + 'otherPage.gif';
			var otherImage = '#searchNavigationOne li img';
			$(otherImage).attr('src',imageOther);
		});
		var imageActive = templateName + 'activePage.gif';
		var splitElemId = nextId.split('_');
		var activeImageId = splitElemId[0]+'_li_'+splitElemId[1];
		var imageId = '#'+activeImageId+' img';
		$(imageId).attr('src',imageActive);
		}
	});
});

jQuery(function( $ ){
	$('#ArchiveCatPost').serialScroll({
		target:'#CategorySection',
		items:'li', 
		prev:'img.catLeft',
		next:'img.catRight',
		axis:'xy',
		navigation:'#catNavigationOne li',
		duration:700,
		force:false, 
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
		var nextId = elem.id;
		var imagePath = '';
		var templateName = $('#templateName').attr('rel')+'/images/buttons/';
		$('#catNavigationOne li').each(function() {

			var liId = this.id;
			var imageId = '#'+liId+' img';
			var imageSource = $(imageId).attr('src');
			var splitImage = imageSource.split('/');
			var imageOther = templateName + 'otherPage.gif';
			var otherImage = '#catNavigationOne li img';
			$(otherImage).attr('src',imageOther);
		});
		var imageActive = templateName + 'activePage.gif';
		var splitElemId = nextId.split('_');
		var activeImageId = splitElemId[0]+'_li_'+splitElemId[1];
		var imageId = '#'+activeImageId+' img';
		$(imageId).attr('src',imageActive);
		}
	});
});

jQuery(function( $ ){
	$('#ClientGallery').serialScroll({
		target:'#ClientSection',
		items:'li', 
		prev:'img.widgetLeft',
		next:'img.widgetRight',
		axis:'xy',
		navigation:'#ClientSection',
		duration:700,
		force:false, 
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
		$('#clientId').val(elem.id);
		var nextId = elem.id;
		var imagePath = '';
		}
	});
	$('#ClientSection li a').click(function(e){
		e.stopPropagation();
	});	
});

jQuery(function( $ ){
	$('#FullGallery').serialScroll({
		target:'#FullSection',
		items:'li', 
		prev:'img.widgetLeft',
		next:'img.widgetRight',
		axis:'xy',
		navigation:'#FullSection',
		duration:700,
		force:false, 
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
		$('#clientId').val(elem.id);
		var nextId = elem.id;
		var imagePath = '';
		}
	});
	$('#ClientSection li a').click(function(e){
		e.stopPropagation();
	});	
});

jQuery(function( $ ){
$('.topMenuMore').livequery('click',function(){
		var menuMax = this.id;
		var splitMenu = menuMax.split('_');
		var menuMaxValue = splitMenu[1];
		var parentId = $('#subnav li').attr('id');
		var splitParent = parentId.split('_');
		var parentValue = splitParent[2];
		$.post("/stylusinc/GiveMeMore.php",
		{ 'menuMax': menuMaxValue,'parentId': parentValue,'actiontype':'More'},
			function(data){
			var dataSplit = data.split('-->');
			var trimData = $.trim(dataSplit[2]);
			 $('#subnav').customFadeOut('100', function() {
					/* $('#subnav').show('100', function() { */
				if(trimData == ''){
					trimData = data;
				}
					$('#subnav').html(trimData).customFadeIn('fast','');
				});
			}
		);
		
	});
});

jQuery(function( $ ){
$('.topMenuLess').livequery('click',function(){
		var menuMax = this.id;
		var splitMenu = menuMax.split('_');
		var menuMaxValue = splitMenu[1];
		var parentId = '';
		$('#subnav li').each(function() {
			if(this.id){
				parentId = this.id;
			}
		}
		);
		var splitParent = parentId.split('_');
		var parentValue = splitParent[2];
		$.post("/stylusinc/GiveMeMore.php",
		{ 'menuMax': menuMaxValue,'parentId': parentValue,'actiontype':'Less'},
			function(data){
			var dataSplit = data.split('-->');
			var trimData = $.trim(dataSplit[2]);
				$('#subnav').customFadeOut('slow', function() {
				if(trimData == ''){
					trimData = data;
				}
				$('#subnav').html(trimData).customFadeIn('fast','');
				});

			}
		);
		
	});
});

jQuery(function( $ ){
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != ''){
				callback();
			}
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != ''){
				callback();
			}
		});
	};
});



jQuery(function( $ ){
	$('#tabSection').serialScroll({
		items:'li', 
		prev:'img.tabLeft',
		next:'img.tabRight',
		axis:'xy',
		navigation:'#tabSection',
		duration:700,
		force:true, 
		lazy:true,
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
		var nextId = elem.id;
		var imagePath = '';
		}
	});
	$('#tabSection li a').click(function(e){
		e.stopPropagation();
	});	
	
});

jQuery(function( $ ){
	$('#tabContainer').serialScroll({
		items:'li', 
		prev:'img.quickLeft',
		next:'img.quickRight',
		axis:'xy',
		navigation:'#tabSection',
		duration:700,
		force:true, 
		lazy:true,
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
		var nextId = elem.id;
		var imagePath = '';
		}
	});
	$('#tabContainer li a').click(function(e){
		e.stopPropagation();
	});	
});


jQuery(function( $ ){
	$('#tabContainer').serialScroll({
		items:'li', 
		prev:'img.archiveLeft',
		next:'img.archiveRight',
		axis:'xy',
		navigation:'#CategoryList',
		duration:700,
		force:true, 
		lazy:true,
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
		var nextId = elem.id;
		var imagePath = '';
		}
	});
	$('#CategoryList li a').click(function(e){
		e.stopPropagation();
	});	
	
});



jQuery(function( $ ){
	$('#LatestPost').livequery('click',function(){
	$('#tabSection').fadeOut('600','');
		setTimeout ("LoadPostList()", 1000 );
	});
});


jQuery(function( $ ){
	$('#CategoryPost').livequery('click',function(){
	$('#CategoryList').fadeOut('600','');
		setTimeout ("LoadCategoryList()", 1000 );
	});
});


jQuery(function( $ ){
	$('#ArchivePost').livequery('click',function(){
	$('#CategoryList').fadeOut('600','');
		setTimeout ("LoadArchiveList()", 1000 );
	});
});

function LoadCategoryList(){
	jQuery(function( $ ){
	$('#tabsI li a').removeClass('selected');
	$('#tabsI li a span').removeClass('selected');
	$('#CategoryPost a').addClass('selected');
	$('#CategoryPost a span').addClass('selected');
	$("#tabContainer").html("<p style='padding: 55px 0px 0px 55px; margin:0px; float:left;position:relative; height:120px; width:100px;'><img src='/stylusinc/Loader/ajax-loader.gif' border='0' alt='Loading'><br>Loading</p>");
	$.get("/stylusinc/CategoryList.php",function(data){
		var dataSplit = data.split('-->');
		var trimData = $.trim(dataSplit[2]);
		if(trimData == ''){
			trimData = data;
		}
		$("#tabContainer").html(trimData);
	  });
	});
	$('#tabContainer img.archiveLeft').css({display:''});
	$('#tabContainer img.archiveRight').css({display:''});
}

function LoadPostList(){
	jQuery(function( $ ){
	$('#tabsI li a').removeClass('selected');
	$('#tabsI li a span').removeClass('selected');
	$('#LatestPost a').addClass('selected');
	$('#LatestPost a span').addClass('selected');
	$('#tabContainer img.tabLeft').css({display:''});
	$('#tabContainer img.tabRight').css({display:''});
	$("#tabContainer").html("<p style='padding: 55px 0px 0px 55px; margin:0px; float:left;position:relative; height:120px; width:100px;'><img src='/stylusinc/Loader/ajax-loader.gif' border='0' alt='Loading'><br>Loading</p>");
	$.get("/stylusinc/LatestPost.php",function(data){
		var dataSplit = data.split('-->');
		var trimData = $.trim(dataSplit[2]);
		if(trimData == ''){
			trimData = data;
		}
		$("#tabContainer").html(trimData);
	  });
	});
}

function LoadArchiveList(){
	jQuery(function( $ ){
	$('#tabsI li a').removeClass('selected');
	$('#tabsI li a span').removeClass('selected');
	$('#ArchivePost a').addClass('selected');
	$('#ArchivePost a span').addClass('selected');
	$('#tabContainer img.archiveLeft').css({display:'none'});
	$('#tabContainer img.archiveRight').css({display:'none'});
	$("#tabContainer").html("<p style='padding: 55px 0px 0px 55px; margin:0px; float:left;position:relative; height:120px; width:100px;'><img src='/stylusinc/Loader/ajax-loader.gif' border='0' alt='Loading'><br>Loading</p>");
	$.get("/stylusinc/Archives.php",function(data){
		var dataSplit = data.split('-->');
		var trimData = $.trim(dataSplit[2]);
		if(trimData == ''){
			trimData = data;
		}
		$("#tabContainer").html(trimData);
	  });
	});
	$('#tabContainer img.archiveLeft').css({display:''});
	$('#tabContainer img.archiveRight').css({display:''});
}

jQuery(function( $ ){
		$('#OfferingMore').livequery('click',function(){
			var moreText = $('#OfferingMore').text();
			if(moreText == 'More>>'){
				$('#OfferingList li').each(function(){
					var display = $(this).css('display');
					var textName = $.trim($(this).text());
					if(display == 'none' && textName != 'More>>' ){
						$('#OfferingList li').customFadeIn('600', function() {
						var content = $('#OfferingList li').html();
							if(content == ''){
								$('#OfferingList li').html(content);
							}
						});
						$(this).css({display:''});
					}
				});
			$('#OfferingMore').text('<<Less');
			}else if(moreText == '<<Less'){
				var liCount = 0;
				$('#OfferingList li').each(function(){
					var display = $(this).css('display');
					var textName = $.trim($(this).text());
					if(liCount >= 3 && textName != '<<Less'){
						var content = $('#OfferingList li').html();
						$(this).customFadeOut('600', function() {
								$(this).css({display:'none'});
						});
					}
					liCount++;
				});
				$('#OfferingMore').text('More>>');
			}
		});
});

jQuery(function( $ ){
		$('#CaseStudiesMore').livequery('click',function(){
			var moreText = $('#CaseStudiesMore').text();
			if(moreText == 'More>>'){
				$('#CaseStudiesList li').each(function(){
					var display = $(this).css('display');
					var textName = $.trim($(this).text());
					if(display == 'none' && textName != 'More>>' ){
						$('#CaseStudiesList li').customFadeIn('600', function() {
						var content = $('#CaseStudiesList li').html();
							if(content == ''){
								$('#CaseStudiesList li').html(content);
							}
						});
						$(this).css({display:''});
					}
				});
			$('#CaseStudiesMore').text('<<Less');
			}else if(moreText == '<<Less'){
				var liCount = 0;
				$('#CaseStudiesList li').each(function(){
					var display = $(this).css('display');
					var textName = $.trim($(this).text());
					if(liCount >= 3 && textName != '<<Less'){
						var content = $('#CaseStudiesList li').html();
						$(this).customFadeOut('600', function() {
								$(this).css({display:'none'});
						});
					}
					liCount++;
				});
				$('#CaseStudiesMore').text('More>>');
			}
		});
});


jQuery(function( $ ){
	$('#emailReferenceGo').click(function(){
		var email = $('#emailReference').val();
		var clientId = $('#clientId').val();
		if(email == 'Your email address here.' || email == ''){
			$('#ClientMsg').fadeIn('600','');
			$('#ClientMsg').text('Please Enter Valid Email Address');
			setTimeout ("FadeOut()", 2000 );
		}else{
			$.post("/stylusinc/GalleryEmail.php",{ 'email': email,'clientId': clientId},
				function(data){
					trimData = $.trim(data);
					if(trimData == 'Error'){
						$('#ClientMsg').fadeIn('600','');
						$('#ClientMsg').text('Please Enter Valid Email Address');
						setTimeout ("FadeOut()", 2000 );
					}else{
						var dataSplit = data.split('-->');
						var trimData = $.trim(dataSplit[2]);
						if(trimData == ''){
							trimData = $.trim(data);
						}
						$('#ClientMsg').fadeIn('600','');
						$('#ClientMsg').text('Mail has been sent');
						setTimeout ("FadeOut()", 2000 );
					}
				}
			);
		}
});
});


function FadeOut(){
	jQuery(function( $ ){
		$('#ClientMsg').fadeOut('600','');
		$('#emailReference').val('Your email address here.');
	});
}
jQuery(function( $ ){
	$('#s').blur(function(){
		var searchkey = $('#s').val();
		if(searchkey == ''){
			$('#s').val('Search this website...');
		}else{
			$('#s').searchkey;
		}
});

	$('#s').focus(function(){
		$('#s').val('');
});

});


jQuery(function( $ ){
	$('#emailReference').blur(function(){
		var emailValue = $('#emailReference').val();
		if(emailValue == ''){
			$('#emailReference').val('Your email address here.');
		}
});

	$('#emailReference').focus(function(){
		$('#emailReference').val('');
});

});

jQuery(function( $ ){
	var marginLeft = '';
	var idIndex = '';
	$('#nav li').each(function(){
		var checkClass = $(this).attr('className');
		if(checkClass.indexOf('current_page_item') > 1){
			idIndex = '#'+this.id;
		}
	});
	var $ul = $('#nav > li');
	var firstItem = $ul[0].id;
	var firstIndex = '#'+firstItem;
	var xn = $(idIndex).offset().left;
	var x1 = $(firstIndex).offset().left;
	//alert(xn);
	//alert(x1);
	marginLeft = (xn - x1) + 'px';
	if(marginLeft == ''){
		marginLeft = '0px';
	}
	$('#subnav').css({'margin-left':marginLeft});

});

jQuery(function( $ ){
	var maxLenLabel = '';
	var maxLenLabelTemp = 0;
	$('#contactUsLeft p label').each(function(){
		maxLenLabel = $(this).width();
		if(maxLenLabel > maxLenLabelTemp){
			maxLenLabelTemp = maxLenLabel;
		}
	});
	if($.browser.msie){
	maxLenLabelTemp = maxLenLabelTemp - 50;
	}
	$('#contactUsLeft p label').width(maxLenLabelTemp);
	maxLenLabel = '';
	maxLenLabelTemp = 0;

	$('#contactUsRight p label').each(function(){
		maxLenLabel = $(this).width();
		if(maxLenLabel > maxLenLabelTemp){
			maxLenLabelTemp = maxLenLabel;
		}
	});
	if($.browser.msie){
	maxLenLabelTemp = maxLenLabelTemp + 20;
	}
	$('#contactUsRight p label').width(maxLenLabelTemp);
});

jQuery(function( $ ){
	$('#ContactUs').click(function(){
		var postField = '';
		var postValue = '';
		$('#contactUsMain :input').each(function() {
		var type = this.type;
		var tag = this.tagName.toLowerCase(); 
			var elementId = this.id;
			var indexSplit = elementId.split('_');
			var spanIndex = '#'+indexSplit[1]+'_span';
			var spanValue = $(spanIndex).text();
			var elementIndex = '#'+this.id;
				postValue = $(elementIndex).val();
				if(type != 'button' && type != 'image'){
					postField += elementId+"="+postValue+"&";
				}
		});
		var ser = $('#contactUsMain :input').serialize();
		var postLen = (postField.length) - 1;
		postField = postField.substr(0,postLen);
		$('#contactStatus').fadeIn('1000','');
		$('#contactStatus').attr('class','normalMsg');
		$('#contactStatusImg').attr('class','normalImg');
		$('#contactStatusMessage').text('System Processing the form Please wait...');
		//alert(postField);
		$.post("/stylusinc/ContactUsPost.php",postField,
			function(data){
			var data = $.trim(data);
			//alert(data);
			var splitData = data.split('|');
			var fieldCount = 0;
			var errorCount = 0;
			var successCount = 0;
			$('#contactUsMain :input').each(function() {
				var type = this.type;
				var tag = this.tagName.toLowerCase(); 
				var elementId = this.id;
				var elementIndex = '#'+this.id;
				var elementHelpIndex = '#'+this.id+'_help img';
				var fileNormalClass = $(elementIndex).attr('class');
				if(type != 'button' && type != 'image'){
					var splitValue = splitData[fieldCount].split(':');
					var fieldId = $.trim(splitValue[0]);
					var fieldStatus = $.trim(splitValue[1]);
					var fieldMsg = $.trim(splitValue[2]);
					if(elementId == fieldId){
						//alert(fieldStatus);
						if(fieldStatus == 'Error'){
							if(fileNormalClass == 'filenormal' || fileNormalClass == 'filevalid' || fileNormalClass == 'fileerror'){
								$(elementIndex).attr('class','fileerror');
								$(elementHelpIndex).css({'display':'inline'});
							}else{
								$(elementIndex).attr('class','error');
								$(elementHelpIndex).css({'display':'inline'});
							}
							errorCount++;
						}else if(fieldStatus == 'Success'){
							if(fileNormalClass == 'filenormal' || fileNormalClass == 'filevalid' || fileNormalClass == 'fileerror'){
								$(elementIndex).attr('class','filevalid');
								$(elementHelpIndex).css({'display':'none'});
							}else{
								$(elementIndex).attr('class','valid');
								$(elementHelpIndex).css({'display':'none'});
							}
							successCount++;
						}else if(fieldStatus == 'Invalid'){
							if(fileNormalClass == 'filenormal' || fileNormalClass == 'filevalid' || fileNormalClass == 'fileerror'){
								$(elementIndex).attr('class','fileinvalid');
								$(elementHelpIndex).css({'display':'inline'});
							}else{
								$(elementIndex).attr('class','invalid');
								$(elementHelpIndex).css({'display':'inline'});
							}
						}
					}
					fieldCount++;
				}
			});
			
				if(successCount > errorCount){
					$('#contactStatus').fadeIn('1000','');
					$('#contactStatus').attr('class','invalidMsg');
					$('#contactStatusImg').attr('class','invalidImg');
					$('#contactStatusMessage').text('Error - Please check the input data.');
				}
				if(successCount < errorCount){
					$('#contactStatus').fadeIn('1000','');
					$('#contactStatus').attr('class','errorMsg');
					$('#contactStatusImg').attr('class','errorImg');
					$('#contactStatusMessage').text('Invalid Submission. Please check the input data again.');
				}
				if(successCount == fieldCount){
					$('#contactStatus').fadeIn('1000','');
					$('#contactStatus').attr('class','successMsg');
					$('#contactStatusImg').attr('class','successImg');
					$('#contactStatusMessage').text('Thank you. - Within 24 hours our executive will contact you.');
					$('#contactUsMain :input').each(function() {
						var type = this.type;
						if(type != 'button' && type != 'image'){
								var elementId = this.id;
								var elementIndex = '#'+this.id;
								var fileNormalClass = $(elementIndex).attr('class');
								if(fileNormalClass == 'filenormal' || fileNormalClass == 'filevalid' || fileNormalClass == 'fileerror'){
									$(elementIndex).attr('class','filenormal');
								}else{
									$(elementIndex).attr('class','normal');
								}
								$(elementIndex).val('');
						}
					});
					window.location.href="http://www.stylusinc.net/?page_id=1163&menuId=92";
				}
			}
		);
	});
});

jQuery(function( $ ){
	var MainError = $('#contactStatusMessage').text();
	$('#contactUsMain span a img').click(function(){
		var parentIndex = $(this).parent().parent().attr('id');
		var postField = 'parentId='+parentIndex;
		$.post("/stylusinc/ContactUsHover.php",postField,function(data){
			var trimData = $.trim(data);
			$('#contactStatusMessage').customFadeIn('50000',function(){
				$('#contactStatusMessage').text(trimData);
			});
		});
	});
});




jQuery(function( $ ){
	$('#RecentSearch').livequery('click',function(){
	$('#RecentTagList').fadeOut('600','');
		setTimeout ("LoadRecentSearchTagList()", 1000 );
	});
});

jQuery(function( $ ){
	$('#RelatedSearch').livequery('click',function(){
	$('#RecentTagList').fadeOut('600','');
		setTimeout ("LoadRelatedSearchTagList()", 1000 );
	});
});

function LoadRecentSearchTagList(){
	jQuery(function( $ ){
	$('#tabsI li a').removeClass('selected');
	$('#tabsI li a span').removeClass('selected');
	$('#RecentSearch a').addClass('selected');
	$('#RecentSearch a span').addClass('selected');
	$("#tabContainer").html("<div style='padding-left:60px;padding-top:55px;float:left;position:relative;'><img src='/stylusinc/Loader/ajax-loader.gif' border='0' alt='Loading'><br>Loading</div>");
	$.get("/stylusinc/RecentSearchTags.php",function(data){
		var dataSplit = data.split('-->');
		var trimData = $.trim(dataSplit[2]);
		if(trimData == ''){
			trimData = data;
		}
		$("#tabContainer").html(trimData);
	  });
	});
}

function gup(name)
{
	name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
	var regexS = "[\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null ){
	return "";
	}else{
	return results[1];
	}
}


function LoadRelatedSearchTagList(){
	jQuery(function( $ ){
	$('#tabsI li a').removeClass('selected');
	$('#tabsI li a span').removeClass('selected');
	$('#RelatedSearch a').addClass('selected');
	$('#RelatedSearch a span').addClass('selected');
	var paramS = gup('s');
	var paramSK = gup('searchKey');
	$("#tabContainer").html("<div style='padding-left:60px;padding-top:55px;float:left;position:relative;'><img src='/stylusinc/Loader/ajax-loader.gif' border='0' alt='Loading'><br>Loading</div>");
	$.post("/stylusinc/RelatedSearchTags.php",{'s':paramS, 'searchKey':paramSK},function(data){
		var dataSplit = data.split('-->');
		var trimData = $.trim(dataSplit[2]);
		if(trimData == ''){
			trimData = data;
		}
		$("#tabContainer").html(trimData);
	  });
	});
}

jQuery(function( $ ){
$('.entrytopPadAdjust').jScrollPane({scrollbarWidth:10, scrollbarMargin:2,showArrows:true,dragMaxHeight:25,dragMinHeight:25});
 });

jQuery.fn.reset = function() {
	this.each(function(){
		if($(this).is('form')) {
			var button = jQuery(jQuery('<input type="reset" />'));
			button.hide();
			$(this).append(button);
			button.click().remove();
		} else if($(this).parent('form').size()) {
			var button = jQuery(jQuery('<input type="reset" />'));
			button.hide();
			$(this).parent('form').append(button);
			button.click().remove();
		} else if($(this).find('form').size()) {
			$(this).find('form').each(function(){
				var button = jQuery(jQuery('<input type="reset" />'));
				button.hide();
				$(this).append(button);
				button.click().remove();
			});
		}
	})
	return this;
};

jQuery(function( $ ){
	$('#RecommendUsButton').livequery('click',function(){
		GB_show('Recommend Us','/stylusinc/RecommendUs.php',277,850);
	});
	$('#docView li a').livequery('click',function(){
		var url = $(this).attr('id');
		GB_show('DocView',url,277,850);
	});

});

jQuery(function( $ ){
	$('#FullView').livequery('click',function(){
		var postIdMain = $(this).parent().attr('id');
		/*var postIdSplit = postIdMain.split('-');
		var postId = postIdSplit[1];*/
		var postId = postIdMain;
		GB_show('FullView','/stylusinc/FullView.php?postId='+postId,277,850);
	});
	$('#commentView').livequery('click',function(){
		var postIdMain = $('.post').attr('id');
		var postIdSplit = postIdMain.split('-');
		var postId = postIdSplit[1];
		GB_show('FullView','/stylusinc/wp-comments-popup.php?postId='+postId,277,850);
	});
	$('#emailview').livequery('click',function(){
		var postIdMain = $('.page').attr('id');
		if(!postIdMain){
			var postIdMain = $('.post').attr('id');
		}
		var postIdSplit = postIdMain.split('-');
		var postId = postIdSplit[1];
		GB_show('FullView','/stylusinc/Email.php?p='+postId+'&email=1',277,850);
	});
	$('#printPost').livequery('click',function(){
		var postIdMain = $('.post').attr('id');
		var postIdSplit = postIdMain.split('-');
		var postId = postIdSplit[1];
		GB_show('FullView','/stylusinc/Print.php?p='+postId+'&print=1',277,850);
	});
	$('#PageFullView').livequery('click',function(){
		var postIdMain = $(this).parent().parent().attr('id');
		var postIdSplit = postIdMain.split('-');
		var postId = postIdSplit[1];
		GB_show('FullView','/stylusinc/FullView.php?postId='+postId,277,850);
	});
});

jQuery(function( $ ){
	$('#homeNavContainer img').livequery('click',function(){
		var templateName = $('#templateName').attr('rel')+'/images/buttons/';
		var activeIdSplit = 0;
		$('#homeImage a img').each(function() {
			if($(this).attr('class') == 'active'){
				var activeIdMain = $(this).attr('id');
				activeIdSplit = activeIdMain.split('_');
			}
		});
		var imageIdMain = $(this).attr('id');
		var imageIdSplit = imageIdMain.split('_');
		var imageIndex = imageIdSplit[1];
		var totImage = $('#homeImage').attr('class');
		changeImage(imageIndex,totImage,activeIdSplit[1]);
		$('#homeNavContainer img').each(function() {
			var navImage = templateName + 'otherPage.gif';
			$(this).attr('src',navImage);
		});
		var activeImage = templateName + 'activePage.gif';
		$(this).attr('src',activeImage);
	});

	$('#pagePrevious').livequery('click',function(){
		var templateName = $('#templateName').attr('rel')+'/images/buttons/';
		var activeIdSplit = 0;
		$('#homeImage img').each(function() {
			if($(this).attr('class') == 'active'){
				var activeIdMain = $(this).attr('id');
				activeIdSplit = activeIdMain.split('_');
			}
		});
		var totalCount = $(this).parent().attr('id');
		var currentImage = parseInt(activeIdSplit[1]) - 1;
		if(currentImage < 0){
			var currentImage =  parseInt(totalCount) - 1;
		}
		changeImage(currentImage,totalCount,activeIdSplit[1]);
		$('#homeNavContainer img').each(function() {
			var navImage = templateName + 'otherPage.gif';
			$(this).attr('src',navImage);
		});
		var activeImage = templateName + 'activePage.gif';
		var navIndex = '#nav_'+currentImage;
		$(navIndex).attr('src',activeImage);
	});

	$('#pageNext').livequery('click',function(){
		var templateName = $('#templateName').attr('rel')+'/images/buttons/';
		var activeIdSplit = 0;
		$('#homeImage img').each(function() {
			if($(this).attr('class') == 'active'){
				var activeIdMain = $(this).attr('id');
				activeIdSplit = activeIdMain.split('_');
			}
		});
		var totalCountMain = $(this).parent().attr('id');
		var totalCount = totalCountMain.split('_');
		var currentImage = parseInt(activeIdSplit[1]) + 1;
		var maxcount = parseInt(totalCount[1]);
		if(parseInt(currentImage) == maxcount){
			currentImage =  0;
		}

		changeImage(currentImage,totalCount[1],activeIdSplit[1]);
		$('#homeNavContainer img').each(function() {
			var navImage = templateName + 'otherPage.gif';
			$(this).attr('src',navImage);
		});
		var activeImage = templateName + 'activePage.gif';
		var navIndex = '#nav_'+currentImage;
		$(navIndex).attr('src',activeImage);
	});

	$('#questionNavContainer img').livequery('click',function(){
		$('#questionSubmit').hide('slow');
		$('#sformMandatory').hide('slow');
		var templateName = $('#templateName').attr('rel')+'/images/buttons/';
		var activeIdSplit = 0;
		var Question1Checked = $('#Q2ANSW_4').attr('checked');
		var Question1 = $('#Q2ANSW_4').val();
		$('#QuizNavContainer div').each(function() {
			if($(this).attr('class') == 'active'){
				var activeIdMain = $(this).attr('id');
				activeIdSplit = activeIdMain.split('_');
			}
		});
		var questionIdMain = $(this).attr('id');
		var questionIdSplit = questionIdMain.split('_');
		var questionIndex = questionIdSplit[1];
		var totQuestion= $('#QuizNavContainer').attr('class');
		totQuestion = parseInt(totQuestion) + 1;
		if(Question1 == '4' && Question1Checked == true){
			if(questionIndex >= 3 && questionIndex <= 8){
				questionIndex = 2;
				activeIdSplit[1] = 9;
			}
		}
		if(Question1 == '4' && Question1Checked == true && questionIndex >=9 ){
			var qindex = 'Question '+(parseInt(questionIndex) - 7);
			$('#QuizNavContainer h2').text(qindex);
		}else{
			var qindex = 'Question '+ (parseInt(questionIndex) - 1);
			$('#QuizNavContainer h2').text(qindex);
		}
		if(qindex = 'Question 0' && questionIndex < 2){
			$('#QuizNavContainer h2').text("Looks like you're ready to invest in BI. But is your business ready?");
		}

		changeQuestion(questionIndex,totQuestion,activeIdSplit[1]);
		$('#questionNavContainer img').each(function() {
			var navImage = templateName + 'otherPage.gif';
			var navMainId = $(this).attr('id');
			var navSplitId = navMainId.split('_');
			if(Question1 == '4' && (navSplitId[1] < 9 && navSplitId[1] > 2) && Question1Checked == true){
				$(this).customFadeOut();
			}else{
				$(this).customFadeIn();
			}
			$(this).attr('src',navImage);
		});
		var activeImage = templateName + 'activePage.gif';

		if(Question1 == '4' && (questionIndex == '3') && Question1Checked == true){
			$('#questionNav_9').attr('src',activeImage);
		}else{
			$(this).attr('src',activeImage);
		}

		if(questionIndex == 12){
			$('#questionSubmit').show('slow');
			$('#sformMandatory').show('slow');
		}
	});

	$('#QuizPrevious').livequery('click',function(){
	$('#questionSubmit').hide('slow');
	$('#sformMandatory').hide('slow');
		var Question1Checked = $('#Q2ANSW_4').attr('checked');
		var Question1 = $('#Q2ANSW_4').val();
		var templateName = $('#templateName').attr('rel')+'/images/buttons/';
		var activeIdSplit = 0;
		$('#QuizNavContainer div').each(function() {
			if($(this).attr('class') == 'active'){
				var activeIdMain = $(this).attr('id');
				activeIdSplit = activeIdMain.split('_');
			}
		});
		var totalCount = $(this).parent().attr('id');
		var currentImage = parseInt(activeIdSplit[1]) - 1;
		if(currentImage == 0){
			var currentImage =  parseInt(totalCount);
		}
		if(currentImage == 12){
			$('#questionSubmit').show('slow');
			$('#sformMandatory').show('slow');
		}
		if(Question1 == '4' && (currentImage >3 && currentImage < 9)  && Question1Checked == true){
			currentImage = 2;
		}
		if(Question1 == '4' && Question1Checked == true && currentImage >=9 ){
			var qindex = 'Question '+(parseInt(currentImage) - 7);
			$('#QuizNavContainer h2').text(qindex);
		}else{
			var qindex = 'Question '+ (parseInt(currentImage) - 1);
			$('#QuizNavContainer h2').text(qindex);
		}
		if(qindex = 'Question 0' && currentImage < 2){
			$('#QuizNavContainer h2').text("Looks like you're ready to invest in BI. But is your business ready?");
		}

		totalCount = parseInt(totalCount) + 1;
		changeQuestion(currentImage,totalCount,activeIdSplit[1]);
		$('#questionNavContainer img').each(function() {
			var navImage = templateName + 'otherPage.gif';
			var navMainId = $(this).attr('id');
			var navSplitId = navMainId.split('_');
			if(Question1 == '4' && (navSplitId[1] < 9 && navSplitId[1] > 2) && Question1Checked == true){
				$(this).hide();
			}else{
				$(this).show();
			}
			$(this).attr('src',navImage);
		});
		var activeImage = templateName + 'activePage.gif';
		var navIndex = '#questionNav_'+currentImage;
		$(navIndex).attr('src',activeImage);
	});

	$('#QuizNext').livequery('click',function(){
		$('#questionSubmit').hide('slow');
		$('#sformMandatory').hide('slow');
		var Question1Checked = $('#Q2ANSW_4').attr('checked');
		var Question1 = $('#Q2ANSW_4').val();
		var templateName = $('#templateName').attr('rel')+'/images/buttons/';
		var activeIdSplit = 0;
		$('#QuizNavContainer div').each(function() {
			if($(this).attr('class') == 'active'){
				var activeIdMain = $(this).attr('id');
				activeIdSplit = activeIdMain.split('_');
			}
		});
		var totalCountMain = $(this).parent().attr('id');
		var totalCount = totalCountMain.split('_');
		var currentImage = parseInt(activeIdSplit[1]) + 1;
		if(currentImage == 12){
			$('#questionSubmit').show('slow');
			$('#sformMandatory').show('slow');
		}	
		if(Question1 == '4' && (currentImage < 9 && currentImage > 2) && Question1Checked == true){
			currentImage = 9;
		}
		if(currentImage > 12){
			var currentImage =  1;
		}
		if(Question1 == '4' && Question1Checked == true && currentImage >=9 ){
			var qindex = 'Question '+(parseInt(currentImage) - 7);
			$('#QuizNavContainer h2').text(qindex);
		}else{
			var qindex = 'Question '+ (parseInt(currentImage) - 1);
			$('#QuizNavContainer h2').text(qindex);
		}
		if(qindex = 'Question 0' && currentImage < 2){
			$('#QuizNavContainer h2').text("Looks like you're ready to invest in BI. But is your business ready?");
		}
		changeQuestion(currentImage,totalCount[1],activeIdSplit[1]);
		$('#questionNavContainer img').each(function() {
			var navImage = templateName + 'otherPage.gif';
			var navMainId = $(this).attr('id');
			var navSplitId = navMainId.split('_');
			if(Question1 == '4' && (navSplitId[1] < 9 && navSplitId[1] > 2) && Question1Checked == true){
				$(this).hide();
			}else{
				$(this).show();
			}
			$(this).attr('src',navImage);
		});
		var activeImage = templateName + 'activePage.gif';
		var navIndex = '#questionNav_'+currentImage;
		$(navIndex).attr('src',activeImage);
	});
});

function changeQuestion(questionIndex,totQuestion,fromId){
	$("#Question_" + fromId).hide('fast', function() {
		$(this).removeClass('active');
		$(this).addClass('inactive');
		$("#Question_" + questionIndex).removeClass('inactive');
		$("#Question_" + questionIndex).addClass('active');
		$("#Question_" + questionIndex).show('fast');
	});
	var MercuryDivison = 500 / totQuestion;
	var MercuryWidth = parseInt(questionIndex * MercuryDivison);
	var MercuryPercentage = parseInt(( Math.round(parseInt(MercuryWidth)) / 500)*100);
	//$("#mercury").animate({width: MercuryWidth,opacity:'hide'}, 1000 );
	$("#mercury span").text(MercuryPercentage+'%');

}
function changeImage(currentImage,numImages,fromId)
{
	$("#slide_" + fromId).customFadeOut('slow', function() {
		$("#slide_" + fromId).removeClass('active');
		$("#slide_" + fromId).addClass('inactive');
		$("#slide_" + currentImage).removeClass('inactive');
		$("#slide_" + currentImage).addClass('active');
		$("#slide_" + currentImage).fadeIn('slow');
	});
}

jQuery(function( $ ){
	$("#gborderContainer").click(function() {
		var options = {};
		$("#tabContainer").toggle('slide',options,200);
		if($('#content').attr('class') == 'marginAdjust'){
			$('#content').animate({width: 820}, '7000', function() {});
			$('.page').animate({width: 820}, '7000', function() {});
			$('.entrytopPadAdjust').animate({width: 820}, '7000', function() {});
			$('.jScrollPaneContainer').animate({width: 820}, '7000', function() {});
			$('#content').removeClass('marginAdjust');
			$('#content').removeClass('recommendAdjust');
			$(this).removeClass('gborderContainerHide');
			$(this).addClass('gborderContainerShow');
			$('#content').css({'left': '1px', 'height': '210px'});
			$('#item22').html('<h3>Help</h3><p>Show Quick Links</p>');
		}else if($('#content').attr('class') == 'recommendAdjust'){
			$('#content').animate({width: 820}, '7000', function() {});
			$('.page').animate({width: 820}, '7000', function() {});
			$('.entrytopPadAdjust').animate({width: 820}, '7000', function() {});
			$('.jScrollPaneContainer').animate({width: 820}, '7000', function() {});
			$('#content').removeClass('recommendAdjust');
			$(this).removeClass('gborderContainerHide');
			$(this).addClass('gborderContainerShow');
			$('#content').addClass('checkRecommend');
			$('#content').css({'left': '1px', 'height': '210px'});
			$('#item22').html('<h3>Help</h3><p>Show Quick Links</p>');

		}else if($('#content').attr('class') == 'noContactAdjust'){
			$('#content').animate({width: 820}, '7000', function() {});
			$('.page').animate({width: 820}, '7000', function() {});
			$('.entrytopPadAdjust').animate({width: 820}, '7000', function() {});
			$('.jScrollPaneContainer').animate({width: 820}, '7000', function() {});
			$('#content').removeClass('noContactAdjust');
			$(this).removeClass('gborderContainerHide');
			$(this).addClass('gborderContainerShow');
			$('#content').addClass('checkContact');
			$('#content').css({'left': '1px', 'height': '210px'});
			$('#item22').html('<h3>Help</h3><p>Show Quick Links</p>');

		}else{
			$('#content').attr('style','');
			$('#content').animate({width: 660}, '7000', function() {});
			$('.page').animate({width: 660}, '7000', function() {});
			$('.entrytopPadAdjust').animate({width: 660}, '7000', function() {});
			$('.jScrollPaneContainer').animate({width: 660}, '7000', function() {});
			 if ($.browser.msie){$('#content').css({'left': '-5px'}); }else {$('#content').css({'left': '5px'});}
			 if($('#content').attr('class') == 'checkRecommend'){
				$('#content').addClass('recommendAdjust');
				$('#content').removeClass('checkRecommend');
				$('#content').css({'left': '1px', 'height': '210px'});
			 }else if($('#content').attr('class') == 'checkContact'){
				$('#content').addClass('noContactAdjust');
				$('#content').removeClass('checkContact');
				$('#content').css({'left': '1px', 'height': '210px'});
			 }else{
				$('#content').addClass('marginAdjust');
			 }
			$(this).removeClass('gborderContainerShow');
			$(this).addClass('gborderContainerHide');
			$('#item22').html('<h3>Help</h3><p>Hide Quick Links</p>');
	}
		return false;
	});
});

jQuery(function( $ ){
	var originalFontSize = $('.entry').css('font-size');
	$('area').click(function() { 
	var dynamicFontSize = $('.entry').css('font-size');
	var url = $(this).attr('href'); 
	var coords = $(this).attr('id');
	if(coords == 'sFont'){
		if(parseInt(dynamicFontSize) > 9){
			var currentFontSizeNum = parseFloat(dynamicFontSize, 10);
			var newFontSize = currentFontSizeNum*0.8;
		}
		$('.entry').css('font-size', newFontSize);
	}else 
	if(coords == 'dFont'){
		$('.entry').css('font-size', originalFontSize);
	}else 
	if(coords == 'bFont'){
		var styleFont = $('.entry').attr('style');
		if(styleFont){
			var styleSplit = styleFont.split(':');
			var currentFontSize = styleSplit[1].replace(';','');
			if(parseInt(currentFontSize) < 20){
				dynamicFontSize = currentFontSize;
			}
		}
		if(parseInt(dynamicFontSize) < 20){
			var currentFontSizeNum = parseFloat(dynamicFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
		}
		$('.entry').css('font-size', newFontSize);
	} 
	return false; 
	});
});

jQuery(function( $ ){
	$("#tellMeMore img").click(function() {
		if($(this).parent().attr('class') == 'iniWidth'){
			$(this).parent().animate({width: 600}, '7000', function() {});
			$(this).parent().removeClass('iniWidth');
			$(this).parent().addClass('finalWidth');
			$('#tmmForm').show();
		}else{
			$(this).parent().animate({width: 35}, '7000', function() {});
			$(this).parent().removeClass('finalWidth');
			$(this).parent().addClass('iniWidth');
			$('#tmmForm').hide();
		}
		return false;
	});
});

jQuery(function( $ ){
	$('#surveySubmit').click(function() {
	var tcontact_name			= $('#tcontact_name').val();
	var tcontact_email			= $('#tcontact_email').val();
	var tcontact_designation	= $('#tcontact_designation').val();
	var tcontact_industry		= $('#tcontact_industry').val();
	var tcontact_function		= $('#tcontact_function').val();
	var tcontact_compsize		= $('#tcontact_compsize').val();
	var tcontact_location		= $('#tcontact_location').val();
	var tcontact_phone			= $('#tcontact_phone').val();
	var status = '0';
	$.post("/stylusinc/SurveyForm.php",
		{ 'tcontact_name': tcontact_name,'tcontact_email': tcontact_email,'tcontact_designation': tcontact_designation,'tcontact_industry':tcontact_industry,'tcontact_function':tcontact_function,'tcontact_compsize':tcontact_compsize,'tcontact_location':tcontact_location,'tcontact_phone':tcontact_phone},
			function(data){
			var splitData = data.split('|');
				if(splitData[0] == 'ERROR'){
					alert('Please check the form details again.');
					status = '1';
				}
				if(status == '1'){
					return false;
				}else{
					$('#surveyForm').submit();
				}
			}
		);
	});
	$('#faceBookButton').focus(function(){
		$('#faceBook').show('slow');
	});

	 $('#faceBookButton').blur(function(){
		$('#faceBook').hide('slow');
	});
});

function FaceBookHide(){
	$('#faceBook').hide('slow');
}

jQuery(function( $ ){
	var maxLenLabel = '';
	var maxLenLabelTemp = 0;
	$('#RecommendFormMain label').each(function(){
		maxLenLabel = $(this).width();
		if(maxLenLabel > maxLenLabelTemp){
			maxLenLabelTemp = maxLenLabel;
		}
	});
	if($.browser.msie){
		maxLenLabelTemp = maxLenLabelTemp - 50;
	}else{
		maxLenLabelTemp = maxLenLabelTemp + 20;
	}
	$('#RecommendFormMain label').width(maxLenLabelTemp);

	$('#RecommendUs').click(function(){
		var postField = '';
		var postValue = '';
		$('#RecommendFormMain :input').each(function() {
		var type = this.type;
		var tag = this.tagName.toLowerCase(); 
			var elementId = this.id;
			var indexSplit = elementId.split('_');
			var spanIndex = '#'+indexSplit[1]+'_span';
			var spanValue = $(spanIndex).text();
			var elementIndex = '#'+this.id;
				postValue = $(elementIndex).val();
				if(type != 'button' && type != 'image'){
					postField += elementId+"="+postValue+"&";
				}
		});
		var postLen = (postField.length) - 1;
		postField = postField.substr(0,postLen);
		postField += '&RecommendUs=1'; 
		$.post("/stylusinc/ContactUsPost.php",postField,
			function(data){ 
			//alert(data);
			var splitData = data.split('|');
			var fieldCount = 0;
			var errorCount = 0;
			var successCount = 0;
			$('#RecommendFormMain :input').each(function() {
				var type = this.type;
				var elementId = this.id;
			if(type != 'button' && type != 'image'){
					var splitValue = splitData[fieldCount].split(':');
					var fieldId		= $.trim(splitValue[0]);
					var fieldStatus = $.trim(splitValue[1]);
					var fieldMsg	= $.trim(splitValue[2]);
					if(elementId == fieldId){
						if(fieldStatus == 'Error'){
							var spanIndex = '#'+elementId+'_help';
							$(spanIndex).attr('class','error');
							$(spanIndex).text(fieldMsg);
							errorCount++;
						}else if(fieldStatus == 'Success'){
							var spanIndex = '#'+elementId+'_help';
							$(spanIndex).attr('class','success');
							$(spanIndex).text('Valid');
							successCount++;
						}
					}
					fieldCount++;
				}
			});
				if(parseInt(successCount) >= 2){
					$('.recommendThankYou').show();
					$('.recommendThankYou').text('Mail has been sent to your friend');
					self.parent.JosephHide();
					parent.location.href = 'http://www.stylusinc.net/recommend-thank-you/';
				}
			}
		);
	});
});

jQuery(function( $ ){

	$('.faqTitle').toggle(function() {
		var indexId = $(this).attr('id');
		var childId = '#'+indexId+'_questions';
		$(childId).hide();
	}, function() {
		var indexId = $(this).attr('id');
		var childId = '#'+indexId+'_questions';
		$(childId).show();
	});

	$('.faqQuestion').toggle(function() {
		var indexId = $(this).attr('id');
		var childId = '#'+indexId+'_a';
		$(childId).show();
	}, function() {
		var indexId = $(this).attr('id');
		var childId = '#'+indexId+'_a';
		$(childId).hide();
	});
});

function ContactUsFrom(){
	if(local == true){
		GB_show('ContactForm','stylusinc/ContactForm.php',277,450);
	}else{
		GB_show('ContactForm','/stylusinc/ContactForm.php',277,450);
	}

}