﻿// JavaScript Document
var allFields = [];
var reqFields = [];
var newFields = [];
var shortReqFields = [];
var TwtObj;
var FBObj;
var LinkObj
var UserObj;
//for my menu selection at christiansummermusic.com
var sections;
var loading;
//var content; depricated by MainContent
var loadingImage;
var MainContentContainer; //the jquery div for swapping page templates from the menu


var getFinalJSSuccessFlag;

var $myTemplate;
var myTemplate2;
var $returnedhtmltemplatepage;
var returnedhtmltemplatepage2;



//working
var TemplateString;
var FBtemplate; //Main fb template
var FBtemplateLoad;// loading fb (shown while waiting for the request to return from server)
var FBtemplateError;//Template used when the user isnt found
var linkedInTemplate;//Main linkedin template
var linkedInTemplateLoad; // loading linkedin template (shown while waiting for the request to return from server)
var linkedInTemplateError;// error template for linked in
var TwitterTemplate; //main twitter template
var TwitterTemplateLoad;//you get the idea
var TwitterTemplateError;

var Language;
var MainTemplate;

var MainData; //data array for holding the data that binds to the MainTemplate
var UserData;
//var TwitterData; //data array for holding the data that binds to the TwitterTemplate
//var FBData; //data array for holding the data that binds to the FBtemplate
//var LinkedData; //data array for holding the data that binds to the linkedInTemplate
//var myEmailList = []; //was used to auto populate the username as typed...but the web serice is down
//var PageInputArray = []; //array that holds all the data for rebuilding the page when resource files change.
var MainDataCreationString;
var TempTableURLString;


var object; // = this.theForm;
var table;
var elements = [];
var test;
var mylength;
var headers = [];
//var fname;
//var lname;
//var twitterid;
//var fbid;
//var myData;
//var MyTwitterUser;

var keywords = [];

///*
//* jQuery Highlight plugin
//*
//* Based on highlight v3 by Johann Burkard
//* http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
//*
//* Code a little bit refactored and cleaned (in my humble opinion).
//* Most important changes:
//*  - has an option to highlight only entire words (wordsOnly - false by default),
//*  - has an option to be case sensitive (caseSensitive - false by default)
//*  - highlight element tag and class names can be specified in options
//*
//* Usage:
//*   // wrap every occurrance of text 'lorem' in content
//*   // with <span class='highlight'> (default options)
//*   $('#content').highlight('lorem');
//*
//*   // search for and highlight more terms at once
//*   // so you can save some time on traversing DOM
//*   $('#content').highlight(['lorem', 'ipsum']);
//*   $('#content').highlight('lorem ipsum');
//*
//*   // search only for entire word 'lorem'
//*   $('#content').highlight('lorem', { wordsOnly: true });
//*
//*   // don't ignore case during search of term 'lorem'
//*   $('#content').highlight('lorem', { caseSensitive: true });
//*
//*   // wrap every occurrance of term 'ipsum' in content
//*   // with <em class='important'>
//*   $('#content').highlight('ipsum', { element: 'em', className: 'important' });
//*
//*   // remove default highlight
//*   $('#content').unhighlight();
//*
//*   // remove custom highlight
//*   $('#content').unhighlight({ element: 'em', className: 'important' });
//*
//*
//* Copyright (c) 2009 Bartek Szopka
//*
//* Licensed under MIT license.
//*
//*/

jQuery.extend({
	highlight: function (node, re, nodeName, className) {
		if (node.nodeType === 3) {
			var match = node.data.match(re);
			if (match) {
				var highlight = document.createElement(nodeName || 'span');
				highlight.className = className || 'highlight';
				var wordNode = node.splitText(match.index);
				wordNode.splitText(match[0].length);
				var wordClone = wordNode.cloneNode(true);
				highlight.appendChild(wordClone);
				wordNode.parentNode.replaceChild(highlight, wordNode);
				return 1; //skip added node in parent
			}
		} else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
				!/(script|style)/i.test(node.tagName) && // ignore script and style nodes
				!(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
			for (var i = 0; i < node.childNodes.length; i++) {
				i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
			}
		}
		return 0;
	}
});

