var tcdacmd="dt";

if ( document.all && ! document.getElementById ) {
    document.getElementById = function( id ) {
         return document.all[ id ];
    }
};




function popPrint(url) {
  window.name = "opener";
  var detWindow = "";
  detWindow = window.open(url,'print','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=764,height=600');
};

function popWindow( url, title, w, h ) {
	var popup = null;
	window.name = "opener";
	if ( w == 0 ) w = 764;
	if ( h == 0 ) h = 600;
	
	popupwindow = window.open( url, title, 'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=' + w + ',height=' + h );
};
function popWindow2( url, title, w, h ) {
	var popup = null;
	window.name = "opener";	
	var params = "";
	
	if ( w != null && h != null ) {
		params = 'width=' + w + ',height=' + h
	}
	
	popupwindow = window.open( url, title, params );
};
function popMailWin( formURL ) {
	window.open( formURL, "emailpop","height=470,width=540,resizable,scrollbars=no" );
}
function goPop(section,name,option,question) {
        var help = 'scrollbars=1,dependent=1,resizable=1,width=325,height=375,left=325,top=225';
        var spcHelp = 'scrollbars=1,dependent=1,resizable=1,width=325,height=375,left=325,top=225';
        if(option=="help"){
                        eval(option + "Win = window.open('http://www.kitchenassistant.com/web/recipefinder/help/" + section + "_indx.html#" + question + "','" + name + "'," + option + ")");
        }
        else{
                        alert("No option selected");
        }
        eval(option + "Win.focus()");
}

function IMArticle() {
	
	if (isInAolClient()) {
		document.location.href = "aol://9293::Here's something that may interest you from RealSimple.com <a href='" + document.location.href + "'>" + document.location.href + "</a>";
	} else {
		document.location.href = "aim:goim?message=Here's+something+that+may+interest+you+from+RealSimple.com:+" + document.location.href;
	}
	
	return false;
}


// ### Array Helper Functions ###

function tiiArrayContains (array, value) {
	if (array != null) {
		var al = array.length;
		for (var i = 0; i < al; i++) {
			if (array[i] == value) return true;
		}
	}
	return false;
}

// ### Key=Value; Functions ###

function tiiHashKeys(string) {
	var keys = null;
	if (string != null) {
		var hash = string.split(';');
		var hl = hash.length - 1;
		if(hl > 0){
			keys = new Array();
			for(var i = 0; i < hl; i++){
				var data = hash[i].split('=');
				keys[i] = data[0].replace(' ', '');
			}
		}
	}
	return keys;
}

function tiiHashGet(string, key) {
	var value = null;
	if (string != null) {
		var keyStart = key + '=';
		var offset = string.indexOf(keyStart);
		if (offset != -1) {
			offset += keyStart.length;
			var end = string.indexOf(';', offset);
			if (end == -1) {
				end = string.length;
			}
			value = string.substring(offset, end);
		}
	}
	return value;
}

function tiiHashSet(string, key, value) {
	var string = tiiHashDelete(string, key);
	var newValue = key + '=' + value + ';';
	if (string != null) newValue = newValue + string;
	return newValue;
}

function tiiHashDelete(string, key) {
	var oldValue = tiiHashGet(string, key);
	var newString = string;
	if (oldValue != null) {
		var search = key + '=';
		var start = string.indexOf(search);
		var offset = start + search.length;
		var end = string.indexOf(';', offset) + 1;
		if (end == -1) end = string.length;
		newString = string.slice(0,start) + string.slice(end,string.length);
		return newString;

	}
	return newString;
}

