var search =  [
{name: "Home", desc: "Home page of the LEAD Portal.", keyword: ""} ,

{name: "Perception", desc: "A brief introduction and perception to start off your way on becoming a leader.", keyword: ""} ,
{name: "Defining Leader", desc: "Definition of Leader", keyword: ""} ,
{name: "Defining Leadership", desc: "Definition of Leadership", keyword: ""} ,
{name: "Leadership VS Management", desc: "Know the difference between leadership & management", keyword: ""} ,

{name: "Qualities", desc: "List of qualities a leader should possess", keyword: "quality"} ,
{name: "Communication Skills", desc: "Good communication skill of leader also earns himself respect and loyalty from his workers.", keyword: "qualities quality"} ,
{name: "Empathy", desc: "Empathy is crucial as leader must be sensitive to other people's feelings at all times. ", keyword: "qualities quality"} ,
{name: "Enthusiasm and Energy", desc: "Enthusiasm and energy is the basis of a leader's effectiveness.", keyword: "qualities quality"} ,
{name: "Innovation", desc: "Innovation - Good leaders always seek new ways of doing things and accept challenges as opportunities for improvement.", keyword: "qualities quality"} ,
{name: "Integrity", desc: "Integrity is an important virtue which reflects leader's leadership abilities and styles.", keyword: "qualities quality"} ,
{name: "Objectivity", desc: "Objectivity is necessary for leaders to be effective.", keyword: "qualities quality"} ,
{name: "Risk Taking", desc: "Leaders are bound to take risks when dealing with problems. Hence, risk taking is essential.", keyword: "qualities quality"} ,
{name: "Service", desc: "The key characteristic of great leaders is their willingness to make personal sacrifices in serving others.", keyword: "qualities quality"} ,
{name: "Visioning", desc: "Leaders are people with foresight and vision who understand lessons from the past.", keyword: "qualities quality"} ,

{name: "Theories", desc: "List of leadership styles", keyword: ""} ,
{name: "Situational Leadership", desc: "Situational Leadership holds that leaders must use different leadership styles depending on the situation. The model allows you to analyze the needs of the situation you are in, and then use the most appropriate leadership style.", keyword: "theories theory"} ,
{name: "Transformational Leadership", desc: "A transformational leader engages with others in such a way that leaders and followers raise one another to higher levels of motivation and morality.", keyword: "theories theory"} ,
{name: "Servant Leadership", desc: "The servant leader serves others, rather than others serving the leader. Serving others thus comes by helping them to achieve and improve.", keyword: "theories theory"} ,
{name: "Autocratic Leadership", desc: "A leadership style wherein the authority is from leader's position, knowledge, strength or power to reward and punish, and he uses this authority as his principal method of getting things done.", keyword: "theories theory"} ,
{name: "Bureaucratic Leadership", desc: "A Leadership Style wherein a leader is absolutely following the organization's policies, procedures, rules and manages entirely \"by the book\" and no exceptions are permitted.", keyword: "theories theory"} ,
{name: "Charismatic Leadership", desc: "A charismatic leader controls his followers by the force of his/her personality.", keyword: "theories theory"} ,
{name: "Diplomatic Leadership", desc: "A diplomatic leader has the skills and tact in dealing with other people and in managing relationships.", keyword: "theories theory"} ,
{name: "Participative Leadership", desc: "A participative leader openly invites his people to participate or share to a greater or lesser extent, in decision, policy making and operations methods.", keyword: "theories theory"} ,
{name: "Power-Influence Approach", desc: "The power-influence approach links the effectiveness of leadership to the power bases of the leaders.", keyword: "theories theory"} ,
{name: "Primal Leadership", desc: "Primal leadership is a new concept in the 21st century based on the theory of emotional intelligence.", keyword: "theories theory"} ,


{name: "Case Studies", desc: "Case studies of famous leaders around the world", keyword: "case study studies"} ,
{name: "Bill Clinton", desc: "Bill Clinton - Forty-second president of United States", keyword: "case study studies"} ,
{name: "Bill Gates", desc: "Bill Gates - CEO of Microsoft till 2008", keyword: "case study studies"} ,
{name: "Ho Chi Minh", desc: "Ho Chi Minh - President of Democratic Republic of Vietnam from 1946-1969", keyword: "case study studies"} ,
{name: "Mahatma Gandhi", desc: "Mahatma Gandhi - Political and spiritual leader of India", keyword: "case study studies"} ,
{name: "Martin Luther King", desc: "Martin Luther King - A pivotal leader of the American civil rights movement", keyword: "case study studies"} ,
{name: "Mother Teresa", desc: "Mother Teresa - Famed as a humanitarian and advocate for the poor and helpless", keyword: "case study studies"} ,
{name: "Ong Teng Cheong", desc: "Ong Teng Cheong - The first directly elected President of Singapore", keyword: "case study studies"} ,


{name: "Application", desc: "Place to apply your knowledges on  different situations", keyword: ""} ,
{name: "Article Analysis", desc: "In depth article analysis on leadership", keyword: "application"} ,
{name: "Conflict Resolution", desc: "Learn how to resolve your conflict with your friends", keyword: "application"} ,

{name: "Interviews", desc: "Interviews from famous school leaders around the world", keyword: ""} ,


{name: "Video Interviews", desc: "Select from a list of video interviews", keyword: "interviews"} ,
{name: "Text Interviews", desc: "Select from a list of text interviews", keyword: "interviews"} ,
{name: "Izumi Tan", desc: "Interview with Izumi Tan", keyword: "interviews"} ,
{name: "Norman", desc: "Interview with Norman", keyword: "interviews"} ,
{name: "William", desc: "Interview with William", keyword: "interviews"} ,
{name: "Tiffany", desc: "Interview with Tiffany", keyword: "interviews"} ,
{name: "Yvette", desc: "Interview with Yvette", keyword: "interviews"} ,
{name: "Hon Chiew Weng", desc: "Interview with Dr Hon Chiew Weng, Principal of Hwa Chong Institution (High School Section)", keyword: "interviews"} ,

{name: "Leadership at Home", desc: "Relevant situations faced by teenagers at home", keyword: "application"} ,
{name: "Leadership in School", desc: "Relevant situations faced by teenagers in school", keyword: "application"} ,

{name: "Activities", desc: "List of interesting multimedia activities to enhance your learning", keyword: ""} ,
{name: "Game 1", desc: "Game - Develop Your Country", keyword: "activity games activities"} ,
{name: "Game 2", desc: "Game - Ship Commander", keyword: "activity activities games"} ,
{name: "Crossword Puzzle", desc: "Test your knowledge and complete this crossword puzzle!", keyword: "games activities activity"} ,
{name: "Motivation Assessment", desc: "An assessment on how motivated you are to lead", keyword: "activity activities"} ,
{name: "Student Leadership Scale", desc: "A student leadership scale to assess your leadership capability", keyword: "assessment activities activity"} ,


{name: "Technology", desc: "Find out the technologies behind the LEAD Portal.", keyword: "ajax"},
 {name: "The Team", desc: "Want to know who we are? Find out!", keyword: "about"},
 
 {name: "Profile", desc: "Track all the activities you have completed on this portal", keyword: "report"},

{name: "Importance of Leadership", desc: "Why study leadership? With list of statistics and survey showing imprtance of leadership.", keyword: ""} 

];


