function noErrorMessages () { return true; }
//window.onerror = noErrorMessages;

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );


var isIE = ((document.all)? true  : false );
var isNS6 = ((document.getElementById && !document.all)? true: false );
var ie55up = (document.all && document.getElementById)?(true):(false);

if (!currentLanguage){
	var currentLanguage = "EN" ;
}
btWish = new Image();
btWishOn = new Image();
btWish.src = "images/" + currentLanguage + "/b_my_wishlist.gif" ;
btWishOn = new Image();
btWishOn.src = "images/" + currentLanguage + "/b_my_wishlistON.gif" ;

btCenter = new Image();
btCenter.src = "images/" + currentLanguage + "/b_my_center.gif" ;
btCenterOn = new Image();
btCenterOn.src = "images/" + currentLanguage + "/b_my_centerON.gif" ;

function goToUrl(url){
	if(url)
		location.href = url;
}

function validateEmail(e){
	var rule = /^.+\@.+\..+$/;
	if (e.value.length>0){
		if ( !rule.test (e.value) ){
			alert ("Please enter a valid E-mail address");
			e.focus();
		}
	}
}

function validateEmailWithReturn(e){
	var rule = /^.+\@.+\..+$/;
	if (e.value.length>0){
		if ( !rule.test (e.value) ){
			alert ("Please enter a valid E-mail address");
			e.focus();
		}
		else
			return true;
	}
	return false;
}

function checkDate(e){
	var rule = /\d\d\/\d\d\/\d\d\d\d/;
	if (e.value.length>0 && e.value!="mm/dd/yyyy" ){
		if ( !rule.test (e.value) ){
			alert ("Please enter a valid date (mm/dd/yyyy format - e.g. 08/27/2004)");
			e.focus();
		}
	}
}

function getOffsetLeft (el) {
	if (!el)return ;
  var ol = el.offsetLeft;
  while ((el = el.offsetParent) != null)
    ol += el.offsetLeft;
  return ol;
}


function getOffsetTop (el) {
if (!el)return ;
  var ol = el.offsetTop;
  while ((el = el.offsetParent) != null)
    ol += el.offsetTop;return ol;
}

fixFatherId = 0;
function markTop(mainTabSuffix,submenuSuffix ){
	var mainO = document.getElementById("menu_"+mainTabSuffix);
	var subO = document.getElementById("submenu_"+submenuSuffix);
	if (mainO){
		if (mainO.parentElement){
			mainO.parentElement.parentElement.className = "sel" ;
		}else{
			if (mainO.parentNode){
				mainO.parentNode.parentNode.className = "sel" ;
			}
		}
	}
	if (submenuSuffix && submenuSuffix!="" ){
		if (subO){
			subO.className = "sel" ;
		}
	}
}

function showPoll(pollId){
	 addFlashInside ("flashDiv", "pollObject.swf?pollId="+pollId,"pollObject",255,245,"ffffff", "opaque","");

}

function showTerms(){
	window.open ("terms_of_use.aspx" , "terms", "width=582,height=470,scrollbars=yes,resizable=yes,scalable=yes,status=yes");
}

function showCopyrights(){
	window.open ("copyrights.aspx" , "copyrights", "width=582,height=440,scrollbars=auto,resizable=yes,scalable=yes,status=yes");
}

function showVideo(){
	window.open ("videoPopup.aspx" , "video", "width=562,height=350,scrollbars=no,resizable=yes,scalable=yes,status=yes");
}

var clickedSearch = false;
function catchSearch (evt){
	e = (isIE)? (window.event):(evt);

	if(e.keyCode==13){

		clickedSearch = true;
		if (document.forms[0]){document.forms[0].onsubmit = function(){return false};}
		result = validateSearch(false);
		/*
		if (e.cancelBubble) e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
		if (e.returnValue) e.returnValue = false;
		if (e.cancel) e.cancel = false;
		*/
		return false;
	}
}

function validateSearch(isAdvanced){
	if (document.getElementById('searchStr')){
		if (document.getElementById('searchStr').value.length>1 ){
			top.location.href = 'search.aspx?advanced='+isAdvanced+'&searchStr='+escape(document.getElementById('searchStr').value);

			return true;
		}else{
			alert ("Search term must be at least 2 characters ");
			document.getElementById('searchStr').focus();
			return false;
		}
	}
}

var lastTab = "";
function showTabContent(tabName){
	if (document.getElementById("tabLink_" + lastTab)){
		document.getElementById("tabContent_" + lastTab).style.display = "none";
		document.getElementById("tabLink_" + lastTab).className = "";
	}


	if (document.getElementById("tabContent_" + tabName)){
		document.getElementById("tabContent_" + tabName).style.display = "block";
		document.getElementById("tabLink_" + tabName).className = "sel";
		lastTab = tabName;
	}
}

function selectDefTab(){
	if(lastTab == '')
		showTabContent('articles');
}

