function GetVoteCookieValue(sParent, sName, sValue)
{
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (aCookie[i].lastIndexOf(sName)> -1) 
		{
				var aCrumb = aCookie[i].split("=");
				if (sParent == aCrumb[0])
				{ 
					if (sName == aCrumb[1])
					{
						if (aCrumb[2].search(",") > -1)
						{
							var aCrumb2 = aCrumb[2].split(",");
							for (var l=0; l < aCrumb2.length; l++)
							{
								if (aCrumb2[l] == sValue)
									return aCrumb2[l];
							}
						}
						else
						{
							if (aCrumb[2] == sValue)
								return unescape(aCrumb[2]);
						}
					}
					
				}
			//}
		}

	}
	// a cookie with the requested name does not exist
	return null;
}

function CheckCookie(vid)
{
	var voteId = GetVoteCookieValue("vote","vID",vid);
	if (voteId)
	{
		if (!isNaN(voteId))
		{
			var coll = document.all.item("voteSelect" + vid);
			if (coll)
			{
				for (var i=0; i<coll.length; i++)
				{
					coll(i).disabled = true;
				}
			}
			var votePaltrink = document.all.item("votePart" + vid);
			if (votePaltrink)
				votePaltrink.removeAttribute("href");
		}
		else
		{
			alert("voteId is not a No. = " + voteId);
		}
	}
}

function RegExpTest(strInput)
{
  var regExpPattern = /\S{10}/g;    //Create regular expression pattern to check for long words
  var matchesArray;
  var strReturn = "";
  var firstIndex = 0;
  //var ver = Number(ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion())
  while ((matchesArray = regExpPattern.exec(strInput)) != null)
  {
     //alert(arr.index + "-" + arr.lastIndex + "-\s-" + arr + "<br>");
     strReturn += strInput.substring(firstIndex,matchesArray.lastIndex) + "&#32;";
     firstIndex = matchesArray.lastIndex;
  }
  strReturn += strInput.substring(firstIndex,strInput.length);
  regExpPattern = /</g;  //Create regular expression pattern to check for <
  strReturn = strReturn.replace(regExpPattern, "&lt;");    //Replace < character with "&lt;".
  
  regExpPattern = />/g;  //Create regular expression pattern to check for <
  strReturn = strReturn.replace(regExpPattern, "&gt;");    //Replace > character with "&gt;"
  
  regExpPattern = /\r\n/g;  //Create regular expression pattern to check for a new line character
  strReturn = strReturn.replace(regExpPattern, "<br>");    //Replace new line character with "<br>".
  return strReturn ;
}

function RegExpEmailTest(strInput)
{
  //The corresponding regular expression for text would be
  //var regExpPattern = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
  //The corresponding regular expression for multilingual text would be
  var regExpPattern = /(\w+|\W+)([-+.](\w+|\W+))*@(\w+|\W+)([-.](\w+|\W+))*\.(\w+|\W+)([-.](\w+|\W+))*/;    //Create regular expression pattern to check email expression
  if (regExpPattern.test(strInput))
	return true;
  else
	return false;

}

function CheckJS(strInput)
{
	var found= true;
	while (found) 
	{
		strInput = strInput.replace("<","&lt;");
		strInput = strInput.replace(">","&gt;");
		if ((strInput.search("<") > -1) || (str.search(">") > -1))
			found=true;
		else
		found=false;
	}
	
	return strInput; 
}