function cleanArray(actual){
  var newArray = new Array();
  for(var i = 0; i<actual.length; i++){
      if (actual[i]){
        newArray.push(actual[i]);
    }
  }
  return newArray;
}


function s(query){
	if(query!=null&&query!=''){

	var terms = cleanArray(query.toLowerCase().strip().split(' ').uniq());

	var sresult = [];
	search.each(function(s){
		var used = false;
		terms.each(function(t){
			if(s.desc.toLowerCase().match(t)||s.name.toLowerCase().match(t)||s.keyword.toLowerCase().match(t)){
				snew = {name: s.name, desc: s.desc, url: pURL(s.name)};
				if(!used){
					used = true;
					sresult.push(snew);
				}
			}
		});
	});

	sresult = sresult.uniq();

	var sTemplate = new Template('<a class="searchitem" href="#page=#{url}" onclick="go(\'#{url}\');Lightview.hide();"><h1>#{name}</h1><p>#{desc}</p></a>');

	var sHTML = '';

	sresult.each(function(s){
		terms.each(function(t){
			s.desc = s.desc.replace(new RegExp("("+t+")","ig"), '<span class="searchhl">$1</span>');
		});
		sHTML = sHTML + sTemplate.evaluate(s);
	});

	if(sresult.size()==0){
		sHTML = '<a class="searchitem" href="javascript:void(0)" onclick="Lightview.hide();"><h1>No results found</h1><p>Sorry, your search query returned no results. Click here to return.</p></a>';
	}

	sHTML = '<div id="searchresultsframe"><h1 class="title">Search Results</h1><span class="sresults"><span class="searched">You searched for <b>' + query + '</b>, returning <b>' + sresult.size() + '</b> results.</span> ' + sHTML + '</span></div>';

	$('searchresults').update(sHTML);


  Lightview.show({
    href: '#searchresults',
    rel: 'inline',
    options: {
      topclose: true,
      autosize: true

    }
  });

	$('searchq').value=''

	
}
}