function addToCenter(itemType , itemId ){


	document.getElementById("topTabsFrame").src = "my_center.aspx?type=" + itemType + "&id="+ itemId ;

	if (itemId>0 ){
		if (userId!=""){
			setTimeout ("mycenterAlert()" , 1000);
		}
	}else{
		if (userId){
			document.getElementById("topTabsFrame").style.display = "block";
			document.getElementById("myCenterBottom").style.display = "block";
			document.getElementById("wishlistBottom").style.display = "none";
			document.getElementById("mycenterButton").style.backgroundImage = "url("+ btCenterOn.src + ")";
			document.getElementById("wishlistButton").style.backgroundImage = "url("+ btWishOn.src + ")";
			document.getElementById("mycenterButton").blur();
		}
	}


}

function closeMyCenter(){
	top.document.getElementById("topTabsFrame").style.display = "none";
	top.document.getElementById("myCenterBottom").style.display = "none";
	top.document.getElementById("mycenterButton").style.backgroundImage = "url("+ btCenter.src + ")";
	top.document.getElementById("wishlistButton").style.backgroundImage = "url("+ btWish.src + ")";
}
function closeWishlist(){
	top.document.getElementById("topTabsFrame").style.display = "none";
	top.document.getElementById("wishlistBottom").style.display = "none";
	top.document.getElementById("mycenterButton").style.backgroundImage = "url("+ btCenter.src + ")";
	top.document.getElementById("wishlistButton").style.backgroundImage = "url("+ btWish.src + ")";
}

function addToWishlist(toyId){
	document.getElementById("topTabsFrame").src = "wishlist.aspx?toyId="+ toyId ;

	if (toyId>0 ){
		if (userId!=""){
			setTimeout ("wishlistAlert()" , 1000);
		}
	}else{
		if (userId){
			document.getElementById("topTabsFrame").style.display = "block";
			document.getElementById("wishlistBottom").style.display = "block";
			document.getElementById("myCenterBottom").style.display = "none";
			top.document.getElementById("mycenterButton").style.backgroundImage = "url("+ btCenterOn.src + ")";
			document.getElementById("wishlistButton").style.backgroundImage = "url("+ btWishOn.src + ")";
			document.getElementById("wishlistButton").blur();
		}
	}



}

function wishlistAlert(){
	if (document.getElementById ("wishlistWrapper")){
		document.getElementById ("wishlistWrapper").style.display = "block" ;
		moveAlert (true,true);
	}
}


function mycenterAlert(){
	if (document.getElementById ("mycenterWrapper")){
		document.getElementById ("mycenterWrapper").style.display = "block" ;
		moveAlert (true,false);
	}
}

lastLoc = -24;
function moveAlert (moveUp,isWishlist){
	var o ;
	if (isWishlist){
		o = document.getElementById ("wishlistWrapper");
	}else{
		o = document.getElementById ("mycenterWrapper");
	}

	if (moveUp){
		if (lastLoc<0){
			lastLoc++;
			o.style.bottom = lastLoc;
			setTimeout ("moveAlert(true,"+isWishlist+")" , 20) ;
		}else{
			setTimeout ("moveAlert(false,"+isWishlist+")" , 2000) ;
		}
	}else{
		if (lastLoc>-25){
			lastLoc--;
			o.style.bottom = lastLoc;
			setTimeout ("moveAlert(false,"+isWishlist+")" , 20) ;
		}else{
			o.style.display = "none";
		}
	}
}


function sendMilestone(){
	dateStr = document.getElementById("mileDate").value;
	if (dateStr=="mm/dd/yyyy"){
		dateStr = "";
	}

	emailStr = document.getElementById("mileEmail").value;
	top.location = "milestone_mail.aspx?date=" + dateStr + "&email=" + emailStr;
}



var keepTooltip = false;
function tooltip(tooltipOpenerDiv, str){
	var o = document.getElementById("tooltipDiv");
	var h = document.getElementById("tooltipHeader")
	var d = document.getElementById("tooltipDesc")
	var offset = 0;
	if (o && glossaryItemsAr){
		if (glossaryItemsAr[str]){
			h.innerHTML = str;
			d.innerHTML = glossaryItemsAr[str];

			o.style.display = "block";
			o.style.left = getOffsetLeft(tooltipOpenerDiv) - 40;
			o.style.top = getOffsetTop(tooltipOpenerDiv) - 153;
			
			//o.style.left = event.x + 40 ;
			//offset = getOffsetTop (event.srcElement);

			//o.style.top =  offset - 150;
			//o.style.top =  event.y - 160;
			//setTimeout("tooltipEnd()" , 5000 );
		}
	}
}

function tooltipEnd(){

	if (keepTooltip == false ){
		document.getElementById("tooltipDiv").style.display = "none";
	}
}

