﻿$(function() {
    $('#noJavaScript').css('display','none');
    $('#inputContent').css('display','block');
})

$(document).ready(function() {
    var $search = $('.inputForm');
    var $searchInput = $search.find('input:eq(0)');
    var $searchLabel = $search.find('.domainExample').addClass('overlabel');

    if ($searchInput.val()) {
        $searchLabel.hide();
    }

    $searchInput
    .focus(function() {
        $searchLabel.hide();
    })
    .blur(function() {
        if (this.value == '') {
            $searchLabel.show();
        }
    });

    $searchLabel.click(function() {
        $searchInput.trigger('focus');
    });
});


$(document).ready(function(event) {
    $('img.ajax').hide();
    
    // set even and odd rows colors report jQuery.
    $('tbody tr:not(:has(th)):odd').addClass('odd');
    $('tbody tr:not(:has(th)):even').addClass('even');
    // set left text align of right column
    $('tbody tr td:nth-child(2)').css('text-align','right');

    // set hover over report panel buttons

    $('.button').hover(function(){
        $(this).addClass('hoverButton');
    }, function(){
        $(this).removeClass('hoverButton');
    });
    // secion collapsing
    var collapseIcon = 'images/minus.png';
    var collapseText = 'Collapse this section';
    var expandIcon = 'images/plus.png';
    var expandText = 'Expand this section';
    $('table.collapsible tbody').each(function() {
        var $section = $(this);
        $('<img class="png_bg"/>').attr('src', collapseIcon)
        .attr('alt', collapseText)
        .prependTo($section.find('th'))
        .addClass('clickable')
        .click(function() {
            if ($section.is('.collapsed')) {
                $section.removeClass('collapsed')
                .find('tr:not(:has(th))')
                .fadeIn('fast', function() {
                    $(this).show();
                //  hideNullH();
                });
                $(this).attr('src', collapseIcon)
                .attr('alt', collapseText);
            } else {
                $section.addClass('collapsed')
                .find('tr:not(:has(th))')
                .fadeOut('fast', function() {
                    $(this).hide();
                });
                $(this).attr('src', expandIcon)
                .attr('alt', expandText);
            }
            
        });
    });

    // generate report
    $('#reportInput form').submit(function(event) {
        event.preventDefault();
        
        var domainName = $('#reportInput input').val();
        
        // validate input
        if(!valideDomainAddress(domainName)){
            $('span.error').css('visibility', 'visible');
            return false;
        }
        $('#inputContent').hide();
        $('#reportContent').css('display', 'block');

        // set counter
        $.get('seoscripts/countReports.php',{},function (data){
            $('#counter span').text(data + " ");
        });
    
        // set report timestamp
        $('<span></span>').text(getCurrentDate()).css({
            'color': '#99cc00',
            'font-weight':'bold'
        }).appendTo('#timeStamp');
    
        // set input domain to header
        $('<a></a>').text('www.' + domainName).css({}).attr('href','http://www.'+domainName).appendTo('#reportTable thead:eq(0) td:nth-child(1)');
    
        domainName = 'http://www.'+domainName;
    
        $.get('seoscripts/metadata.php',{
            domain : domainName
        }, function(data){ 
			eval("var jsonObj = " + data);
			$img = $('<img />').attr('src', 'images/error.gif').attr('alt', 'NO');
			
			if(!jsonObj.pageTitle)
				$('td#pageTitle').empty().append($img);
			else 
            	$('td#pageTitle').empty().text(jsonObj.pageTitle);
				
			if(!jsonObj.description)
				$('td#description').empty().append($img);
			else
            	$('td#description').empty().text(jsonObj.description);
				
			if(!jsonObj.keywords)
				$('td#keywords').empty().append($img);
			else
            	$('td#keywords').empty().text(jsonObj.keywords);
				
			if(!jsonObj.imgCount)	
            	$('td#imgCount').empty().append($img);
			else 
				$('td#imgCount').empty().text(jsonObj.imgCount);
          countPageSEOGrade();
        });

        // w3c validation
        $.get('seoscripts/w3cValidate.php',{
            domain : domainName
        }, function(data){
            var novalidIcon = 'images/error.gif';
            var validIcon = 'images/passed.gif';
            var $w3cResult;
            if(data=='true') {
                $w3cResult = $('<img />').attr('src', validIcon)
                .attr('alt', 'YES');
            } else {
				$w3cResult = $('<span class="w3cError"> ' + data + ' coding errors found</span>').prepend($('<img />').attr('src', novalidIcon).attr('alt', 'NO'));
            }
            $('#w3cValidation').empty().append($w3cResult);
			countPageSEOGrade();
        });
    
        // send ajax requests for seo to server
        $('#seoMetrics tr td:nth-child(2)').each(function(index){
            var $id = $(this).attr('id');
    
            $.get('seoscripts/' + $id + 'Metric.php',
            {
                domain : domainName
            }, function(data){
            	if(data == '')
                	$('#' + $id).text("0");
                else
                 	$('#' + $id).text(data);
                countPageSEOGrade();
            });
        })

    
        // favIcon row
        $.get('seoscripts/favIcon.php', {
            domain : domainName
        }, function(data){
            var noIcon = 'images/error.gif';
            var foundIcon = 'images/passed.gif';
            var $img;
            if(data=='true') {
                $img = $('<img />').attr('src', foundIcon)
                .attr('alt', 'YES');
            } else {
                $img = $('<img />').attr('src', noIcon)
                .attr('alt', 'NO');
            }
            $('#favIcon').empty().append($img);
            countPageSEOGrade();
        });
    
        // get loading time
        $.get('seoscripts/loadTime.php', {
            domain : domainName
        }, function(data) {
            $('#loadTime').html(data);
        })
    
        // sites hosted on an IP row
        $.get('seoscripts/reverseIP.php', {
            domain : domainName
        }, function(data){
        	eval("var jsonObj = " + data);
            var noIcon = 'images/error.gif';
            var foundIcon = 'images/passed.gif';
            var $img;
           	$('td#sitesHostedOnAnIPNum').empty().text(jsonObj.numberOfDomains);
            $('td#sitesHostedOnAnIP').empty().text(jsonObj.domains.join("    "));
            
	       /* $('#downloadify').downloadify({
	  			filename: function(){
	    			return 'webs on my IP.txt';
	  			},
	  			data: function(){ 
	    			return $('div#sitesHostedOnAnIP').text();
	  			},
				transparent: false,
				swf: 'media/downloadify.swf',
				downloadImage: 'images/hostOnMyIP.gif',
				width: 120,
				height: 30,
				transparent: true,
				append: false
			}); */
        });

        // domain dates Info
        $.get('seoscripts/domainInfo.php',{
            domain : domainName
        }, function(data){
            eval('var jsonObj = ' + data);
            $('td#domainRegistrationDate').empty().text(jsonObj.domainRegistrationDate);
            $('td#domainExpirationDate').empty().text(jsonObj.domainExpirationDate);
            $('td#domainLastUpdatedDate').empty().text(jsonObj.domainLastUpdatedDate);
            countPageSEOGrade();
        });
        
        

    });
});

