<!--

var ajax;
var urlProtocol = (("https:" == document.location.protocol) ? "https://www." : "http://www.");
var url = urlProtocol+'kids-list.com/KidsListServices.asmx';
var actId = '';
var catId = '';
var area = '';
var map = null;
var zipSearched;

/* Virtual Earth Controls */

function GetMap(zipCode) {
	if (!map) {
		map = new VEMap('myMap');            
		map.LoadMap();     
	}
	try {          
		zipSearched = zipCode;
		map.Find(null, zipCode, null, null, null, null, null, null, null, null, callback);
	} catch(e) {}
}    

function callback(shapeLayer,findResult,place,hasMoreResults,error) {         
	if (place!=null&&place.length>0) {
		var names = new Array('zipCode','latitude','longitude');
		var values = new Array(zipSearched,place[0].LatLong.Latitude,place[0].LatLong.Longitude);
		if (IsIE()) ajax = new ActiveXObject("Microsoft.XMLHTTP");	
		else ajax = new XMLHttpRequest();
		executeAJAX(ajax,url,'SaveZipInfo',names,values);
	}
}


function NextPage() {
	var page = Number(document.getElementById('CurrentPage').value);
	var totalPages = Number(document.getElementById('TotalPages').value);
	if (page<totalPages) GetMoreNews(++page);
}

function PreviousPage() {
	var page = Number(document.getElementById('CurrentPage').value);
	if (page>1) GetMoreNews(--page);
}

function GetMoreNews(page) {
	document.getElementById('CurrentPage').value = page;
	var names = new Array('page');
	var values = new Array(''+page);
	if (IsIE()) ajax = new ActiveXObject("Microsoft.XMLHTTP");	
	else ajax = new XMLHttpRequest();
	ajax.onreadystatechange = UpdateNews;		
	executeAJAX(ajax,url,'GetNews',names,values)	
}

function UpdateNews() {
	if (ajax.readyState==4) {
		if (ajax.status==200) {
			var response = stripHTML(ajax.responseText);
			var html = '<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="Title">KIDS-LIST NEWS</td></tr>';
			var items = response.split('|');
			for (i=0; i<items.length; i++) {
				var details = items[i].split('=');
				html += '<tr><td class="Header" style="cursor:pointer;" onClick="window.location=\'News.aspx?news='+details[0]+'\';">'+details[1]+'</td></tr>';	
			}
			var page = Number(document.getElementById('CurrentPage').value);
			var totalPages = Number(document.getElementById('TotalPages').value);
			html += '<tr><td class="HeaderText"><span style="float:right"><a href="javascript:PreviousPage();" style="text-decoration:none;display:'+((page>1)?'inline':'none')+'">&lt;</a>&nbsp;&#8226;&nbsp;<a href="javascript:NextPage();" style="text-decoration:none;display:'+((page<totalPages)?'inline':'none')+'">&gt;</a></span><a href="News.aspx">See All News</a></td></tr></table>'
			document.getElementById('NewsListArea').innerHTML = html;
		}
	}
}

function SelectAll(id) {
	var obj = document.getElementById(id);
	if (obj!=null) {
		for (var i=0; i<obj.options.length; i++) {
			obj.options[i].selected = true;	
		}
	}
}

function CheckboxRadio(obj,objArray) {
	if (obj.checked) {
		for (var i=0; i<objArray.length; i++) {
			if (objArray[i]!=obj.id) document.getElementById(objArray[i]).checked = false;	
		}
	}
}

function GetChildrenShowArea(activityId,categoryId,subArea) {
	actId = activityId;
	catId = categoryId;
	area = subArea;
	var parentId = document.getElementById(actId).options[document.getElementById(actId).selectedIndex].value;
	var catList = document.getElementById(catId);
	catList.options.length = 0;
	if (parentId!=-1) {
		var names = new Array('parentId');
		var values = new Array(parentId);
		if (IsIE()) ajax = new ActiveXObject("Microsoft.XMLHTTP");	
		else ajax = new XMLHttpRequest();
		ajax.onreadystatechange = UpdateChildrenShowArea;		
		executeAJAX(ajax,url,'GetChildCategories',names,values)
	}
}