function tiiGetQueryParamValue(param) {
	var startIndex;
	var endIndex;
	var valueStart;

	var qs = document.location.search;
	var detectIndex = qs.indexOf( "?" + param + "=" );
	var detectIndex2 = qs.indexOf( "&" + param + "=" );
	var key = "&" + param + "=";
	var keylen = key.length;

	if (qs.length > 1) {
		if (detectIndex != -1) {
			startIndex = detectIndex;
		} else if (detectIndex2 != -1) {
			startIndex = detectIndex2;
		} else {
			return null;
		}

		valueStart = startIndex + keylen;

		if (qs.indexOf("&", valueStart) != -1) {
			endIndex = qs.indexOf("&", startIndex + 1)
		} else {
			endIndex = qs.length
		}

		return (qs.substring(qs.indexOf("=", startIndex) + 1, endIndex));
	}

	return null;
}

// ### Date/Time Functions ###

function tiiDateGetOffsetMinutes(minutes)	{ var today = new Date(); return today.getTime() + (60000) * minutes;}
function tiiDateGetOffsetHours(hours)		{ var today = new Date(); return today.getTime() + (3600000) * hours; }
function tiiDateGetOffsetDays(days)			{ var today = new Date(); return today.getTime() + (86400000) * days; }
function tiiDateGetOffsetWeeks(weeks)		{ var today = new Date(); return today.getTime() + (604800000) * weeks; }
function tiiDateGetOffsetMonths(months)		{ var today = new Date(); return today.getTime() + (259200000) * months; }
function tiiDateGetOffsetYears(years)		{ var today = new Date(); return today.getTime() + (31536000000) * years; }
// ### Core Cookie Functions ###

function tiiCookieExists(cookieName) {
	return tiiArrayContains(tiiCookieGet(), cookieName);
}

function tiiCookieGet(cookieName) {
	if (arguments.length == 0) {
		return tiiHashKeys(document.cookie);
	}

	var cookie = tiiHashGet(document.cookie, cookieName);
	if (cookie != null) cookie = unescape(cookie);
	return cookie;
}

function tiiCookieSet(cookieName, cookieValue, domain, path, expires, secure) {
	if (expires != null) {
		expire_date = new Date();
		expire_date.setTime(expires);
	}
	var curCookie = cookieName + '=' + escape(cookieValue)
		+ ((expires) ? '; expires=' + expire_date.toGMTString() : '')
		+ ((path) ? '; path=' + path : '')
		+ ((domain) ? '; domain=' + domain : '')
		+ ((secure) ? '; secure' : '');
	document.cookie = curCookie;
}

function tiiCookieDelete(cookieName) {
	tiiCookieSet(cookieName, null, null, null, '', 0);
}

// ### Core Chip Functions ###
function tiiCookieChipGet(cookieName, chipName) {
	if (arguments.length == 1) {
		return tiiHashKeys(tiiCookieGet(cookieName));
	}
	return tiiHashGet(tiiCookieGet(cookieName), chipName);
}

function tiiCookieChipSet(cookieName, chipName, chipValue, domain, path, expire, secure) {
	var new_cookieValue = tiiHashSet(tiiCookieGet(cookieName), chipName, chipValue);
	tiiCookieSet(cookieName, new_cookieValue, domain, path, expire, secure);
}

function tiiCookieChipDelete(cookieName, chipName, domain, path, expire, secure) {
	var new_cookieValue = tiiHashDelete(tiiCookieGet(cookieName), chipName);
	if (new_cookieValue == null) new_cookieValue = '';
	tiiCookieSet(cookieName, new_cookieValue, domain, path, expire, secure);
}

// ### Permanent Cookie/Chip Functions ###
function tiiPermCookieChipGet(chipName) {
	return tiiCookieChipGet('tii_perm', chipName);
}

function tiiPermCookieChipSet(chipName, chipValue) {
	tiiCookieChipSet('tii_perm', chipName, chipValue, null, '/', tiiDateGetOffsetYears(2), 0);
}

function tiiPermCookieChipDelete(chipName) {
	tiiCookieChipDelete('tii_perm', chipName, null, '/', tiiDateGetOffsetYears(2), 0);
}

// ### Session Cookie/Chip Functions ###
function tiiSessCookieChipGet(chipName) {
	return tiiCookieChipGet('tii_sess', chipName);
}