jQuery.fn.unhighlight = function (options) {
	var settings = { className: 'highlight', element: 'span' };
	jQuery.extend(settings, options);

	return this.find(settings.element + "." + settings.className).each(function () {
		var parent = this.parentNode;
		parent.replaceChild(this.firstChild, this);
		parent.normalize();
	}).end();
};

jQuery.fn.highlight = function (words, options) {
	var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
	jQuery.extend(settings, options);

	if (words.constructor === String) {
		words = [words];
	}
	words = jQuery.grep(words, function (word, i) {
		return word != '';
	});
	words = jQuery.map(words, function (word, i) {
		return word.replace("/[-[\]{}()*+?.,\\^$|#\s]/g", "\\$&");
	});
	if (words.length == 0) { return this; };

	var flag = settings.caseSensitive ? "" : "i";
	var pattern = "(" + words.join("|") + ")";
	if (settings.wordsOnly) {
		pattern = "\\b" + pattern + "\\b";
	}
	var re = new RegExp(pattern, flag);

	return this.each(function () {
		jQuery.highlight(this, re, settings.element, settings.className);
	});
};





//placed this function here so that googles garbage collection wont trash my script the function below would be sufficient but if you dont have any
//functions external to doc.ready then google trashes the script which prevents debugging.
//function getData(tr) {
//    alert(tr);
//}