function GetChildren(activityId,categoryId) {
	actId = activityId;
	catId = categoryId;
	var parentId = document.getElementById(actId).options[document.getElementById(actId).selectedIndex].value;
	var catList = document.getElementById(catId);
	catList.options.length = 0;
	catList.options[catList.options.length] = new Option('All Categories','-1');
	if (parentId!=-1) {
		var names = new Array('parentId');
		var values = new Array(parentId);
		if (IsIE()) ajax = new ActiveXObject("Microsoft.XMLHTTP");	
		else ajax = new XMLHttpRequest();
		ajax.onreadystatechange = UpdateChildren;		
		executeAJAX(ajax,url,'GetChildCategories',names,values)
	}
}

function UpdateChildrenShowArea() {
	if (ajax.readyState==4) {
		if (ajax.status==200) {
			var response = stripHTML(ajax.responseText);
			var catList = document.getElementById(catId);
			var parentList = document.getElementById(actId);
			if (response.indexOf('|')>-1) {				
				var vals = response.split('|');
				for (var i=0; i<vals.length; i++) {
					var items = vals[i].split('~');
					catList.options[catList.options.length] = new Option(items[1],items[0]);
				}
				ShowCell(area+'_1');
				ShowCell(area+'_2');
			} else {
				HideCell(area+'_1');
				HideCell(area+'_2');
			}
		}
	}
}	

function UpdateChildren() {
	if (ajax.readyState==4) {
		if (ajax.status==200) {
			var response = stripHTML(ajax.responseText);
			var catList = document.getElementById(catId);
			var parentList = document.getElementById(actId);
			if (response.indexOf('|')>-1) {				
				var vals = response.split('|');
				if (vals.length>0) {
					for (var i=0; i<vals.length; i++) {
						var items = vals[i].split('~');
						catList.options[catList.options.length] = new Option(items[1],items[0]);
					}
				}
			}
		}
	}
}	

function ShowAreas() {
	var obj = document.getElementById('ContentTitle');
	var titleVal = stripHTML(obj.innerHTML);
	if (titleVal==''||titleVal=='undefined'||titleVal==null||titleVal==undefined) {
		ShowRow('BlankSub');
		HideRow('TitleSub');
		HideRow('TitleBottom');
	} else {
		HideRow('BlankSub');
		ShowRow('TitleSub');
		ShowRow('TitleBottom');
	}
}
 
function MoveAtLength(obj,size,to) {
	if (obj.value.length>=size) MoveTo(to);
}
 
function MoveTo(to) {
	document.getElementById(to).focus();
	document.getElementById(to).select();
}

function stripHTML(oldString) {
   var newString = "";
   var inTag = false;
   for(var i = 0; i < oldString.length; i++) {
        if(oldString.charAt(i) == '<') inTag = true;
        if(oldString.charAt(i) == '>') {
			inTag = false;
			continue;
		}
        if(!inTag) newString += oldString.charAt(i);
   }
   return newString;
}

function restoreHtml(oldString) {
	var newString = oldString.replace(/&lt;/g,'<');
	newString = newString.replace(/&amp;/g,'&');
	return newString.replace(/&gt;/g,'>');
}

function executeAJAX(ajax,url,method,names,vals) {
	var val = '';
	val += '<?xml version="1.0" encoding="utf-8"?>';
	val += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
	val += '<soap:Body>';
	val += '<'+method+'  xmlns="'+url.replace(/https:/, "http:")+'">';
	if (names!=null) {
		for (var i=0; i<names.length&&i<vals.length; i++) val += '<'+names[i]+'>'+vals[i]+'</'+names[i]+'>';
	}
	val += '</'+method+'>';
	val += '</soap:Body>';
	val += '</soap:Envelope>';
	//alert(val);
	ajax.open("POST",url,true); 
	ajax.setRequestHeader("Content-Type", "text/xml");
	ajax.send(val)
	return true;
}

/*
 * ASPNET Fixes
 */

if (document.captureEvents&&Event.KEYPRESS) { 
	document.captureEvents(Event.KEYPRESS)
	document.onkeypress = ns_up; 
} else { 
	document.onkeypress = ms_up; 
} 

function ns_up(e) { 
	if (e.which==13&&e.target.type!='textarea'&&e.target.type!='submit') return false; 
	return true; 
} 

function ms_up() { 
	if (event.keyCode==13&&event.srcElement.type!='textarea'&&event.srcElement.type!='submit') return false; 
	return true; 
} 

function SelectEnterClicked(evt,button) {
	if (navigator.appName=='Microsoft Internet Explorer') {
		 if (event.keyCode==13) {
			 event.returnValue = false;
			 event.cancel = true;
	 		 document.getElementById(button).click();
		 }
	 } else {
		 if (evt.which==13) {
	 		 document.getElementById(button).click();
			 return false;
		 }
	 }
 }
//-->