function openLogin(url,urlParam)
{
	var Link	
	Link = url + escape(urlParam) ;	
	//alert(Link)
	window.open(Link ,"","height=220,width=465,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

function openLoginWithRandom(url,urlParam,type)
{
	var Link
	var thisdate = new Date();
	
	Link = url + escape(urlParam + "&rnd=" + Math.random() + "&dt=" + thisdate.getTime())  ;	

	if (type==1)
		{
			window.open(Link ,"","height=220,width=465,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
		}
	else
		{
			window.location.href=urlParam + "&rnd=" + Math.random() + "&dt=" + thisdate.getTime();
		}	
}


function checkValidations(txtContent)
{
	if(window.document.all.item(txtContent).value == '' )
	{
		alert("Please enter the text to search for ");
		return false;
	}
	else
	{
		return true;
	}
}

//This will remove the passed variable from the passed query string
function removeQueryVarFromString(query ,variable)
{
	var newQuery = "";
	
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++)
	{
		var pair = vars[i].split("=");
		if (pair[0] != variable)
		{
			if(i!=0)
			{
				newQuery += "&";
			}
			
			newQuery += vars[i];
		}
	}	
	return newQuery;
}

function OpenVoteUrl(vid,ansid)
{
	if(ansid==-1)
		return;
	
	var strQS = document.location.search.substring(1);
	strQS = removeQueryVarFromString(strQS,"vid");
	strQS = removeQueryVarFromString(strQS,"ansid");
	
	strNewLink = window.location.toString().replace( window.location.search,"" )
	
	document.location = strNewLink +"?" + strQS + "&vid=" + vid + "&ansid=" + ansid;
		
	/*if (strHref.search("&") == "-1") {
		
		document.location = document.location.href + "?vid=" + vid + "&ansid=" + ansid
	}
	else {
		document.location = document.location.href + "&vid=" + vid + "&ansid=" + ansid
	}*/
	
	/*
	if (type == 0)
	{
		if ((document.all.yourAnswer.value > 0) && (document.all.yourVote.value == vid))
		{
			url = url + "&yourAnswer=" + document.all.yourAnswer.value;
			var coll = document.all.item("voteSelect" + vid);
			if (coll)
			{
				for (var i=0; i<coll.length; i++)
				{
					coll(i).checked = false;
					coll(i).disabled = true;
				}
			}
			var votePaltrink = document.all.item("votePart" + vid);
			if (votePaltrink)
				votePaltrink.removeAttribute("href");
			document.all.yourAnswer.value = 0;
			window.open(url,"","height=333,width=590,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");	
		}
		
	}
	else
		window.open(url,"","height=333,width=590,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");	
	*/	
}

function submit(voteID,actionType)
{
	if(actionType == 1)
		voteForm.actionType.value = actionType;
	else
		voteForm.actionType.value = 0;
	voteForm.dispType.value = 1;
	voteForm.voteID.value = voteID;
	voteForm.submit();
}

function OpenVote(path)
{
	window.open(path,"","height=333,width=590,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

function voteHome()
{
	if (window.opener)
	{
		window.opener.top.location.href = "/English/Polls/Polls";
		window.opener.top.focus();
	}
	else
		window.location.href = "/English/Polls/Polls";
}

function sendVote(VoteLink)
{
	window.open("/gateway/aspx/sendArticle.aspx?EML="+VoteLink,"","height=450,width=590");
}

function openAnalysis(VoteLink)
{
	if (window.opener)
		window.opener.top.location.href = VoteLink;
	else
		window.location.href = VoteLink;
}

function OpenDG(paramStr)
{
	window.navigate("/NR/exeres/34A8E2E7-6048-4017-ACC7-A03A062DC347.htm?" + paramStr);
}


function checkValidations(txtContent)
{
	if(window.document.all.item(txtContent).value == '' )
	{
		alert("Please enter the text to search for");
		return false;
	}
	else
	{
		return true;
	}
}

function checkNewsValidations(txtNewsSearchContent)
{
	if(window.document.all.item(txtNewsSearchContent).value == "" )
	{
		alert("Please enter the text to search for");
		return false;
	}
	else
	{
		return true;
	}
}
function checkAllValidations(btnID)
{
	if(window.document.all.item(btnID).value == '' )
		{
			alert('Please enter the text to search for');
				return false;
         }
         else
         {
			return true;
         }
}
function openWindowOnFocus(strURL, strWinTarget, strWinFeatures) 
{
	var pWindow = window.top.open(strURL, strWinTarget, strWinFeatures);
	if (pWindow)
		pWindow.focus();
}

/*SHEARCH SERVICE */
//================================
// ##when the selection changes on the Main topics list, then the items in the Sub Topics should change
//================================
function lstMainTopics_onchange(ddlMainTopics, ddlSubTopics,hdnSubTopicsXml)
{
	var oMainTopicsList = document.all.item(ddlMainTopics)
	var oSubTopicsList = document.all.item(ddlSubTopics)
	if (oMainTopicsList.selectedIndex > -1)
	{
		LoadSubTopics(oMainTopicsList.options(oMainTopicsList.selectedIndex).value,0,ddlSubTopics,hdnSubTopicsXml);
	}
	else
	{
		oSubTopicsList.innerHTML = ""
	}
	
}

function lstSubTopics_onchange(ddlSubTopics, hdnSubTopicsSel, hdnSubTopicsSelText)
{

	var oSubTopicsList = document.all.item(ddlSubTopics)
	var ohdnObj = document.all.item(hdnSubTopicsSel)
	var ohdnObjtext = document.all.item(hdnSubTopicsSelText)
	

	if (oSubTopicsList.selectedIndex > -1)
	{
		ohdnObj.value = oSubTopicsList.options(oSubTopicsList.selectedIndex).value;
		ohdnObjtext.value = oSubTopicsList.options(oSubTopicsList.selectedIndex).innerText;
	}
	else
	{
		ohdnObj.vaue= "00";
		ohdnObjtext.value = "";
	}
}

//================================
// ## This function loads the Main topics list with the Main Topics
// ##PARAM intSelectedItemID: the item that will be selected in the list.
//================================
function LoadMainTopics(intSelectedItemID)
{

var oList = document.getElementById("<%=ddlMainTopics.ClientID%>")
var XMLDoc=new ActiveXObject("Microsoft.XMLDOM")
XMLDoc.async="false"
XMLDoc.loadXML(document.getElementById ("<%=hdnMainTopicsXml.ClientID%>").value );
//Clear the list
oList.innerHTML = ""; 

var ElemList = XMLDoc.getElementsByTagName("Item");
  for (var i=0; i<= ElemList.length -1; i++)
  {
	var oOption = document.createElement("OPTION");
	oList.options.add(oOption);
	oOption.innerText = ElemList.item(i).attributes(1).value;
	oOption.value = ElemList.item(i).attributes(0).value;
	if (oOption.value == intSelectedItemID) 
		{
			oOption.selected = true; 
		}
  }
  
}

//================================
// ##This function loads the Sub topics list with the Sub Topics
// ##PARAM intMainTopicID: The ID of the parent Main topic that will be used to load specific sub topics into the sub topics list
// ##PARAM intSelectedItemID: the item that will be selected in the list.
//================================
function LoadSubTopics(intMainTopicID, intSelectedItemID, ddlSubTopics ,hdnSubTopicsXml)
{

var oList = document.all.item(ddlSubTopics)
var XMLDoc=new ActiveXObject("Microsoft.XMLDOM")
XMLDoc.async="false"
XMLDoc.loadXML(document.all.item(hdnSubTopicsXml).value);
//clear the list
oList.innerHTML = ""; 
//add the elements from the XML to the list
var ElemList = XMLDoc.getElementsByTagName("Item");
var oOption = document.createElement("OPTION");
oList.options.add(oOption);
oOption.innerText = "All";
oOption.value = "00";

  for (var i=0; i<= ElemList.length -1; i++)
  {
	if (intMainTopicID == ElemList.item(i).attributes(2).value)
	{
		var oOption = document.createElement("OPTION");
		oList.options.add(oOption);
		oOption.innerText = ElemList.item(i).attributes(1).value;
		oOption.value = ElemList.item(i).attributes(0).value;
		if (oOption.value == intSelectedItemID) 
			{
				oOption.selected = true; 
			}
	}
	
  }

}

//================================
// ##when the selection changes on the Sites list, then the items in the Channels list should change
//================================

function lstSites_onchange(ddlSite,ddlChannel,ddlSection,hdnChannelsXml,hdnSectionsXml)
{

	var oSitesList = document.all.item(ddlSite)
	var oChannelsList = document.all.item(ddlChannel)
	var oSectionsList = document.all.item(ddlSection)
	if (oSitesList.selectedIndex > -1)
	{
		LoadChannels(oSitesList.options(oSitesList.selectedIndex).value,0,ddlChannel,hdnChannelsXml);
		LoadSections(0,0,ddlSection,hdnSectionsXml)
	}
	
}
function lstChannels_onchange(ddlChannel,hdnChannelSel,hdnChannelSelText,hdnSectionsXml,ddlSection)
{
	var ochannelsList = document.all.item(ddlChannel)
	var ohdnObj = document.all.item(hdnChannelSel)
	var ohdnObjtext = document.all.item(hdnChannelSelText)
	if (ochannelsList.selectedIndex > -1)
	{
		ohdnObj.value = ochannelsList.options(ochannelsList.selectedIndex).value;
		ohdnObjtext.value = ochannelsList.options(ochannelsList.selectedIndex).innerText;
		LoadSections(ochannelsList.options(ochannelsList.selectedIndex).value,0,ddlSection,hdnSectionsXml);
	}
	else
	{
		ohdnObj.vaue= "00"
		ohdnObjtext.value = ""
	}

}

function lstSections_onchange(ddlSection,hdnSectionSel,hdnSectionSelText)
{
	var oSectionList = document.all.item(ddlSection)
	var ohdnObj = document.all.item(hdnSectionSel)
	var ohdnObjtext = document.all.item(hdnSectionSelText)
	if (oSectionList.selectedIndex > -1)
	{
		ohdnObj.value = oSectionList.options(oSectionList.selectedIndex).value;
		ohdnObjtext.value = oSectionList.options(oSectionList.selectedIndex).innerText;
	}
	else
	{
		ohdnObj.vaue= "00"
		ohdnObjtext.value = ""
	}
}


//================================
// ##This function loads the Channelst list
// ##PARAM intSiteID: The ID of the parent Site that will be used to load specific Channels
// ##PARAM intChannelID: the item that will be selected in the list.
//================================
function LoadChannels(intSiteID, intChannelID, ddlChannel,hdnChannelsXml)
{
var oList = document.all.item(ddlChannel)
var XMLDoc=new ActiveXObject("Microsoft.XMLDOM")
XMLDoc.async="false"
XMLDoc.loadXML(document.all.item(hdnChannelsXml).value );
//clear the list
oList.innerHTML = ""; 
//add the elements from the XML to the list
var ElemList = XMLDoc.getElementsByTagName("Item");
var oOption = document.createElement("OPTION");
oList.options.add(oOption);
oOption.innerText = "All";
oOption.value = "00";

  for (var i=1; i<= ElemList.length -1; i++)
  {
	if (intSiteID == ElemList.item(i).attributes(2).value)
	{
		var oOption = document.createElement("OPTION");
		oList.options.add(oOption);
		oOption.innerText = ElemList.item(i).attributes(1).value;
		oOption.value = ElemList.item(i).attributes(0).value;
		if (oOption.value == intChannelID) 
			{
				oOption.selected = true; 
			}
	}
	
  }

}
//================================
// ##This function loads the Sub topics list with the Sub Topics
// ##PARAM intMainTopicID: The ID of the parent Main topic that will be used to load specific sub topics into the sub topics list
// ##PARAM intSelectedItemID: the item that will be selected in the list.
//================================
function LoadSections(intSubTopicID, intSelectedItemID,ddlSection ,hdnSectionsXml)
{

var oList = document.all.item(ddlSection)
var XMLDoc=new ActiveXObject("Microsoft.XMLDOM")
XMLDoc.async="false"
XMLDoc.loadXML(document.all.item(hdnSectionsXml).value);
var ElemList = XMLDoc.getElementsByTagName("Item");
//clear the list
oList.innerHTML = ""; 
//add the elements from the XML to the list  
var oOption = document.createElement("OPTION");
oList.options.add(oOption);
oOption.innerText = "All";
oOption.value = "00";

	for (var i=1; i<= ElemList.length -1; i++)
	{
		if (intSubTopicID == ElemList.item(i).attributes(2).value)
		{
			var oOption = document.createElement("OPTION");
			oList.options.add(oOption);
			oOption.innerText = ElemList.item(i).attributes(1).value;
			oOption.value = ElemList.item(i).attributes(0).value;
			if (oOption.value == intSelectedItemID) 
				{
					oOption.selected = true; 
				}	
		}
	}

}

function CheckAll(AllFlag,chkContent,chkHeadline,chkMainSummary,chkSecondarySummary)
{
	if (window.document.all.item(AllFlag).checked == 1)
	{
		window.document.all.item(chkContent).checked = 1
		window.document.all.item(chkContent).disabled = 1
		window.document.all.item(chkHeadline).checked = 1
		window.document.all.item(chkHeadline).disabled = 1
		window.document.all.item(chkMainSummary).checked = 1
		window.document.all.item(chkMainSummary).disabled = 1
		window.document.all.item(chkSecondarySummary).checked = 1
		window.document.all.item(chkSecondarySummary).disabled = 1
	}
	else
	{
		window.document.all.item(chkContent).disabled = 0
		window.document.all.item(chkHeadline).disabled = 0
		window.document.all.item(chkMainSummary).disabled = 0
		window.document.all.item(chkSecondarySummary).disabled = 0
	}
 }
 

function checkCountries(rblGeoOptions,ddlCountries1,ddlCountries2,ddlCountries3,ddlCountries4,ddlCountries5,ddlCountries6)
{
	var rblGeoOptionsid0 = rblGeoOptions + "_0"
	var rblGeoOptionsid1 = rblGeoOptions + "_1"
	if(window.document.all.item(rblGeoOptionsid0).checked == true)
	{
		window.document.all.item(ddlCountries1).disabled = true;
		window.document.all.item(ddlCountries2).disabled = true;
		window.document.all.item(ddlCountries3).disabled = true;
		window.document.all.item(ddlCountries4).disabled = true;
		window.document.all.item(ddlCountries5).disabled = true;
		window.document.all.item(ddlCountries6).disabled = true;
	}
	else
	{
		if(window.document.all.item(rblGeoOptionsid1).checked == true)
		{
			window.document.all.item(ddlCountries1).disabled = false;
			window.document.all.item(ddlCountries2).disabled = false;
			window.document.all.item(ddlCountries3).disabled = false;
			window.document.all.item(ddlCountries4).disabled = true;
			window.document.all.item(ddlCountries5).disabled = true;
			window.document.all.item(ddlCountries6).disabled = true;
		}
		else
		{
			window.document.all.item(ddlCountries1).disabled = true;
			window.document.all.item(ddlCountries2).disabled = true;
			window.document.all.item(ddlCountries3).disabled = true;
			window.document.all.item(ddlCountries4).disabled = false;
			window.document.all.item(ddlCountries5).disabled = false;
			window.document.all.item(ddlCountries6).disabled = false;
		}
	}
}

function checkDatelists(rblSearchPeriod,ddlFromDay,ddlFromMonth,ddlFromYear,ddlToDay,ddlToMonth,ddlToYear,ddlSpecifyPeriod)
{
	var rblSearchPeriodId0 = rblSearchPeriod + "_0"
	var rblSearchPeriodId1 = rblSearchPeriod + "_1"
	if(window.document.all.item(rblSearchPeriodId0).checked == true)
	{
		window.document.all.item(ddlFromDay).disabled = true;
		window.document.all.item(ddlFromMonth).disabled = true;
		window.document.all.item(ddlFromYear).disabled = true;
		window.document.all.item(ddlToDay).disabled = true;
		window.document.all.item(ddlToMonth).disabled = true;
		window.document.all.item(ddlToYear).disabled = true;
		window.document.all.item(ddlSpecifyPeriod).disabled = false;
	}
	else
	{
		window.document.all.item(ddlFromDay).disabled = false;
		window.document.all.item(ddlFromMonth).disabled = false;
		window.document.all.item(ddlFromYear).disabled = false;
		window.document.all.item(ddlToDay).disabled = false;
		window.document.all.item(ddlToMonth).disabled = false;
		window.document.all.item(ddlToYear).disabled = false;
		window.document.all.item(ddlSpecifyPeriod).disabled = true;
	}
}

function validateText(txtContent,rblSearchPeriod,ddlFromYear,ddlFromMonth,ddlFromDay,ddlToYear,ddlToMonth,ddlToDay)
{
	var re1 = /\*/gi;
	var re2 = /\#/gi;
	var re3 = /\!/gi;
	var re4 = /\@/gi;
	var re5 = /\%/gi;
	var re6 = /\$/gi;
	var re7 = /\^/gi;
	var re8 = /\&/gi;
	var searchStr = window.document.all.item(txtContent).value;
	
	if((searchStr.length < 1) || (searchStr == " "))
	{
		alert('Please enter a text to search for');
		window.document.all.item(txtContent).focus();
		return false;
	}
	else
	{
		if((searchStr.search(re1) != -1)|| (searchStr.search(re2)!= -1) || (searchStr.search(re3)!= -1) || (searchStr.search(re4)!= -1) || (searchStr.search(re5)!= -1) || (searchStr.search(re6)!= -1)|| (searchStr.search(re7)!= -1)|| (searchStr.search(re8)!= -1))
		{
			alert('Please dont use special characters');
			window.document.all.item(txtContent).focus();
			return false;
		}
		else
		{
			if (ValidateDate(rblSearchPeriod,ddlFromYear,ddlFromMonth,ddlFromDay,ddlToYear,ddlToMonth,ddlToDay))
			{
				return true;
			}
			else
			{
				alert('please enter the date in a well format');
				return false;
			}
			
		}
	}
}

function ValidateDate(rblSearchPeriod,ddlFromYear,ddlFromMonth,ddlFromDay,ddlToYear,ddlToMonth,ddlToDay)
{
	var rblSearchPeriodId1 = rblSearchPeriod + "_1"
	if (window.document.all.item(rblSearchPeriodId1).checked)
	{
		var fYear = window.document.all.item(ddlFromYear).value
		var fMonth = window.document.all.item(ddlFromMonth).value
		var fDay = window.document.all.item(ddlFromDay).value
		var fDate = new Date(fYear,fMonth,fDay);
		var toYear = window.document.all.item(ddlToYear).value
		var toMonth = window.document.all.item(ddlToMonth).value
		var toDay = window.document.all.item(ddlToDay).value
		var toDate = new Date(toYear,toMonth,toDay);
		if (fDate > toDate)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}

/*************************** DISCUSSION ********************************/

function drawPages(pURL,totRecords,loc,discid,poolID,pageGroup,NoPageGroups,pageSize,appPath,isHeader)
{
	//alert( pURL + " -------- " + totRecords + " -------- " + loc + " -------- " + discid + " -------- " + poolID + " -------- " + pageGroup + " -------- " + NoPageGroups + " -------- " + pageSize + " -------- " + appPath)
	if (totRecords!=0)
	{
	var text = "",page,j=0;
	var totPages = Math.ceil(totRecords/pageSize);
	var counter=0;
	text= "<table class=\"CommentsPagination\" cellSpacing='0' cellPadding='2' border='0'><tr>";
	
	
	//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	//''''''' Previous 10''''''''''''''''''''''''''''''''''''''''''
	if(pageGroup == 1)
	{
		text += "<td align=\"center\" class=\"CommentsPagination\" >Previous " + NoPageGroups + "</td><td>|</td>";
		j=0;
	}
	else 
	if (pageGroup > 1)
	{
		j= (pageGroup * NoPageGroups) -NoPageGroups+ 1;
		text += "<td align=\"center\" class=\"CommentsPagination\" ><a align=\"center\" href=\"" + pURL + "&amp;choice=3&dgDiscID=" + discid + "&dgPoolID=" + poolID + "&loc=" + (j-1) + "&pagesize=" + pageSize + "&group=" + (pageGroup-1)  + "\">Previous "+ NoPageGroups +"</a></td><td>|</td>";
	}
	//''''''''''End Previous 10'''''''''''''''''''''''''''''''''''''''''''''''''''
	
	
	
	
	//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	//''''''' Previous'''''''''''''''''''''''''''''''''''''''''''''
	if((loc % NoPageGroups)==1)
	{
		text += "<td align=\"center\" class=\"CommentsPagination\" >Previous</td><td>|</td>";
	}
	else 
	{
		text += "<td align=\"center\" class=\"CommentsPagination\" ><a align=\"center\" href=\"" + pURL + "&amp;choice=3&dgDiscID=" + discid + "&dgPoolID=" + poolID + "&loc=" + (loc-1) + "&pagesize=" + pageSize + "&group=" + pageGroup  + "\">Previous</a></td><td>|<td>";
	}
	//''''''''''End Previous 10'''''''''''''''''''''''''''''''''''''''''''''''''''
	
	
	
	//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	//''''''' Numbers''''''''''''''''''''''''''''''''''''''''''''''

	//text += "<td align=\"left\" class=\"CommentsPagination\" >";
	for (var i=j;(i<=totPages);i++)
	{
		if(i==0)
			++i;
		page = i;
		counter++;
		if (page == loc)
		{
			if (loc==totPages)	
				text += "<td align=\"center\" class=\"CommentsPagination\" >" + loc + "  </td>";
			else
				{
				text += "<td align=\"center\" class=\"CommentsPagination\" >" + loc + "</td><td class=\"CommentsPaginationVLine\">|</td>";
				}
		}
			
		else
			text += "<td align=\"center\" class=\"CommentsPagination\"><a align=\"left\" href=\"" + pURL + "&amp;choice=3&dgDiscID=" + discid + "&dgPoolID=" + poolID + "&loc=" + page + "&pagesize=" + pageSize + "&group=" + pageGroup + "\">" + page + "</a></td><td align=\"center\" class=\"CommentsPaginationVLine\">|</td>";
		
		if (counter>=(NoPageGroups))
			break;		
	}
	text = text.slice(0,text.length-7);
	//text += "</td>";
	//'''''''' End Numbers'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

	
	

	//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	//''''''' Next''''''''''''''''''''''''''''''''''''''''''
	if((loc % NoPageGroups)==0 ||loc == totPages)
	{
	
		text += "<td>|</td><td align=\"center\" dir=\"ltr\" class=\"CommentsPagination\" >Next</td>";
	}
	else
		text += "<td>|</td><td align=\"center\" dir=\"ltr\" class=\"CommentsPagination\" ><a align=\"left\" href=\"" + pURL + "&amp;choice=3&dgDiscID=" + discid + "&dgPoolID=" + poolID + "&loc=" + (loc+1) + "&pagesize=" + pageSize + "&group=" + pageGroup  + "\" >Next</a></td>";

	//''''''' End Next''''''''''''''''''''''''''''''''''''''''''

	
	
	
	//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	//''''''' Next 10''''''''''''''''''''''''''''''''''''''''''
	if((totRecords <= pageSize) || (totPages <= (pageGroup * NoPageGroups)))
	{
		text += "<td>|</td><td align=\"center\" dir=\"ltr\" class=\"CommentsPagination\" >Next "+ NoPageGroups +"</td>";
	}
	else
	if(totPages > (pageGroup * NoPageGroups))
		text += "<td>|</td><td align=\"center\" dir=\"ltr\" class=\"CommentsPagination\" ><a align=\"left\" href=\"" + pURL + "&amp;choice=3&dgDiscID=" + discid + "&dgPoolID=" + poolID + "&loc=" + (page+1) + "&pagesize=" + pageSize + "&group=" + (pageGroup+1)  + "\" >Next "+ NoPageGroups +"</a></td>";

	//''''''' End Next 10''''''''''''''''''''''''''''''''''''''''''





	text +="</tr></table>"
	if (isHeader==1)
	{
		text +="<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td height='1' bgcolor='#CCCCCC'></td></tr></table>";
	}
	document.write(text);
	}
}





function drawArchivePagesSearch(totRecords,loc,url,pageGroup,NoPageGroups,pageSize)
{
	var text = "",page,j=0;	
	var totPages = Math.ceil(totRecords/pageSize);
	//alert("totRecords = " + totRecords);
	//alert("pageGroup = " + pageGroup);
	//alert("url = " + url);
	//alert("loc = " + loc);
	var counter=0;
	if(pageGroup == 1)
	{
		//text += "<td align=\"left\" dir=\"ltr\" ><img src=\"" + appPath + "/images/previous.gif\" align=\"absmiddle\" border=\"0\">&nbsp;<label class=\"dgTableHeaderLink\">&#1575;&#1604;&#1587;&#1575;&#1576;&#1602;</label></td>";
		j=0;
	}
	else 
	if (pageGroup > 1)
	{
		j = (pageGroup * NoPageGroups) - NoPageGroups+ 1;
		//text += "<td align=\"left\" dir=\"ltr\"><a align=\"center\" href=\"" + url + "&sloc=" + (j-1) + "&pagesize=" + pageSize + "&group=" + (pageGroup-1)  + "\"><img src=\"" + appPath + "/images/previous.gif\" border=\"0\" align=\"absmiddle\"><label class=\"dgTableHeaderLink\">&#1575;&#1604;&#1587;&#1575;&#1576;&#1602;</label></a></td>";
	}
	text += "<td align=\"left\" class=\"archivePaging\" dir=\"ltr\">";
	//alert("j = " + j);
	//alert("totPages = " + totPages);
	for (var i=j;(i<=totPages);i++)
	{
		if(i==0)
			++i;
		page = i;
		//alert("page = " & page)
		counter++;
		if (page == loc)
			text += "<label class=\"archivePaging\">" + loc + "</label>&nbsp;&nbsp;";
		else
			text += "<a  class=\"archivePaging\" align=\"center\" href=\"" + url + "&sloc=" + page + "&pagesize=" + pageSize + "&group=" + pageGroup + "\">" + page + "</a>&nbsp;&nbsp;";
		
		if (counter>=(NoPageGroups))
			break;		
	}

	text = text.slice(0,text.length-7);
	text += "</td>";
	
	if(pageGroup == 1)
	{
		text += "<td align=\"left\" dir=\"ltr\" ><label class=\"archivePagingGroups2\">&#1575;&#1604;&#1587;&#1575;&#1576;&#1602;</label>";
	}
	else
	if (pageGroup > 1)
	{
		text += "<td align=\"left\" dir=\"ltr\"><a  class=\"archivePagingGroups\" align=\"center\" href=\"" + url + "&sloc=" + (j-1) + "&pagesize=" + pageSize + "&group=" + (pageGroup-1)  + "\">&#1575;&#1604;&#1587;&#1575;&#1576;&#1602;</a>";
	}
	
	if((totRecords <= pageSize) || (totPages <= (pageGroup * NoPageGroups)))
	{
		text += "&nbsp;&nbsp;<label class=\"archivePagingGroups2\"> Next</label>";
	}
	else
	if(totPages > (pageGroup * NoPageGroups))
		text += "&nbsp;&nbsp;<a class=\"archivePagingGroups\" align=\"center\" href=\"" + url + "&sloc=" + (page+1) + "&pagesize=" + pageSize + "&group=" + (pageGroup+1)  + "\"> Next</a></td>";

	//text = text.slice(0,text.length-7);
	document.write(text);
	
}


function drawPagesSearch(totRecords,loc,url,pageGroup,NoPageGroups,pageSize,appPath)
{
	var text = "",page,j=0;	
	var totPages = Math.ceil(totRecords/pageSize);
	
	var counter=0;
	if(pageGroup == 1)
	{
		text += "<td align=\"left\" dir=\"ltr\" ><img src=\"" + appPath + "/images/previous.gif\" align=\"absmiddle\" border=\"0\">&nbsp;<label class=\"dgTableHeaderLink\">Previous</label></td>";
		j=0;
	}
	else 
	if (pageGroup > 1)
	{
		j= (pageGroup * NoPageGroups) -NoPageGroups+ 1;
		text += "<td align=\"left\" dir=\"ltr\"><a align=\"center\" href=\"" + url + "&sloc=" + (j-1) + "&pagesize=" + pageSize + "&group=" + (pageGroup-1)  + "\"><img src=\"" + appPath + "/images/previous.gif\" border=\"0\" align=\"absmiddle\"><label class=\"dgTableHeaderLink\">Previous</label></a></td>";
	}
	text += "<td align=\"center\" dir=\"ltr\">";
	for (var i=j;(i<=totPages);i++)
	{
		if(i==0)
			++i;
		page = i;
		
		counter++;
		if (page == loc)
			text += "<label class=\"dgTableHeader\">" + loc + "</label>&nbsp;|&nbsp;";
		else
			text += "<a class=\"dgTableHeaderLink\" align=\"center\" href=\"" + url + "&sloc=" + page + "&pagesize=" + pageSize + "&group=" + pageGroup + "\">" + page + "</a>&nbsp;|&nbsp;";
		
		if (counter>=(NoPageGroups))
			break;		
	}

	text = text.slice(0,text.length-7);
	text += "</td>";
	if((totRecords <= pageSize) || (totPages <= (pageGroup * NoPageGroups)))
	{
		text += "<td align=\"left\" dir=\"ltr\" ><img src=\"" + appPath + "/images/next.gif\" border=\"0\" align=\"absmiddle\"  hspace=\"7\"><label class=\"dgTableHeaderLink\"> Next</label></td>";
	}
	else
	if(totPages > (pageGroup * NoPageGroups))
		text += "<td align=\"left\" dir=\"ltr\" ><a  align=\"center\" href=\"" + url + "&sloc=" + (page+1) + "&pagesize=" + pageSize + "&group=" + (pageGroup+1)  + "\"><img src=\"" + appPath + "/images/next.gif\" align=\"absmiddle\" border=\"0\"  hspace=\"7\"><label class=\"dgTableHeaderLink\"> Next</label></a></td>";

	//text = text.slice(0,text.length-7);
	document.write(text);
	
}

function drawDropList(dropName,start,size,selected)
{
	var i, dropTxt;
	dropTxt = "<SELECT runat=\"server\" ID=\""+dropName+"\" NAME=\""+dropName+"\">\n\r";
	for(i=start;i<=size;i++)
		{
			if(i == selected)
				dropTxt += "<option selected value=\""+i+"\">"+i+"</option>";
			else
				dropTxt += "<option value=\""+i+"\">"+i+"</option>";
		}
	dropTxt += "</select>";	
	document.write(dropTxt);
}

/*************************** DISCUSSION ********************************/
function showhide(msg)
{
	var item = document.all.item("msg"+msg);
	var iImage = document.all.item("img"+msg);
	if (item.style.display == "block")
	{
		iImage.src = "/News/KServices" + "/images/plus.gif";
		item.style.display = "none";
	}
	else
	{
		iImage.src = "/News/KServices" + "/images/minus.gif";
		item.style.display = "block";
	}
}


/**************************	CHANNEL ARCHIVE SEARCH ************************/
function radioList_action(listID, txtID)
{
	var listId0 = listID + "_0";
	var listId1 = listID + "_1";
	
	if (window.document.all.item(listId0).checked)
	{
		window.document.all.item(txtID).disabled = true;
		window.document.all.item(txtID).style.backgroundColor = "Gainsboro";
	}
	else
	{
		window.document.all.item(txtID).disabled = false;
		window.document.all.item(txtID).style.backgroundColor = "white";
	}
	
}

function validateArchive(listID, txtID, yearsID)
{
	var listId0 = listID + "_0";
	var listId1 = listID + "_1";
	
	if (window.document.all.item(yearsID).selectedIndex == 0)
	{
		alert("please enter the year");
		return false;
	}
	
	if (window.document.all.item(listId1).checked)
	{
		if (window.document.all.item(txtID).value == "")
		{
			alert("Please enter the subject to search for");
			window.document.all.item(txtID).focus();
			return false;
		}
	}
	return true;
}

function validateReportsArchive(txtID,listID)
{
	var listId0 = listID + "_0";
	var listId1 = listID + "_1";
	
	if (window.document.all.item(listId1).checked)
	{
		if (window.document.all.item(txtID).value == "")
		{
			alert("Please enter the subject to search for");
			window.document.all.item(txtID).focus();
			return false;
		}
	}
	return true;
}


function validateTextInput(txtObjId)
{

return true
}

function getMonthName(monthNo)
{
	
	var monthsNames = new Array 
	monthsNames[1] = "January" ; 
	monthsNames[2] = "February" ; 
	monthsNames[3] = "March" ; 
	monthsNames[4] = "April" ; 
	monthsNames[5] = "May" ; 
	monthsNames[6] = "June" ; 
	monthsNames[7] = "July" ; 
	monthsNames[8] = "August" ; 
	monthsNames[9] = "September" ; 
	monthsNames[10] = "October" ; 
	monthsNames[11] = "November" ; 
	monthsNames[12] = "Desember" ; 

	document.write(monthsNames[parseInt(monthNo)]);
}	

function enableList(listID, selIndex)
{
	var selNo = window.document.all.item(selIndex).selectedIndex;
	if (selNo == 0)
	{
		window.document.all.item(listID).disabled = true;
	}
	else
	{
		window.document.all.item(listID).disabled = false;
	}
}

// check empty spaces if empty return false if not return true
function LTrim(str)
{
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    // We have a string with leading blank(s)...

    var j=0, i = s.length;

    // Iterate from the far left of string until we
    // don't have any more whitespace...
    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;


    // Get the substring from the first non-whitespace
    // character to the end of the string...
    s = s.substring(j, i);
  }

  return s;
}

function RTrim(str)
{
  // We don't want to trip JUST spaces, but also tabs,
  // line feeds, etc.  Add anything else you want to
  // "trim" here in Whitespace
  var whitespace = new String(" \t\n\r");
  var s = new String(str);

  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    // We have a string with trailing blank(s)...

    var i = s.length - 1;       // Get length of string

    // Iterate from the far left of string until we
    // don't have any more whitespace...
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;


    // Get the substring from the front of the string to
    // where the last non-whitespace character is...
    s = s.substring(0, i+1);
  }

  return s;
}

function fnEmptyField (strValue)
{  
	strValue = RTrim(LTrim(strValue));
	if (strValue == "" )
    	return false;
    else
		return true;		
     	    
    }
                   	
function postFeedbackVal(name, email, country, comments)
{
	var url = "/Channel/KServices/SupportPages/postFeedback/postFeedbackAction.htm";
	if (document.all.txtEmail.value != "")
	{
		if(!(CheckEmail(document.all.txtEmail.value)))
		{
			if(!(RegExpEmailTest(document.all.txtEmail.value)))
			{
				alert("please enter the email address in a well formmate")
				document.all.txtEmail.focus();
				return false;
			}
		}	
	}
	// check if txtComments empty or not
	var strComment
	strComment = document.all.txtComments.value
	for (var i=0; i < strComment.length; i++)
            {
				if (strComment.charAt(i) != "<" )
					strComment = strComment.replace("<","&lt;");
            }
    //strComment = strComment.replace("<","&lt;");
    document.all.txtComments.value = strComment;
	if (!fnEmptyField(strComment))
	{
		alert("Please enter comment");
		document.all.txtComments.focus();
		return false;
	}	
	window.open(url,"","height=333,width=590,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");	
	return true;
	
}
 

function CheckEmail(checkValue)
{
	var allValid = true;
	if (checkValue.indexOf("@")<=0 || checkValue.indexOf("@") == checkValue.length-1 || checkValue.indexOf(".") == checkValue.length-1)
	allValid = false;
	return allValid; 
}
 