// compare results
$(function(){
    $('#compareTabel tr td:nth-child(1)').css('font-weight','bold');
    // Dialog
    $('#competitorsDialog').dialog({
        autoOpen: false,
        width: 600,
        modal: true,
        position: ['center',25]
    });

    $('#sendReportDialog').dialog({
        autoOpen: false,
        width: 600,
        modal: true,
        position: 'center'
    });

    // Dialog Link
    $('#competitors').click(function(){
    	if($('img[alt=ajax]:visible').length == 0) {
	        $('#compareTabel').hide();
	        $('#competitor').val('');
	        $('#seoCompetitorReport').css('display','none');
	        $('#competitorsDialog span.error').css('visibility', 'hidden');
	        $('#competitorsDialog').dialog('open');
    	}
        return false;
    });

    $('#sendReport').click(function(){
        $('#sendReportDialog p.info').hide();
        $('#sendReportDialog p.error').hide();
        $('#clientEmail').val('');
        $('#sendReportDialog img[alt=ajax]').hide();
        $('span.error').css('visibility', 'hidden');
        $('#sendReportDialog').dialog('open');

        $('#clientEmail').focus(function (){
            $('span.error').css('visibility', 'hidden');
        });
        return false;
    });

    $('#competitorsDialog form').submit(function (event){
        event.preventDefault();
        var domainName = $('#competitor').val();

        if(!valideDomainAddress(domainName)){
            $('#competitorsDialog span.error').css('visibility', 'visible');
            return false;
        } else {
            $('#competitorsDialog span.error').css('visibility', 'hidden');
        }
        
        $('#compareTabel tr td:nth-child(3)').each(function (){
            $(this).empty().append('<img alt="ajax" src="images/ajax.gif">');
        });

        // get data from server
        $('#compareTabel th:nth-child(2)').text($('#reportTable thead td a').text());
        $('#compareTabel th:nth-child(3)').text('www.' + domainName);
        domainName = 'http://www.' + domainName;

        $('#compareTabel tr:not(:has(th))').css('font-weight', 'normal');
        
        $('#pageInfo tr td:nth-child(2)').each(function(index){
            index += 2;
            $('#compareTabel tr:nth-child('+index+') td:nth-child(2)').html($(this).html());
        });

        $.get('seoscripts/favIcon.php', {
            domain : domainName
        }, function(data){
            var noIcon = 'images/error.gif';
            var foundIcon = 'images/passed.gif';
            var $img;
            if(data == 'true') {
                $img = $('<img />').attr('src', foundIcon)
                .attr('alt', 'YES');
            } else {
                $img = $('<img />').attr('src', noIcon)
                .attr('alt', 'NO');
            }
            $('#compareTabel tr:nth-child(2) td:nth-child(3)').empty().append($img);
        });

        $.get('seoscripts/loadTime.php', {
            domain : domainName
        }, function(data) {
            $('#compareTabel tr:nth-child(3) td:nth-child(3)').html(data);
        })

        $('#compareTabel tr:nth-child(4) td:nth-child(2)').text($('#pageInfo tr:nth-child(9) td:nth-child(1)').text());
        $('#compareTabel tr:nth-child(5) td:nth-child(2)').text($('#pageInfo tr:nth-child(11) td:nth-child(1)').text());
        $('#compareTabel tr:nth-child(6) td:nth-child(2)').text($('#pageInfo tr:nth-child(13) td:nth-child(1)').text());

        $.get('seoscripts/domainInfo.php',{
            domain : domainName
        }, function(data){
            eval("var jsonObj =" + data);
            $('#compareTabel tr:nth-child(4) td:nth-child(3)').empty().text(jsonObj.domainRegistrationDate);
            $('#compareTabel tr:nth-child(5) td:nth-child(3)').empty().text(jsonObj.domainExpirationDate);
            $('#compareTabel tr:nth-child(6) td:nth-child(3)').empty().text(jsonObj.domainLastUpdatedDate);
            countPageSEOGradeForCompetitors();
        });

        $('#seoMetrics tr td:nth-child(2)').each(function(index){
            index += 7;
            $('#compareTabel tr:nth-child('+index+') td:nth-child(2)').text($(this).text());
            $.get('seoscripts/' + $(this).attr('id') + 'Metric.php', {
                domain : domainName
            }, function(data){
            	if(data=='') {
            		data = 0;
            	}
                $('#compareTabel tr:nth-child('+index+') td:nth-child(3)').text(data);
                countPageSEOGradeForCompetitors();
            });
        });
        
        $('#compareTabel tr.lastRow td:nth-child(2)').text($('#medal span').text());
        
        $('#competitorsDialog').css('overflow','hidden').animate({
            height: 460,
        }, 'fast');
        $('#compareTabel').show();
        
        var interval = setInterval(function(){
        		if($('#compareTabel img[alt=ajax]:visible').length == 0) {
        			clearInterval(interval);
        			$('#seoCompetitorReport').css('display','inline');
        		}
        	}, 1000);
    });
    /*
    	Competitors report.$('#seoCompetitorReport').
    */
    
    $('#seoCompetitorReport').click(function() {
    	
		$('#myPdf').val($('#compareTabel th:nth-child(2)').text());
        $('#comPdf').val($('#compareTabel th:nth-child(3)').text());
        $('#myFavIconPdf').val($('#myFavIcon img').attr('alt'));  	
        $('#comFavIconPdf').val($('#comFavIcon img').attr('alt'));  	
        $('#myLoadTimePdf').val($('#myLoadTime').text());  	
        $('#comLoadTimePdf').val($('#comLoadTime').text());  	
        $('#myDomainRegistrationDatePdf').val($('#myDomainRegistrationDate').text());  	
        $('#comDomainRegistrationDatePdf').val($('#comDomainRegistrationDate').text());  	
        $('#myDomainExpirationDatePdf').val($('#myDomainExpirationDate').text());  	
        $('#comDomainExpirationDatePdf').val($('#comDomainExpirationDate').text());  	
        $('#myDomainLastUpdatedDatePdf').val($('#myDomainLastUpdatedDate').text());  	
		$('#comDomainLastUpdatedDatePdf').val($('#comDomainLastUpdatedDate').text());  	
		$('#myGooglePageRankPdf').val($('#myGooglePageRank').text());  	
		$('#comGooglePageRankPdf').val($('#comGooglePageRank').text());  	
		$('#myGooglePageIndexPdf').val($('#myGooglePageIndex').text());  	
		$('#comGooglePageIndexPdf').val($('#comGooglePageIndex').text());  	
		$('#myYahooPageIndexPdf').val($('#myYahooPageIndex').text());  	
		$('#comYahooPageIndexPdf').val($('#comYahooPageIndex').text());  	
		$('#myBingPageIndexPdf').val($('#myBingPageIndex').text());  	
		$('#comBingPageIndexPdf').val($('#comBingPageIndex').text());  	
		$('#myLastGoogleCrawlDatePdf').val($('#myLastGoogleCrawlDate').text());  	
		$('#comLastGoogleCrawlDatePdf').val($('#comLastGoogleCrawlDate').text());  			
		$('#myTrafficRankPdf').val($('#myTrafficRank').text());  	
		$('#comTrafficRankPdf').val($('#comTrafficRank').text());  	
		$('#myInboundLinksPdf').val($('#myInboundLinks').text());  	
		$('#comInboundLinksPdf').val($('#comInboundLinks').text());  	
		$('#myCookeeSeoScorePdf').val($('#myCookeeSeoScore').text());  	
		$('#comCookeeSeoScorePdf').val($('#comCookeeSeoScore').text());  	
	
		$('#comparePdfForm').submit();
		
		return false;
    })
});