function closeTooltip(evt){
	var today = new Date();
	var o = document.getElementById("tooltipDiv");
	//e = window.event;
	var e = (isIE)? (event):(evt);
	var srcElementObj = e.relatedTarget || e.fromElement;
	var toElementObj = e.relatedTarget || e.toElement;
	//alert(srcElementObj.id + " | " + toElementObj.id);
	if (e){
		if ((srcElementObj.id ==  "tooltipDiv" && toElementObj.id.indexOf("tooltip")==-1) || (srcElementObj.id ==  "" && toElementObj.id ==  "")){
				setTimeout("tooltipEnd()" , 100 );
				keepTooltip = false;

		}else{
			window.status = srcElementObj.id + ":" + toElementObj.id  ;
			keepTooltip = true;
		}
	}else{
		setTimeout("tooltipEnd()" , 1000 );
		keepTooltip = false;
	}

}


var loginWin;
function showLogin(){
	loginWin = window.open ("https://www.tinylove.com/login.aspx?url="+escape(top.location.href),"loginWin","width=575,height=525,scalable=yes,scrollbars=no,status=yes,resizable=no");
}

function editProfile(){
	loginWin = window.open ("https://www.tinylove.com/login.aspx?action=edit","loginWin","width=590,height=550,scalable=yes,scrollbars=no,status=yes,resizable=no");
}


function openToybox(){
	selVal = document.getElementById("toyboxAgeId").value;
	top.location = "toy_box.aspx?ageId="+selVal;
}


function addFlashInside (containerId, url,id,w,h,bgcolor, wmode, attributes){
	str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ' + attributes +
		' width="' + w + '" height="' + h + '" > ' +
		'<param name="movie" value="' + url + '">' +
		'<param name="quality" value="high">' +
		'<param name="wmode" value="'+ wmode +'">' +
		'<param name="bgcolor" value="'+ bgcolor +'">' +
		'<param name="allowScriptAccess" value="sameDomain" />' +
		'<embed swLiveConnect="true" quality=best type="application/x-shockwave-flash" menu=false  ' + attributes +
		' name="' + id + '" id="' + id + '" ' +
		' src="' + url + '" ' +
		' wmode="'+ wmode +'" ' +
		' bgcolor="' + bgcolor + '" ' +
		' width=' + w + ' height=' + h +
		' swLiveConnect=true ' +
		' allowScriptAccess="sameDomain" ' +
		' type="application/x-shockwave-flash" ' +
		' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ></embed></object>';
		//alert (containerId + ":" + document.getElementById(containerId) + str);
	setHtml(containerId,str,false,false);

}

function addFlash(url,id,w,h,bgcolor, wmode, attributes){

	str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ' + attributes +
		' width="' + w + '" height="' + h + '" > ' +
		'<param name="movie" value="' + url + '">' +
		'<param name="quality" value="high">' +
		'<param name="wmode" value="'+ wmode +'">' +
		'<param name="bgcolor" value="'+ bgcolor +'">' +
		'<param name="allowScriptAccess" value="sameDomain" />' +
		'<embed swLiveConnect="true" quality=best type="application/x-shockwave-flash" menu=false  ' + attributes +
		' name="' + id + '" id="' + id + '" ' +
		' src="' + url + '" ' +
		' wmode="'+ wmode +'" ' +
		' bgcolor="' + bgcolor + '" ' +
		' width=' + w + ' height=' + h +
		' swLiveConnect=true ' +
		' allowScriptAccess="sameDomain" ' +
		' type="application/x-shockwave-flash" ' +
		' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ></embed></object>';

	document.write (str);
}


function setHtml(id,html,toAppend,hideIfEmpty){
	if (id=="")return;
	var o = document.getElementById(id);
	if (o){
		html = html.replace(/\\r\\n/gi,"");
		o.innerHTML = (toAppend)?(o.innerHTML+html):(html);
		if (hideIfEmpty && html=="") o.className = "off";
	}
}

function changeAgeKit(Obj){
	if(Obj && Obj.value && !isNaN(Obj.value))
		location.href = "age_kit.aspx?AgeId=" + Obj.value;
}

function hideImage(Obj){
	//alert(Obj);
	var ObjDiv = document.getElementById(Obj);
	if (ObjDiv)
		ObjDiv.style.display = "none;"
}

function showImage(Obj){
	//alert(Obj);
	var ObjDiv = document.getElementById(Obj);
	if (ObjDiv)
		ObjDiv.style.display = "inline;"
}

function changeImageSrc(imgObj, imgSrc){
	//alert(imgSrc);
	if(imgObj && imgObj.src)
		imgObj.src = imgSrc;
}

function goToRecallInfoContent(Obj){
    var ObjSelect = document.getElementById(Obj);
    
	if(ObjSelect && ObjSelect.value)
	    location.href = "recall_information_content.aspx?countrycode=" + ObjSelect.value;
    return false;
}