// ==============================================================================
// File Name           : Themes.js V 1.0
// Description         : Themes events 
// Author(s)           : Baskaran V
// Date created        : 2009.05.01
// Last reviewed by    : 
// Last date of review : 
// Copyright           : (c) 2008, Sharp Software Development India Pvt Ltd., All rights reserved.
//                       All rights are reserved. Reproduction or transmission in whole or in part, in
//                       any form or by an means, electronic, mechanical or otherwise, is prohibited
//                       without the prior written consent of the copyright owner.

// ==============================================================================


//===================
//Library to find the query string value

function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];

}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; } 
}
function queryString(key){
var page = new PageQuery(window.location.search.replace("%26", "&")); 
return unescape(page.getValue(key)); 
}

function displayItem(key){
if(queryString(key)=='false') 
{
}else{
document.write(queryString(key));
}
}

//==================


//----------->  Dynamic loading Themes <--------------------------

//- query string for First time loading Themes-----
 function GetFromQueryString(key)
  {
	 keyValue = "";
	 if( location.search != "")
	 {
		 ArrQueryString = location.search.replace("?", "").split("&");
		 
		 if(ArrQueryString.length == 1)
		 {
			 keyValue = ArrQueryString[0].split("=")[1];
		 }
		 else if( ArrQueryString.length > 1)
		 {
			 for(qs =0 ; qs < ArrQueryString.length ; qs++)
			 {
				 ArrQs = ArrQueryString[qs].split("=");
				 if(ArrQs[0] == key)
				 {
					 keyValue = ArrQs[1];
					 break;
				 }
			 }
		 }
	 }
	 return keyValue;
 }
 
 selectedTheme = GetFromQueryString("Theme");
 if(selectedTheme != "")
 {
	 setCookie('opt', selectedTheme);
 }
 


//Set Cookie 
function setCookie(c_name,value)
{
	document.cookie= c_name + "=" + value ;
}


//Get Cookie
function getCookie(c_name)
{
	if (document.cookie.length > 0)
	{ 
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
				return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return null
}

function GoToPage(fileName)
{

	switch(fileName)
	{
		case "Preferences": 
				document.location = "preferences.htm" + '?Theme=' + getCookie('opt'); break;
		case "indexing_schedule": 
				document.location = "indexing_schedule.htm" + '?Theme=' + getCookie('opt');break;
		case "index_databases": 
				document.location = "index_databases.htm" + '?Theme=' + getCookie('opt');break;
		case "last_search": 
				document.location = "last_search.htm"+'?Theme='+getCookie('opt');break;
		case "search_criteria_area": 
				document.location = "search_criteria_area.htm" + '?Theme=' + getCookie('opt');break;
		case "search_results": 
				document.location = "search_results.htm" + '?Theme=' + getCookie('opt');break;
		case "folder_selection_dialog": 
				document.location = "folder_selection_dialog.htm" + '?Theme=' + getCookie('opt');break;
		case "search_criteria_help_area": 
				document.location = "search_criteria_help_area.htm" + '?Theme=' + getCookie('opt');break;
		case "default": 		
				//document.location = "default.htm" + '?Theme=' + getCookie('opt');				
				document.location = "default.htm" + '?Theme=' + getCookie('opt') + '&SearchString_link=No';
				break;				
		case "default_search_link":
				document.location = "default.htm" + '?Theme=' + getCookie('opt') + '&SearchString_link=No';
				break;			
		case "index_wizard_step3": 
				document.location = "index_wizard_step3.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_step5": 
				document.location = "index_wizard_step5.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_step6": 
				document.location = "index_wizard_step6.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_incomplete": 
				document.location = "index_wizard_incomplete.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_config_incomplete": 
				document.location = "index_wizard_config_incomplete.htm" + '?Theme=' + getCookie('opt');break;
		case "individual_index_database": 
				document.location = "individual_index_database.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_step1": 
				document.location = "index_wizard_step1.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_step4_config": 
				document.location = "index_wizard_step4_config.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_begin": 
				document.location = "index_wizard_begin.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_step2": 
				document.location = "index_wizard_step2.htm" + '?Theme=' + getCookie('opt');break;
		case "folder_selection_dialog": 
				document.location = "folder_selection_dialog.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_config_complete": 
				document.location = "index_wizard_config_complete.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_config_end": 
				document.location = "index_wizard_config_end.htmindex_wizard_config_incomplete.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_end": 
				document.location = "index_wizard_end.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_init": 
				document.location = "index_wizard_init.htm" + '?Theme=' + getCookie('opt');break;				
		case "index_wizard_partial_complete": 
				document.location = "index_wizard_partial_complete.htm" + '?Theme=' + getCookie('opt');break;
		case "index_wizard_step4": 
				document.location = "index_wizard_step4.htm" + '?Theme=' + getCookie('opt');break;
		case "local_folder_selection_dialog": 
				document.location = "local_folder_selection_dialog.htm" + '?Theme=' + getCookie('opt');break;
		case "search_init": 
				document.location = "search_init.htm" + '?Theme=' + getCookie('opt');break;
		case "search_session_init": 
				document.location = "search_session_init.htm" + '?Theme=' + getCookie('opt');break;


	
	}
}

//Select the Themes
vsc = parseInt(getCookie("opt"))
switch(vsc)
{
	default:
		document.write("<link rel=stylesheet href=style.css>");		
		break;
	case 2:
		document.write("<link rel=stylesheet href=style1.css>");		
		break;
}