// generate PDF
$(function(){
    $('#report').click(function () {
    	if($('img[alt=ajax]:visible').length == 0) {
	        $('#reportDomain').val($('#domain').val());
	        $('#generatedTime').val($('#timeStamp').text());
	        $('#title').val($('#pageTitle').text());
	        $('#pageDescription').val($('#description').text());
	        $('#pageKeywords').val($('#keywords').text());
	        $('#pageImgCount').val($('#imgCount').text());
	        $('#w3cValid').val($('#w3cValidation img:eq(0)').attr('alt'));
	        $('#pageFavIcon').val($('#favIcon img:eq(0)').attr('alt'));
	        $('#pageLoadTime').val($('#loadTime').text());
	    	$('#pageReverseIP').val($('#sitesHostedOnAnIPNum').text());
	        $('#pageReverseIPHosts').val($('#sitesHostedOnAnIP').text());
	
	        $('#registrationDate').val($('#domainRegistrationDate').text());
	        $('#expirationDate').val($('#domainExpirationDate').text());
	        $('#lastUpdatedDate').val($('#domainLastUpdatedDate').text());
	        $('#metricGooglePageRank').val($('#googlePageRank').text());
	        $('#metricGooglePageIndex').val($('#googlePageIndex').text());
	        $('#metricYahooPageIndex').val($('#yahooPageIndex').text());
	        $('#metricBingPageIndex').val($('#bingPageIndex').text());
	        $('#metricLastGoogleCrawlDate').val($('#lastGoogleCrawlDate').text());
	        $('#metricTrafficRank').val($('#trafficRank').text());
	        $('#metricInboundLinks').val($('#inboundLinks').text());
	
	        $('#generateReport').submit();
		};
    });
});