function tiiSessCookieChipSet(chipName, chipValue) {
	tiiCookieChipSet('tii_sess', chipName, chipValue, null, '/', null, 0);
}

function tiiSessCookieChipDelete(chipName) {
	tiiCookieChipDelete('tii_sess', chipName, null, '/', null, 0);
}
function google_ad_request_done(google_ads) {
	var i;
	var td = 0;
	var width = 100;
	
	if (google_ads.length > 0) {
		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" class="google_border">');
		
		if (tii_slinks_header.length > 0) {
			document.write('<tr><td class=\"google_header\" colspan=' + td + '>' + tii_slinks_header + '</td></tr>');
		}
		
		document.write('<tr>');
		document.write('<td>');
		document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.write('<tr>');
		
		if (google_ads.length > 1) {
			var width = (100 - ((google_ads.length - 1) * 1)) / google_ads.length;
		}
	
		for(i = 0; i < google_ads.length; ++i) {
			if (i > 0) {
				document.write('<td align="center" valign="top" class="google_separator" width="1%">' + tii_slinks_separator + '</td>');
				td++;
			}
			
			document.write('<td class="google_adbox" width="' + width +'%">');
			document.write('<nobr><a href="' + google_ads[i].url + '" class="google_link" target=_blank>' + google_ads[i].line1 + '</a></nobr><br />');
			document.write(google_ads[i].line2 + ' ' + google_ads[i].line3 + '<br />');
			document.write('</td>');
			td++;
		}
		
		document.write('</tr>');
		
		if (tii_slinks_footer.length > 0) {
			document.write('<tr><td class=\"google_footer\" colspan=' + td + '>' + tii_slinks_footer + '</td></tr>');
		}
		
		document.write('</table>');
		document.write('</td>');
		document.write('</tr>');
		document.write('</table>');
	}
}function reloadAds() {
	var ads = "";
	if ( adsList != null ) {
		for ( var i = 0; i < adsList.length; i++ ) {
			var id1 = adsList[i];
			ad = document.getElementById(id1);
			 if ( ad != null ) {
				var frame = ad.getElementsByTagName("script")[0];
				 ad.appendChild( frame );
				 ads = ads + " " + adsList[i];
			}
		}
	}
	 }

function tiiGetQueryParamValue(param) {
	var startIndex;
	var endIndex;
	var valueStart;
	var qs = document.location.search;
	var detectIndex = qs.indexOf( "?" + param + "=" );
	var detectIndex2 = qs.indexOf( "&" + param + "=" );
	var key = "&" + param + "=";
	var keylen = key.length;
	if (qs.length > 1) {
		if (detectIndex != -1) {
			startIndex = detectIndex;
		} else if (detectIndex2 != -1) {
			startIndex = detectIndex2;
		} else {
			return null;
		}	
		valueStart = startIndex + keylen;		
		if (qs.indexOf("&", valueStart) != -1) {
			endIndex = qs.indexOf("&", startIndex + 1)
		} else {
			endIndex = qs.length
		}
		return (qs.substring(qs.indexOf("=", startIndex) + 1, endIndex));
	}
 return null;
}FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver || 6; // default to 6
	this.align = "middle"; // default to middle
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "Please <a href='http://www.macromedia.com/go/getflashplayer'>upgrade your Flash Player</a>.";
	this.bypassTxt = "";
	this.params = new Object();
	this.variables = new Object();
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'high'); // default to high
	this.doDetect = tiiGetQueryParamValue('tiiDetectFlash');
}

FlashObject.prototype.addParam = function(name, value) {
	this.params[name] = value;
}

FlashObject.prototype.getParams = function() {
	return this.params;
}

FlashObject.prototype.getParam = function(name) {
	return this.params[name];
}

FlashObject.prototype.addVariable = function(name, value) {
	this.variables[name] = value;
}

FlashObject.prototype.getVariable = function(name) {
	return this.variables[name];
}