/*
jquery-uniqueArray.js
By: William Skidmore - www.wskidmore.com

Purpose: Remove duplicates elements in an array
[1,1,2,2,3,3] -> [1,2,3]

Installation: Include jquery first, then this js file.

Usage:
var myArray = ["Bob","Bob","Mary","Susan","Susan"];
myArray = $.uniqueArray(myArray);
document.write(myArray);
	
outputs -- Bob, Mary, Susan
	
License: Released under MIT License:
Copyright (c) 2010 William Skidmore

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
jQuery.extend({
	uniqueArray: function (array) {
		if ($.isArray(array)) {
			var dupes = {}; var len, i;
			for (i = 0, len = array.length; i < len; i++) {
				var test = array[i].toString();
				if (dupes[test]) { array.splice(i, 1); len--; i--; } else { dupes[test] = true; }
			}
		} else {
			if (window.console) console.log('Not passing an array to uniqueArray, returning whatever you sent it - not filtered!');
			return (array);
		}
		return (array);
	}
});

//old
function doSomething() {
	//var myrequest = new ajaxRequest()

	//    $.ajax({
	//        url: 'http://twitter.com/users/show_for_profile.json?screen_name=',
	//        cache: false,
	//        dataType: 'json'
	//    });
	//MyTwitterUser = $.getJSON("http://twitter.com/users/show_for_profile.json?screen_name=");
	//var MyTwitterUser = $.getJSON("http://twitter.com/users/show_for_profile.json?screen_name=");

}







//turns on or off the console window
function ToggleConsole() {
    $("#chkConsole:checked");
	var console = $("#LiveLogdiv");
	var myChk = $("#chkConsole");

	$('#LiveLogdiv').toggle(myChk.val());
//    if (thisCheck.is (':checked'))
//    {
//        console.show();
//    }
//    if (thisCheck.is !(':checked'))
//    {
//        console.hide();
//    }
}


//nothing
function BodyLoad() {

}

//only called when a new resource is needed from the server.
//this control rebuilds the page when required (like when changing languages)
function BuildMainData() {
	var allInputs = MainTemplate.find(".mainInput");//finds only the values that have .mainInput
	//mainInput
	$.each(allInputs, function (i, val) {
	    PageInputArray.push($(this).attr("id"));
	    val = val;
	    //alert($(this).attr("id"));
	    //$(this).val().toLowerCase();
	    //MainData[$(this).attr("id")] = $(this).val();
	    //MainData.$(this).att('id') = $(this).val();
	});
	MainDataCreationString = "";
	MainDataCreationString = "MainData={";
	$.each(PageInputArray, function (i, val) {
		//eval("MainData" + val + "=/" / "");
		
		MainDataCreationString += val;
		if (i < PageInputArray.length-1) {
			MainDataCreationString += ":\"\",";
		}
		else {
			MainDataCreationString += ":\"\"};";
			//MainData={MainDataCreationString};
		}
		
		//{firstname:"John",lastname:"Doe",age:50,eyecolor:"blue"};
	});
	//creates the main data objects based off of the id's of the inputs
	eval(MainDataCreationString);   
	
}

//this function builds json object for rendering in the Main templates
function GetMainData() {
	//MainTemplate = $(TemplateString).filter('#MainTemplate');

	//var allInputs = $(MainTemplate).filter(':input');
	//var allInputs = MainTemplate.children().filter(':input');
	//var allInputs = MainTemplate.children().filter('.mainInput');
	//var allInputs = MainTemplate.filter('.mainInput');
    if (MainTemplate != undefined) 
    {
        if (MainData == undefined) 
        {
			BuildMainData();//only called if the MainData json object doesnt exist and the page needs to be rebuilt
		}
        $.each(PageInputArray, function (i, val) 
        {
			//MainData. + val = $("#" + val + "").val();
			MainData[val] = $("#" + val + "").val(); //rebuilds the MainData json object          
		});
	}
	
	//var allInputs = MainTemplate.filter(':input').toArray;
	//var mainDiv = $("#Main");
	//var allInputs = $(mainDiv).filter(':input');
}


function RefreshTemplates() {

//    TwitterData =
//            { name: TwtObj.Name,
//                screen_name: TwtObj.ScreenName,
//                location: TwtObj.Location, //
//                description: TwtObj.Description, //
//                url: TwtObj.Url, //"",
//                profile_image_url: TwtObj.ProfileImageUrl,  //""
//                followers_count: TwtObj.FollowersCount,
//                following: TwtObj.FriendsCount,
//                text: TwtObj.Status.Text,
//                statuses_count: TwtObj.StatusesCount
//            }; //,

	

//    if (MainData != undefined) {
//        $("#Main").empty()
//        $.tmpl(MainTemplate).appendTo('#Main');
	//    }

	if (MainData == undefined) {
	    $("#Main").empty();
	    $.tmpl(MainTemplate).appendTo('#mainTemplate'); //if there is no data, dont bind any data to the template
	}
	else {
	    $("#Main").empty();
	    $.tmpl(MainTemplate, MainData).appendTo('#mainTemplate'); //bind main data to the MainTemplate
	}
	
	$("#Loading").toggle();//shows the loading screen while loading
	var LanguageList = ["English", "French"];
	var options = '';
	for (var i = 0; i < LanguageList.length; i++) {
		options += '<option value"' + LanguageList[i] + '">' + LanguageList[i] + '</option>';
	}
	$("select#Language").html(options);//adds the language options to the language dropdownlist
	$("select#Language").val(Language);
//    if (Language == "English") {
//        $("select#Language").val("English");
//    }
//    if (Language == "French") {
//        $("select#Language").val("French");
//    }	
}

//uses a json request to pull in the resource template file for the page depending on current language
//only called when templates need to be replaced
function LoadTemplates() {
	var error = 0;
	if (Language == "English") {
		$.get('styles/indexTemplates.htm', function (myTemplatedata) {
			TemplateString = myTemplatedata.toString();
		})
		.success(function () { })
		.error(function () {
			//$("#LiveLog").append("\n -> connection to wcf server for Template file failed...");
			alert("failed on english");
			error = 1;
		 })
		.complete(function () {        
			if (error == 0) {
				//$("#LiveLog").append("\n ->email JSON object recieved from server");
			    GetMainData();
			    MainTemplate = $(TemplateString).filter('#mainTemplate');
			    if (MainData != undefined) {
			        //$returnedhtmltemplatepage = $(myTemplatedata).find('div[id="FBTemplateLoad"]');
			        //var myTemplate8 = $returnedhtmltemplatepage.find('div[id="FBTemplateLoad"]').html();
//			        TwitterTemplate = $(TemplateString).filter('#TwitterTemplate');
//			        TwitterTemplateLoad = $(TemplateString).filter('#TwitterTemplateLoad');
//			        TwitterTemplateError = $(TemplateString).filter('#TwitterTemplateError');
//			        FBtemplate = $(TemplateString).filter('#FBTemplate');
//			        FBtemplateLoad = $(TemplateString).filter('#FBTemplateLoad');
//			        FBtemplateError = $(TemplateString).filter('#FBTemplateLoadError');
//			        linkedInTemplate = $(TemplateString).filter('#LinkedInTemplate');
//			        linkedInTemplateLoad = $(TemplateString).filter('#LinkedInTemplateLoad');
//			        linkedInTemplateError = $(TemplateString).filter('#LinkedInTemplateLoadError');
			    }
			    RefreshTemplates();//now that we have populated the templates in memory, we need to re-render the page with the new templates              
				
			}
			if (error > 0) {
				//$("#fb").append('no FaceBook account found');
			}
			//alert("complete"); 
		});
	}
//	if (Language == "French") {
//	    $.get('styles/clientsidetemplatesFR.htm', function (myTemplatedata) {
//	        TemplateString = myTemplatedata.toString();
//	    })
//		.success(function () { })
//		.error(function () {
//		    //$("#LiveLog").append("\n -> connection to wcf server for Template file failed...");
//		    alert("failed on french");
//		    error = 1;
//		}		
//      .complete(function () {
//		    if (error == 0) {
//		        GetMainData();
//		        MainTemplate = $(TemplateString).filter('#MainTemplate');
//		        if (MainData != undefined) {
//		            //$("#LiveLog").append("\n ->email JSON object recieved from server");
//		            //TemplateString = myTemplatedata.toString();
//		            //$returnedhtmltemplatepage = $(myTemplatedata).find('div[id="FBTemplateLoad"]');
//		            //var myTemplate8 = $returnedhtmltemplatepage.find('div[id="FBTemplateLoad"]').html();
//		            GetMainData();
//		            MainTemplate = $(TemplateString).filter('#MainTemplateFR');
//		            TwitterTemplate = $(TemplateString).filter('#TwitterTemplateFR');
//		            TwitterTemplateLoad = $(TemplateString).filter('#TwitterTemplateLoadFR');
//		            TwitterTemplateError = $(TemplateString).filter('#TwitterTemplateErrorFR');
//		            FBtemplate = $(TemplateString).filter('#FBTemplateFR');
//		            FBtemplateLoad = $(TemplateString).filter('#FBTemplateLoadFR');
//		            FBtemplateError = $(TemplateString).filter('#FBTemplateErrorFR');
//		            linkedInTemplate = $(TemplateString).filter('#LinkedInTemplateFR');
//		            linkedInTemplateLoad = $(TemplateString).filter('#LinkedInTemplateLoadFR');
//		            linkedInTemplateError = $(TemplateString).filter('#LinkedInTemplateErrorFR');
//		        }
//		        RefreshTemplates(); //now that we have populated the templates in memory, we need to re-render the page with the new templates              
//		    }
//		    if (error > 0) {
//		        //$("#fb").append('no FaceBook account found');
//		    }
//		    //alert("complete"); 
		//});
//}

	//    var TestTemplate = $("#FBTemplateLoad", $returnedhtmltemplatepage);
	//return $(this).val().toLowerCase();

//    var myTest = $.get('styles/clientsidetemplates.htm', function (myTemplatedata) {
//        return this.find('div[id="FBTemplateLoad"]').html;
//    });

//    $.get('styles/clientsidetemplates.htm', function (myTemplatedata) {
//        returnedhtmltemplatepage2 = $(this).context().find('div[id="FBTemplateLoad"]').html();
//    });
//    var TestTemplate2 = $("#FBTemplateLoad", returnedhtmltemplatepage2)


//    $.get('styles/clientsidetemplates.htm', function (myTemplatedata) {
//        $returnedhtmltemplatepage = myTemplatedata.toString();
//        $myTemplate = $('#FBTemplateLoad', $returnedhtmltemplatepage);
//        $.tmpl($myTemplate.val()).appendTo('#fb');
//    });

//    myTemplate = $('#FBTemplateLoad', $returnedhtmltemplatepage);
//    $.tmpl(myTemplate).appendTo('#testtemplate');
//    $.tmpl(TestTemplate).appendTo('#testtemplate');
//    $.tmpl(TestTemplate2).appendTo('#testtemplate');

}

//ajax call to autopopulate the email addresses while the user types
function GetEmailAutoPopulate() {
	//var url = "http://localhost:85/SocProfAPI/SocProf/fb-email=" + emailname + "&domain-name=" + domain + "&tld=" + tld;
	//code here GetEmailAutoPopulate
	var error = 0;
	var url = "http://localhost:85/SocProfAPI/Profile/autopopulateemail=dontmatter" 
	$.getJSON(url, function (json) {
		myEmailList = json;
		return;
	})
	.success(function () { })
	.error(function () {
		$("#LiveLog").append("\n -> connection to wcf server for email list Data failed...");
		//alert("error on facebook");
		error = 1;
	})
	.complete(function () {        
		if (error == 0) {
			$("#LiveLog").append("\n ->email JSON object recieved from server");            
		}
		if (error > 0) {
			//$("#fb").append('no FaceBook account found');
		}
		//alert("complete"); 
	});
}
//binds the list
function EmailAutoPop() {
	$("#Email").autocomplete({
		source: myEmailList
	});
}
//function called with the langauge dropbox selection changes
function LanguageChange() {
	var newOption = $("select#Language option:selected").text();
	if (Language != newOption) 
	{
		Language = newOption;
		LoadTemplates();
		//RefreshTemplates();        
	}	
	//$("select#Language ").change(LanguageChange());
	//$("select#Language option:selected").change(LanguageChange());

}

//show loading bar
function showLoading() {   
    loading
            .css({ visibility: "visible" })
            .css({ opacity: "1" })
            .css({ display: "block" })
            ;
}

//hide loading bar
function hideLoading() {
    //loading.fadeTo(1000, 0);
    MainContentContainer.slideDown(250, 0);
    //loading.css({ display: "hidden" })
    $("#loadingimage").fadeTo(1000, 0);
};

function sectionsclick(menuselection) {
    //var test = id;

    if (MainContentContainer == null || MainContentContainer == undefined) {
        MainContentContainer = $("#MainContentContainer");
    }

    if (loading == null || loading == undefined) {
    loading = $("#loading");
    }
    if (loadingImage == null || loadingImage == undefined) {
        loadingImage = $("#loadingImage");
    }

    //switch (menuselection.id.toString()) {
    switch (menuselection) {
        case "home":
            $("#loadingimage").show();
            MainContentContainer.slideUp(250, 0);
            //content.load("sections.html #section_home", hideLoading);
            MainContentContainer.load("styles/indexTemplates.htm #indexPageTemplate", hideLoading);
            break;
        case "music":
            $("#loadingimage").show();
            MainContentContainer.slideUp(200, 0);
            MainContentContainer.load("styles/indexTemplates.htm #musicPageTemplate", hideLoading);
            //content.load("sections.html #section_music", hideLoading);
            break;
        case "pictures":
            $("#loadingimage").show();
            MainContentContainer.slideUp(300, 0);
            MainContentContainer.load("sections.html #section_pictures", hideLoading);
            break;
        case "videos":
            $("#loadingimage").show();
            MainContentContainer.slideUp(175, 0);
            MainContentContainer.load("styles/indexTemplates.htm #videosPageTemplate", hideLoading);
            break;
        case "shows":
            $("#loadingimage").show();
            MainContentContainer.slideUp(200, 0);
            MainContentContainer.load("styles/indexTemplates.htm #showsPageTemplate", hideLoading);
            break;
        case "sideprojects":
            $("#loadingimage").show();
            MainContentContainer.slideUp(225, 0);
            MainContentContainer.load("styles/indexTemplates.htm #sideProjectsPageTemplate", hideLoading);
            break;
        case "programming":
            $("#loadingimage").show();
            MainContentContainer.slideUp(250, 0);
            MainContentContainer.load("styles/indexTemplates.htm #programmingPageTemplate", hideLoading);
            break;
        case "thisismymusic":
            $("#loadingimage").show();
            MainContentContainer.slideUp(250, 0);
            MainContentContainer.load("styles/indexTemplates.htm #thisismymusicPageTemplate", hideLoading);
            break;
        case "thistrain":
            $("#loadingimage").show();
            MainContentContainer.slideUp(250, 0);
            MainContentContainer.load("styles/indexTemplates.htm #thistrainPageTemplate", hideLoading);
            break;
        case "hidden":
            $("#loadingimage").show();
            MainContentContainer.slideUp(250, 0);
            MainContentContainer.load("styles/indexTemplates.htm #hiddenPageTemplate", hideLoading);
            break;
        //hiddenPageTemplate

        default:
            //hide loading bar if there is no selected section
            hideLoading();
            break;
    }

}

function loadFinalGlobalJS(jsFile)
{
//successFlag=false; // Assume Failure
getFinalJSSuccessFlag = false;


    //jQuery.ajax({
    //async: false,
    //type: "GET",
    //url: jsFile,
    //data: null,
    //success: function() {initializeScript.apply(); successFlag=true;},
    //dataType: 'script'
    //});
}

function ReadAndSetControlAtrributes() {
    //$("#loadingimage").fadeTo(1000, 0);
    $(".draggable").dragable();
}


$(document).ready(function () {

    //onInit();
    //GetEmailAutoPopulate();

    //$("#Loading").toggle();
    //loadFinalGlobalJS(FinalJS);
   
    //ReadAndSetControlAtrributes();
    Language = "English";
    LoadTemplates();
    $("#loadingimage").hide();
    //    sections = $("#solidblockmenu li");
    //    loading = $("#loading");
    //    content = $("#content");

    //Manage click events
    //    sections.click(function () {
    //        //show the loading bar
    //        showLoading();
    //        //load selected section
    //        switch (this.id) {
    //            case "home":
    //                content.slideUp(500, 0);
    //                content.load("sections.html #section_home", hideLoading);
    //                break;
    //            case "music":
    //                content.slideUp(500, 0);
    //                content.load("sections.html #section_music", hideLoading);
    //                break;
    //            case "pictures":
    //                content.slideUp(500, 0);
    //                content.load("sections.html #section_pictures", hideLoading);
    //                break;
    //            case "videos":
    //                content.slideUp(500, 0);
    //                content.load("sections.html #section_videos", hideLoading);
    //                break;
    //            case "shows":
    //                content.slideUp(500, 0);
    //                content.load("sections.html #section_shows", hideLoading);
    //                break;
    //            case "sideprojects":
    //                content.slideUp(500, 0);
    //                content.load("sections.html #section_sideprojects", hideLoading);
    //                break;
    //            case "programming":
    //                content.slideUp(500, 0);
    //                content.load("sections.html #section_programming", hideLoading);
    //                break;
    //            default:
    //                //hide loading bar if there is no selected section
    //                hideLoading();
    //                break;
    //        }
    //    });

    //RefreshTemplates();    

    //$("select#Language option:selected").change(LanguageChange());



    //    $.getJSON("http://localhost:85/SocProfAPI/SocProf/twitter-id=", function (json) {
    //        //$.each(json.user, function (i, twit) {
    //        TwtObj = json;
    //        return TwtObj;
    //        //alert("ajaxtest");
    //        //alert(json.user);
    //        //});

    //    })
    //    .success(function () { alert(TwtObj.Name); })
    //    .error(function () { alert("error"); })
    //    .complete(function () {alert("complete");});


    //var myJsonTestObject = $.getJSON("http://localhost:85/SocProfAPI/SocProf/twitter-id=")
    //    $.getJSON("http://localhost:85/SocProfAPI/SocProf/twitter-id=", function (json) {
    //        //$.each(json.user, function (i, twit) {

    //        TwtObj = json;
    //        return TwtObj;
    //        //alert("ajaxtest");
    //        //alert(json.user);
    //                //});

    //    });
    //    //var myJson2 = JSON.parse
    //    var myTestJ = $.ajax({
    //        type:'GET',
    //        url: "http://localhost:85/SocProfAPI/SocProf/twitter-id=",
    //        dataType: 'json',
    //        error: function(){alert("it done broke!!!")}
    //        //complete: function(myData) {alert("ajax test")}
    //        complete: function () {return $(this)}
    //    });

    //      var JSon = $.get("http://localhost:85/SocProfAPI/SocProf/twitter-id=", function(data){
    //      alert(data.screen_name);
    //      alert(data.name);
    //      } , "json");

    //working
    //populate ldd_column_names with column names from import file
    //    ldd_column_name = $(':input[id*="ldd_column_name"]').map(
    //        function () { return $(this).val().toLowerCase(); }
    //        ).toArray();
    //    //populate ldd_alias with first row data
    //    ldd_alias = $(':input[id*="ldd_alias"]').map(
    //        function () { return $(this).val().toLowerCase(); }
    //        ).toArray();
    //    //populate all fields from select drop down list
    //    allFields = $('select[id*="ldd_nf_field_name"] > option').map(
    //        function () { return $(this).val().toLowerCase(); }
    //        ).toArray();
    //    //sets the object prefix
    //    prefix[0] = allFields[1].substring(0, 3);

    //    //works but on all required fields
    //    reqFields = $('select[id*="ldd_nf_field_name"] > option').map(
    //            function () {
    //                if (($(this).text().indexOf("*") > 0)) {
    //                    return $(this).val().toLowerCase();
    //                }
    //            }
    //            ).toArray();

    //    keywords = $('#txtSearchTerms').map(
    //        function () { return $(this).val().split(','); }
    //        ).toArray();

    //    fname = $('#lblFirst').text();
    //    lname = $('#lblLast').text();
    //    twitterid = $('#lblTwitter').text();
    //    fbid = $('#lblFBID').text();
    //    if (fname) keywords.push(fname);
    //    if (lname) keywords.push(lname);
    //    if (twitterid) keywords.push(twitterid);
    //    if (fbid) keywords.push(fbid);
    //    //keywords = keywords.distinct();
    //    keywords = $.unique(keywords);



    //    ];
    /////super duper important
    //***********************************************
    //$("#TwittermyTemplate").tmpl(TwitterData).appendTo("#Twitter");
    //$("#TwittermyTemplate2").tmpl(TwitterData).appendTo("#Twitter");
    //$("#TwittermyTemplate").tmpl(TwitterData).innertext;

    //$("body").highlight(keywords);

    //keywords.push(fname);



    //    shortReqFields = $('select[id*="ldd_nf_field_name"] > option').map(
    //            function () {
    //                if (($(this).text().indexOf("*") >= 0)) {

    //                    if (($(this).text().indexOf(prefix[0]) == 0))
    //                        return $(this).val().toLowerCase();
    //                }
    //            }
    //            ).toArray();


    //missingFields = shortReqFields.slice(0);
    //    jQuery.uniqueArray(shortReqFields);
    //    missingFields = shortReqFields.slice(0);
    //missingFields = jQuery.uniqueArray(shortReqFields);
    //missingFields = shortReqFields;

    //if (lfd_include_headers_flag) == checked then matchFields

    //    if ($('#lfd_include_headers_flag').text() == 'Yes') {
    //        matchFields();
    //    }
    //works right now
    //sets an on change function when the selectors in the file def details change
    //$('select[id*="ldd_nf_field_name"]').change(function () {
    //    alert('changed a selector in datagrid');
    //});
    //$('select[id*="ldd_nf_field_name"]').change(checkrequiredfields);

    //checkrequiredfields();

    //elements = $("table#UPDATEGRIDCONTROL_DOD_File_Detail_InternalUpdateGrid > tbody > tr > td").each(function (index, item) {
    //    elements = $("table#UPDATEGRIDCONTROL_DOD_File_Detail_InternalUpdateGrid > tbody > tr").each(function (index, item) {
    //        if ($(this).hasClass("DataGridItem")) {

    //            //if ($(this).children[0].children == "")
    //            //if ($(this).children.length > 1)
    //            //if (test.value) //////&& $(this).children[0].children[0].value != null)
    //            object = $(this);
    //            test = this.children[0];
    //            //mylength = $(test).length;
    //            //if ($(object[0]).length >= 1) 
    //            //if ($(this).children[0].length > 0) {
    //            if (test != null) {


    //                if (test.childElementCount == 0) {
    //                    alert(test.value);
    //                }
    //                else {
    //                    alert(test.children[1].value);
    //                }
    //            }
    //        }
    //    });


});