// send email to cookee.biz
$(function(){
    $('#sendReportDialog form').submit(function (event){
        event.preventDefault();
        var email = $('#clientEmail').val();
        
        if(!validateEmailAddr(email)){
            $('span.error').css('visibility', 'visible');
            return;
        }
$('#reportDomain').val($('#domain').val());
        $('#sendReportDialog img[alt=ajax]').css('margin-left', '5px').show();
        $.ajax({
            type : 'POST',
            url: 'seoscripts/sendEmail.php',
            data: 'emailAddr=' + email
            + '&clientDomain='+ $('#domain').val() 
			+ '&generatedTime=' + $('#timeStamp').text() 
			+ '&pageTitle=' + $('#pageTitle').text() 
			+ '&pageDescription=' + $('#description').text() 
			+ '&pageKeywords=' +  $('#keywords').text() 
			+ '&pageImgCount=' + $('#imgCount').text()  
			+ '&w3cValid=' + $('#w3cValidation img:eq(0)').attr('alt')  
			+ '&pageFavIcon=' + $('#favIcon img:eq(0)').attr('alt') 
			+ '&pageLoadTime=' + $('#loadTime').text() 
			+ '&pageReverseIP=' + $('#sitesHostedOnAnIPNum').text()  
			+ '&pageReverseIPHosts=' + $('#sitesHostedOnAnIP').text() 
			+ '&registrationDate=' + $('#domainRegistrationDate').text()  
			+ '&expirationDate=' + $('#domainExpirationDate').text() 
			+ '&lastUpdatedDate=' + $('#domainLastUpdatedDate').text()  
			+ '&metricGooglePageRank=' + $('#googlePageRank').text() 
			+ '&metricGooglePageIndex=' + $('#googlePageIndex').text()  
			+ '&metricYahooPageIndex=' + $('#yahooPageIndex').text() 
			+ '&metricBingPageIndex=' + $('#bingPageIndex').text() 
			+ '&metricLastGoogleCrawlDate=' + $('#lastGoogleCrawlDate').text()  
			+ '&metricTrafficRank=' + $('#trafficRank').text() 
			+ '&metricInboundLinks=' + $('#inboundLinks').text(),
            success: function(result) {
                if(result == 'true') {
                    $('#sendReportDialog p.error').hide();
                    $('#sendReportDialog p.info').show();
                } else {
                    $('#sendReportDialog p.info').hide();
                    $('#sendReportDialog p.error').show().html(result);
                }
            },
            async:   false
        });
        $('#sendReportDialog img[alt=ajax]').hide();
        
    });
})

