// JavaScript Document
jQuery(document).ready(function(){
// Clearfix
	jQuery('<style type="text/css">.clearfix:after {visibility: hidden;display: block;font-size: 0;content: " ";clear: both;height: 0;}* html .clearfix { zoom: 1; }*:first-child+html .clearfix { zoom: 1; }</style>').appendTo("head");
// Top Nav
	jQuery("ul#topNav li.mainLi:last-child").css('border-right','0');
	jQuery("ul#topNav li.aboutUsNav ul.subNavList li:odd").css('marginRight','0')
	jQuery("ul#topNav li.mainLi ul.subNavList li:last-child").css('borderBottom','0');
	if(jQuery("ul#topNav li.aboutUsNav ul").hasClass("subNavList")){
		var liIndex = jQuery("ul#topNav li.aboutUsNav ul.subNavList li:last-child").index();
		if (liIndex%2 == 0){
		}else{
			jQuery("ul#topNav li.aboutUsNav ul.subNavList li:last-child").prev("li").css('borderBottom','0');
		}
	}
// Footer Links
	jQuery("div.fLinkWrapper div.fLinkBlk:last-child").css('paddingRight','0');
// Breadcrumb
	jQuery("ul#breadCrumb li:last-child").addClass("activeBreadcrumb");
// Right Nav
	jQuery("ul.rightNav li:last-child").addClass("lastLi");
	jQuery("h3.rNAcc").click(function(){
		jQuery(this).next("ul.rightNav").slideToggle();
		jQuery(this).toggleClass("showRightNav");
	});
//AdvisoryBlk First Child Remove Bg
	jQuery("div.advisoryBlk:first-child").css('background','none');
// Sub Menu
	jQuery("ul#topNav li.mainLi a.mainLink").hover(function() {
		var pareNt =  jQuery(this).parent()
		pareNt.find("div.subNav").stop(true,true).slideDown('fast'); 
		pareNt.find("a.mainLink").addClass("hovered"); 		  
			var LiPos = jQuery(pareNt).position();
			var LiHeight = jQuery(pareNt).outerHeight();
			var LiLeftPos = LiPos.left;
			var LiTopPos = LiPos.top;
			var subNavTop = LiHeight + LiTopPos - 1;
			pareNt.find("div.subNav").css("left",LiLeftPos+'px');
			pareNt.find("div.subNav").css("top",subNavTop+'px');			
	
		pareNt.hover(function() {
		}, function(){	
			pareNt.find("div.subNav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
			pareNt.find("a.mainLink").removeClass("hovered"); 
		});
	});
// Products Nav SubNav
	jQuery("div.productsNavDet div.pNDchild:first-child").show();
	jQuery("ul.productsNavList li:first-child a").addClass("currentProduct");
	jQuery("ul.productsNavList li a").hover(function(){
		if(!jQuery(this).hasClass("currentProduct")){
			jQuery("ul.productsNavList li a").removeClass("currentProduct");
			jQuery(this).addClass("currentProduct");
			var cpEq = jQuery("ul.productsNavList li").index(jQuery(this).parent());
			jQuery("div.pNDchild").stop(true,true).slideUp();
			jQuery("div.productsNavDet div.pNDchild").eq(cpEq).stop(true,true).slideDown();
		}
		return false;
	})
// Index Left Tab
	//jQuery(".leftTabContent").css('visibility','hidden');
    jQuery("ul#leftTab li:first a").addClass("currentLeftTab").show();
	jQuery(".leftTabContent:first").animate({
		top : '0'
	});
    //jQuery(".leftTabContent:first").css('visibility','visible');
	jQuery("ul#leftTab li a").click(function() {
        if (!jQuery(this).hasClass("currentLeftTab")) {
            jQuery("ul#leftTab li a").removeClass("currentLeftTab");
            jQuery(this).addClass("currentLeftTab");
            //jQuery(".leftTabContent").css('visibility','hidden');
			jQuery(".leftTabContent").animate({
				top : '-160px'
			},0);
            var activeTab = jQuery(this).attr("href");
            //jQuery(activeTab).css('visibility','visible')
			jQuery(activeTab).animate({
				top : '0'
			});
        }
		return false;
    });
// Index Right Tab
	jQuery(".rightTabContent").hide();
    jQuery("ul#rightTab li:first a").addClass("currentRightTab").show();
    jQuery(".rightTabContent:first").show();
	jQuery("ul#rightTab li a").click(function() {
        if (!jQuery(this).hasClass("currentRightTab")) {
            jQuery("ul#rightTab li a").removeClass("currentRightTab");
            jQuery(this).addClass("currentRightTab");
            jQuery(".rightTabContent").slideUp();
            var activeTab = jQuery(this).attr("href");
            jQuery(activeTab).slideDown();
        }
		return false;
    });
// tr hover
	jQuery("table.table tr").hover(function() {
		jQuery(this).addClass("trHover");
	}, function(){	
		jQuery(this).removeClass("trHover");
	});
	
	jQuery("table.table2 tr").hover(function() {
		jQuery(this).addClass("trHover");
	}, function(){	
		jQuery(this).removeClass("trHover");
	});
	
	jQuery("table.table3 tr").hover(function() {
		jQuery(this).addClass("trHover");
	}, function(){	
		jQuery(this).removeClass("trHover");
	});
	
// Specification Table
	jQuery(".specification table tr td:first-child").css('textAlign','left');
	jQuery(".specification table tr th:last-child, .specification table tr td:last-child, .tablefomat table tr th:last-child, .tablefomat table tr td:last-child").css('borderRight','none');	
	
// Product Link Last Li
	jQuery("ul#productLinks li.:last-child").addClass("LastLi");
// Adisory Board Accordian
	jQuery('div.advisoryBlk:first a.readmore, div.advisoryBlk:first img.expandAB').hide();
	jQuery('div.advisoryBlk:first div.advisoryBot,div.advisoryBlk:first img.collapseAB').show();
	jQuery('div.advisoryBlk a.readmore, div.advisoryBlk img.expandAB').click(function() {
		jQuery("div.advisoryBot").slideUp();
		jQuery(this).parents("div.advisoryBlk").find("div.advisoryBot").slideDown(/*function(){
			var scrollID = jQuery(this).parents("div.advisoryBlk");
			var scollPos = jQuery(scrollID).position();
			var scrollTopPos = scollPos.top+10;
			jQuery('html, body').animate({scrollTop:scrollTopPos}, 'slow');
		}*/);
		jQuery('div.advisoryBlk a.readmore, div.advisoryBlk img.expandAB').show();
		jQuery(this).parents("div.advisoryBlk").find("a.readmore,img.expandAB").hide();
		jQuery("img.collapseAB").hide();
		jQuery(this).parents("div.advisoryBlk").find("img.collapseAB").show();
		return false;
	});
	jQuery("img.collapseAB").click(function(){
		jQuery('div.advisoryBlk a.readmore,img.expandAB').show();
		jQuery("div.advisoryBot").slideUp();
		jQuery(this).hide();
	});
	jQuery("a.top").click(function() {
		jQuery("html,body").animate({scrollTop:0}, 'slow');
		return false;
	});
// Curent Opening Accordian
	jQuery('div.openingsBlk:first a.viewmore, div.openingsBlk:first img.expandAB').hide();
	jQuery('div.openingsBlk:first div.openingsBot,div.openingsBlk:first img.collapseAB').show();
	jQuery('div.openingsBlk a.viewmore, div.openingsBlk img.expandAB').click(function() {
		jQuery("div.openingsBot").slideUp();
		jQuery(this).parents("div.openingsBlk").find("div.openingsBot").slideDown(/*function(){
			var scrollID = jQuery(this).parents("div.openingsBlk");
			var scollPos = jQuery(scrollID).position();
			var scrollTopPos = scollPos.top+10;
			jQuery('html, body').animate({scrollTop:scrollTopPos}, 'slow');
		}*/);
		jQuery('div.openingsBlk a.viewmore, div.openingsBlk img.expandAB').show();
		jQuery(this).parents("div.openingsBlk").find("a.viewmore,img.expandAB").hide();
		jQuery("img.collapseAB").hide();
		jQuery(this).parents("div.openingsBlk").find("img.collapseAB").show();
		return false;
	});
	jQuery("img.collapseAB").click(function(){
		jQuery('div.openingsBlk a.viewmore,img.expandAB').show();
		jQuery("div.openingsBot").slideUp();
		jQuery(this).hide();
	});
	jQuery("a.top").click(function() {
		jQuery("html,body").animate({scrollTop:0}, 'slow');
		return false;
	});
// Font SIze Toggle
	jQuery("a.increaseFont").click(function(){
		jQuery("div#pageLeft").css('fontSize','13px');
		return false;
	});
	jQuery("a.decreaseFont").click(function(){
		jQuery("div#pageLeft").css('fontSize','12px');
		return false;
	});
	jQuery("a.lightboxClose,#lightbox").click(function(){
		jQuery("#lightboxcontent,#lightbox").fadeOut(500);
	});
	jQuery("a.lightboxloginClose,#lightboxlogin").click(function(){
		jQuery("#lightboxcontentlogin,#lightboxlogin").fadeOut(500);
	});
	
	  // My Account Tab
	jQuery(".myAccTabContent").hide();
    jQuery(".defaultMyAccTab").show();
	jQuery("ul#myAccTab li a").click(function() {
        if (!jQuery(this).hasClass("currentmyAccTab")) {
            jQuery("ul#myAccTab li a").removeClass("currentmyAccTab");
            jQuery(this).addClass("currentmyAccTab");
            jQuery(".myAccTabContent").slideUp();
            var activeTab = jQuery(this).attr("href");
            jQuery(activeTab).slideDown();
        }
		return false;
    });
	jQuery("ul.trailProduct li:odd").css('float','right');
	jQuery("ul.trailProduct li").hover(function(){
		jQuery(this).addClass("trailProductHovered");
	},function(){
		jQuery(this).removeClass("trailProductHovered");
	});
	jQuery("div.myAccLDrow:last").css({borderBottom:'none',marginBottom:'0',paddingBottom:'5px'});


	
	
});





// Lightbox
function showLightBox(){
	var arrPageSizes = getPageSize();
	jQuery("#lightbox").css({
		width : arrPageSizes[0],
		height : arrPageSizes[1],
		opacity : 0.7
	});
	var LbW = jQuery("#lightboxcontent").width();
	var LbH = jQuery("#lightboxcontent").height();
	var LbMl = LbW/2;
	var LbMr = LbH/2;
	jQuery("#lightboxcontent").css({
		marginLeft : '-'+LbMl+'px',
		marginTop : '-'+LbMr+'px'
	});
	jQuery("#lightbox,#lightboxcontent").fadeIn(500);
	return false;
}

function showLightBoxlogin(){
	var arrPageSizes = getPageSize();
	jQuery("#lightboxlogin").css({
		width : arrPageSizes[0],
		height : arrPageSizes[1],
		opacity : 0.7
	});
	var LbW = jQuery("#lightboxcontentlogin").width();
	var LbH = jQuery("#lightboxcontentlogin").height();
	var LbMl = LbW/2;
	var LbMr = LbH/2;
	jQuery("#lightboxcontentlogin").css({
		marginLeft : '-'+LbMl+'px',
		marginTop : '-'+LbMr+'px'
	});
	jQuery("#lightboxlogin,#lightboxcontentlogin").fadeIn(500);
	return false;
}

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;
		};	