FlashObject.prototype.getVariables = function() {
	return this.variables;
}

FlashObject.prototype.getParamTags = function() {
	var paramTags = "";
	for (var param in this.getParams()) {
		paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
	}
	if (paramTags == "") {
		paramTags = null;
	}
	return paramTags;
}

FlashObject.prototype.getHTML = function() {
	var flashHTML = "";
	if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
		flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
		flashHTML += '<param name="movie" value="' + this.swf + '" />';
		if (this.getParamTags() != null) {
			flashHTML += this.getParamTags();
		}
		if (this.getVariablePairs() != null) {
			flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
		}
		flashHTML += '</object>';
	}
	else { // Everyone else
		flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
		for (var param in this.getParams()) {
			flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
		}
		if (this.getVariablePairs() != null) {
			flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
		}
		flashHTML += '></embed>';
	}
	return flashHTML;
}


FlashObject.prototype.getVariablePairs = function() {
	var variablePairs = new Array();
	for (var name in this.getVariables()) {
		variablePairs.push(name + "=" + escape(this.getVariable(name)));
	}
	if (variablePairs.length > 0) {
		return variablePairs.join("&");
	}
	else {
		return null;
	}
}

FlashObject.prototype.write = function(elementId) {
	if(tiiDetectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}
}

function tiiGetFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x){
			if (x.description) {
				var y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
	} else {
		result = false;
		for(var i = 15; i >= 3 && result != true; i--){
			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
			flashversion = i;
		}
	}
	return flashversion;
}

function tiiDetectFlash(ver) {
	if (tiiGetFlashVersion() >= ver) {
		return true;
	} else {
		return false;
	}
}

/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item){
		this[this.length] = item;
		return this.length;
	}
}
var adConfig = new TiiAdConfig("3475.rsm");
adConfig.setCmSitename("cm.rsm");
//Revenue Science
adConfig.setRevSciTracking(true);


var tii_EXPIRES_NEVER=new Date();
tii_EXPIRES_NEVER.setTime(tii_EXPIRES_NEVER.getTime()+((9000)*24*60*60*1000));//9000 days

function tii_Cookie(name,secure){
	this.name=name;
	this.secure=false;
	if(secure!=null&&secure==true){
		this.secure=true;
	}
    var cookies=document.cookie;
    var prefix=this.name+"=";
    var start=cookies.indexOf(prefix);
    if(start==-1) return null;
    var end=cookies.indexOf(";",start);
    if(end==-1) end=cookies.length;
    var readableValue=cookies.substring(start+prefix.length,end);
	if(this.secure){
		readableValue=this.decrypt(readableValue);
	}
	this.value=unescape(readableValue);
}
tii_Cookie.prototype.set=function(cookieValue,expires,path) {
	var savedValue=escape(cookieValue);
	if(this.secure){
		savedValue=this.encrypt(savedValue);
	}
	var tii_Cookie = this.name + '=' + savedValue;
	if(expires!=null)tii_Cookie+='; expires='+expires;
	if(path!=null)tii_Cookie+='; path='+path;
	if(this.secure){
		tii_Cookie+="; secure";
	}
	document.cookie = tii_Cookie;
}
tii_Cookie.prototype.erase=function(){
	this.set("",-1);
}
var xor_key=6;
tii_Cookie.prototype.encrypt=function(to_enc){
	var the_res="";
	for(i=0;i<to_enc.length;++i){
		the_res+=String.fromCharCode(xor_key^to_enc.charCodeAt(i));
	}
	return the_res;
}
tii_Cookie.prototype.decrypt=function(to_dec){
	var the_res="";
	for(i=0;i<to_dec.length;i++){
		the_res+=String.fromCharCode(xor_key^to_dec.charCodeAt(i));
	}
	return the_res;
}
var loginCookie = new tii_Cookie("snId");
var isLoggedIn =0;

if (loginCookie.value!=null )
{
	//alert(loginCookie.value);
	isLoggedIn =1;
}