function countPageSEOGrade() {
    var googlePageRank = Number($('#googlePageRank').text());
    var googlePageIndex = Number($('#googlePageIndex').text());
    var yahooPageIndex = Number($('#yahooPageIndex').text());
    var bingPageIndex = Number($('#bingPageIndex').text());
    var trafficRa = Number($('#trafficRank').text().replace(/,/g, ''));
    var inboundLi = Number($('#inboundLinks').text());
    
    var domainExpirationDate = $('#domainExpirationDate').text();
	if(domainExpirationDate != "") {
    	domainExpirationDate = domainExpirationDate.match(/\d{4}$/);
    } else {
    	domainExpirationDate = 0;
    }
    
    var domainRegistrationDate = $('#domainRegistrationDate').text();
    if (domainRegistrationDate != "") {
    	domainRegistrationDate = Number(domainRegistrationDate.match(/\d{4}$/));
    } else {
    	domainRegistrationDate = 0;
    }
    var favIcon = $('#favIcon img').attr('alt');
    var w3cValidation = $('#w3cValidation img').attr('alt');
	
	var pageTitle = $('#pageTitle').text();
	if(pageTitle != "") {
		pageTitle = 'YES';
	} else {
		pageTitle = 0;
	}
	
	var description = $('#description').text();
	if(description != "") {
		description = 'YES';
	} else {
		description = 0;
	}
	
	var keywords = $('#keywords').text();
	if(keywords != "") {
		keywords = 'YES';
	} else {
		keywords = 0;
	}
	var loadTime = $('#loadTime').text();
	
    var grade = getPageSEOGrade(googlePageRank, googlePageIndex, yahooPageIndex, 
    							bingPageIndex, trafficRa, inboundLi, 
    							domainExpirationDate - domainRegistrationDate, favIcon, 
								w3cValidation, pageTitle, description, keywords, loadTime);
		
    if(grade<30)
		$('#medal span').css('color', 'red');
    else 
    	$('#medal span').css('color', '');
    	
    $('#medal span').text(grade);
}