function emailValidate(email) 
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,3})$/;
   return reg.test(trim(email));
}


function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}

function isValidresume(filename)
{	
	imagefile_value = filename.value;
	var checkimg = imagefile_value.toLowerCase();
	if (!checkimg.match(/(\.doc|\.docx|\.txt|\.pdf|\.rtf)$/))
	{
		alert("Please select valid file");
		filename.focus(); 
		filename.value="";
		return false;
	}
	else
	{
		return true;
	}
}


function show_ngs()
{
	document.getElementById("ngs").style.display = "block";
	document.getElementById("igr").style.display = "none";	
	if(!document.getElementById("optnngs").checked)
	{
		document.getElementById("optnngs").checked='true';
	}
}
function show_igr()
{
	document.getElementById("ngs").style.display = "none";
	document.getElementById("igr").style.display = "block";	
	if(!document.getElementById("optnigr").checked)
	{
		document.getElementById("optnigr").checked='true';
	}
}


function validate_trial_form()
{
	var fname=document.getElementById('firstname');
	var lastname=document.getElementById('lastname');
        var designation=document.getElementById('designation');
	var organization=document.getElementById('organization');
	var email=document.getElementById('email_address');
        var source=document.getElementById('source');
        var country=document.getElementById('country');
	var city=document.getElementById('city');
        var zipcode=document.getElementById('zipcode');
	var terms = document.getElementById('terms');
        
        if(source.value=='others')
	{
		if(document.getElementById('txtsource').value=='')
		{
			return false;
		}
	}
        
        if(country.value=='US')
	{
		var state=document.getElementById('state');
                if(state.value=='')
                {
                    return false;
                }
	}
        else if(country.value!='US')
	{
		var state=document.getElementById('txtstate');
                if(state.value=='')
                {
                    return false;
                }
	}
        var products_ngs=document.getElementById('hiddenngs').value;
        var products_igr=document.getElementById('hiddenigr').value;
        var services=document.getElementById('hiddenservices').value;
        var bioservices=document.getElementById('hiddenbioservices').value;
        
        if(products_ngs==1 || products_igr==1)
        {
            var research_area=document.getElementById('research_area').value;
            if(research_area=='')
            {
                return false;                
            }
        }
        
        if(bioservices==1)
        {
            var detail_description=document.getElementById('detail_description').value;
            if(detail_description=='')
            {
                return false;                
            }
        }
        
        if(services==1)
          {
              var sequence_platform=document.getElementById('sequence_platform');
		var workflow=document.getElementById('workflow');
		var multiplexed=document.getElementById('multiplexed');
		//var date_format=document.getElementById('date_format');
		var read_type=document.getElementById('read_type');
		var read_length=document.getElementById('read_length');
		
		var number_of_samples=document.getElementById('number_of_samples');
		var reference_species=document.getElementById('reference_species');
		var reference_build=document.getElementById('reference_build');

		if(sequence_platform.value=="")
		{
			return false;
		}
		else if(workflow.value=="")
		{
			return false;	
		}
		else if(multiplexed.value=="")
		{
			return false;	
		}
		/*else if(date_format.value=="")
		{
			return false;	
		}*/
		else if(read_type.value=="")
		{
			return false;	
		}
		else if(read_length.value=="")
		{
			return false;	
		}
		else if(number_of_samples.value=="")
		{
			return false;	
		}
		else if(reference_species.value=="")
		{
			return false;	
		}
		else if(reference_build.value=="")
		{
			return false;	
		}
		
          }               
           
	if(fname.value=='')
	{
		return false;
	}
	else if(lastname.value=='')
	{
		return false;
	}
        else if(designation.value=='')
	{
		return false;
	}
	else if(organization.value=='')
	{
		return false;
	}
	else if(email.value=="")
	{
		return false;
	}
	else if(!emailValidate(email.value))
	{
		return false;
	}
	
	else if(city.value=='')
	{
		return false;
	}
	else if(country.value=='')
	{
		return false;
	}
	else if(zipcode.value=='')
	{
		return false;
	}
        else if(terms.checked == false)
	{
		return false;
	}
	
	/*else if(source.value=='')
	{
		return false;
	}*/
	       

	else
	{
                return true;
	}
}

function others_show(value)
{
	var option=value;
	if(option=='others')
	{
		document.getElementById("others").style.display = "";	
	}
	else
	{
		document.getElementById("others").style.display = "none";
	}

}

function loader()
{
	//document.forms["formvalidate"].submit();
	//jQuery('#buttons').html('<img src="images/loader.gif" alt="loading" title="loading" />');	
}

function chkoption(selval)
{
	if(selval == "Other")
	{
		document.getElementById("otherid").style.display = "block";	
	}
	else
	{
		document.getElementById("otherid").style.display = "none";
	}

}

function product_box()
{
    jQuery('#products_opions').show();    
    document.getElementById('hiddenigr').value=1;
}

function service_box()
{
    jQuery('#services_opions').show();
    document.getElementById('hiddenservices').value=1;
}