function countPageSEOGradeForCompetitors() {
    var googlePageRank = Number($('#comGooglePageRank').text());
    var googlePageIndex = Number($('#comGooglePageIndex').text());
    var yahooPageIndex = Number($('#comYahooPageIndex').text());
    var bingPageIndex = Number($('#comBingPageIndex').text());
    var trafficRa = Number($('#comTrafficRank').text().replace(/,/g, ''));
    var inboundLi = Number($('#comInboundLinks').text());
    var domainExpirationDate = $('#comDomainExpirationDate').text();
    if(domainExpirationDate != "") {
    	domainExpirationDate = Number(domainExpirationDate.match(/\d{4}$/));
    }
    var domainRegistrationDate = $('#comDomainRegistrationDate').text();
    if (domainRegistrationDate != "") {
    	domainRegistrationDate = Number(domainRegistrationDate.match(/\d{4}$/));
    };
	var favIcon = $('#comFavIcon img').attr('alt');
    
    var domainName = $('#competitor').val();
    domainName = 'http://www.' + domainName;
  
    var w3cValidation = $.ajax({
    	type : "GET",
    	url : 'seoscripts/w3cValidate.php',
    	data: 'domain=' + domainName,
        async:   false
    }).responseText;
    if(w3cValidation =='true') {
    	w3cValidation = 'YES';
    } else {
    	w3cValidation = 'NO';
    }
    
    var metaData = $.ajax({
    	type : "GET",
    	url : 'seoscripts/metadata.php',
    	data: 'domain=' + domainName,
        async:   false
    }).responseText;
    eval("var jsonObj =" + metaData);
	var pageTitle;
	if(!jsonObj.pageTitle) {
		pageTitle = 0;
	} else {
		pageTitle = 'YES';
	}
	var description;
	if(!jsonObj.description) {
		description = 0;
	} else {
		description = 'YES';
	}
	var keywords;
	if(!jsonObj.keywords) {
		keywords = 0;
	} else {
		keywords = 'YES';
	}
	
	var loadTime = $('td#comLoadTime').text();
    var grade = getPageSEOGrade(googlePageRank, googlePageIndex, yahooPageIndex, 
    							bingPageIndex, trafficRa, inboundLi, 
    							 domainExpirationDate - domainRegistrationDate,  favIcon, 
 								w3cValidation, pageTitle, description, keywords, loadTime);
    	
    $('#compareTabel tr.lastRow td:nth-child(3)').text(grade);
}

function getPageSEOGrade(googlePageRank, googlePageIndex, yahooPageIndex, bingPageIndex,
                                trafficRa, inboundLi, domainAge, favIcon, w3cValidation, 
								pageTitle, description, keywords, loadTime) {
     return $.ajax({
            type : 'POST',
            url: 'seoscripts/count.php',
            data: 'googlePageRank='
            + googlePageRank
            + '&googlePageIndex='
            + googlePageIndex
            + '&yahooPageIndex='
            + yahooPageIndex
            + '&bingPageIndex='
            + bingPageIndex
            + '&trafficRa='
            + trafficRa
            + '&inboundLi='
            + inboundLi
            + '&domainAge='
            + domainAge
            + '&favIcon='
            + favIcon
			+ '&w3cValidation='
			+ w3cValidation
			+ '&pageTitle='
			+ pageTitle
			+ '&description='
			+ description
			+ '&keywords='
			+ keywords
			+ '&loadTime='
			+ loadTime,
            async:   false
        }).responseText;
}

function valideDomainAddress(domainAddres){
    $('span.error').css('visibility', 'hidden');

    if(domainAddres == "" || new RegExp("^(www\.)|(http://)",'i').test(domainAddres)){
        return false;
    } else {
    //        $('img.ajax').show();
    //        var result;
    //        $.ajax({
    //            url: 'seoscripts/validateDomain.php'
    //            + '?domain='
    //            + domainAddres,
    //            success: function(r) {
    //                result = r;
    //            },
    //            async:   false
    //        });
    //        $('img.ajax').hide();
    //        if(result == 'false')
    //            return false;
    }
    return true;
}

function validateEmailAddr(emailAddr) {
    if(/^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@([a-zA-Z0-9_-]+)(\.[a-zA-Z0-9_-]+)*(\.[a-zA-Z]{2,4})$/.test(emailAddr)){
        return true;
    }else {
        return false;
    }
}
function hideNullH(){
    $('.hInfo').each(function (index){
        if($(this).next().find('td').text() == '') {
            $(this).hide().next().hide();
        }
    })
}

function getCurrentDate(){
    var date = new Date();
    return date.format('mm/dd/yyyy HH:MM:ss');
}
