var ver_cntr = 0
var ver_time = 0
var checking_ax = 0
var dont_use_control = 0
var dont_use_exe = 0
var need_ff_plugin = 0
var have_ff_plugin = 0
var var_settings = ""
var curr_aff_code = ""

var sb_path=""
var sb_loc=""
var diff_domain=0
var js_folder=""
var afiniti_name=""
var cust_level=""
var orderWin = null
//activation_key[1] = "999"
afiniti_totals['tape'] = 0
var share_fields=new Array()
var share_fname=""
var share_code=""
var stash_code=""
var check_share_cntr=0

var acct_window = null
var acct_time = 120

var install_done = 0
var add_done = 0
var make_done = 0
var share_done = 0
var all_done = 0
var done_cntr = 0
var check_time = 0
var stash_code = ""
var active_tab = ""
var log_status = ""
var feed_loading = 0
var share_loading = 0
var load_shares_next = 0
var original_skin = "green"
var skins_array = new Array()
skins_array[0] = "green"
skins_array[1] = "leopard"
skins_array[2] = "slate"
skins_array[3] = "decor"
skins_array[4] = "ireland"
skins_array[5] = "chalkboard"
if(GetCookie("skin"))
	{
	for(cntr=0;cntr<skins_array.length;cntr++)
		{
		if(GetCookie("skin") == skins_array[cntr])
			{
			original_skin = GetCookie("skin")
			}
		}
	if(original_skin == "green")
		{
		set_special_cookie("skin",original_skin,365)
		}
	}
if(partner != "")
	{
	if(original_skin != partner_skin)
		{
		original_skin = partner_skin
		set_special_cookie("skin",original_skin,365)
		}
	}
var selected_skin = original_skin

current_activex_version = String(current_activex_version)

var sb_loc_string = String(document.location.host).toLowerCase()



if(sb_loc_string.indexOf("stashspace.com") == -1 && am_local != 1)
	{
	diff_domain = 1
	sb_loc = "www.stashspace.com"
	}
else if(partner != "")
	{
	if(is_partner[partner] == 1)
		{
		sb_loc = ""
		}
	else
		{
		sb_loc = "http://www.stashspace.com"
		}
	}

if(browser_type == "Netscape")
	{
	var br_ver_string = new String(navigator.userAgent)
	if(br_ver_string.indexOf('Windows NT') > -1)
		{
		var chr1 = br_ver_string.indexOf('NT') + 3
		br_ver_string = br_ver_string.slice(chr1,br_ver_string.length)
		var chr2 = br_ver_string.indexOf(';')
		br_ver_string = br_ver_string.slice(0,chr2)
		br_nt_num = eval(br_ver_string)
		if(br_nt_num > 5.0)
			{
			if(navigator.plugins)
				{ 
				for(var i=0; i < navigator.plugins.length; i++ )
					{ 
					if(String(navigator.plugins[i].name).indexOf("Windows Media Player Firefox Plugin") != -1)
						{
						have_ff_plugin = 1
						}
					} 
				if (have_ff_plugin == 1)
					{
					allow = 1
					}
				else
					{
					need_ff_plugin = 1
					}
				}
			}
		else
			{
			allow = 1
			}
		}
	else
		{
		allow = 1
		} 
	}


function swap_nav_image2(id,state)
{
document.getElementById(id).src = (partner_folder + "/images2/" + id.slice(0,id.lastIndexOf("-")) + "-" + state + ".gif")
}


function swap_nav_image(id,state)
{
document.getElementById(id).src = (partner_folder + "/images/" + id.slice(0,id.lastIndexOf("-")) + "-" + state + ".gif")
}


var nav_array = new Array()
nav_array.push('stash')
nav_array.push('shares')
nav_array.push('tapes')
nav_array.push('help1')
nav_array.push('help2')
nav_array.push('contact1')
nav_array.push('contact2')

function chg_log_in_out()
{


if(!GetCookie('homemovie'))
	{
	for(cntr=0;cntr<nav_array.length;cntr++)
		{
		if(document.getElementById('menu-'+nav_array[cntr]))
			{
			var cell_arr = document.getElementById('menu-'+nav_array[cntr]).rows[0].cells
			for(cntr1=0;cntr1<cell_arr.length;cntr1++)
				{
				var cell_id = String(cell_arr[cntr1].id)
				if (cell_id.indexOf('logout') > -1)
					{
					cell_arr[cntr1].innerHTML = "Login"
					}
				}
			}
		}
	}

}


function recommend_ff_plugin()
{
if(document.getElementById('ffplugin_required')) 
	{
	document.getElementById('ffplugin_required').style.visibility = "visible"
	}
else
	{
	var ffplugin_ques = confirm("We recommend that you install a special plugin for Firefox.  We'll take you to the plugin installation.")
	if (ffplugin_ques == true)
		{
		goto_ff_plugin()
		}
	}
}


function goto_ff_plugin()
{
if(partner == "")
	{
	document.location = "/my-account/install-firefox-plugin.stm"
	}
else
	{
	document.location = partner_folder + "/install-firefox-plugin.stm"
	}
}


function load_new_share(this_share_fname,this_share_title,this_share_movie,this_share_type,this_share_number,this_share_view)
{
share_fname = this_share_fname
}


function populate_af4()
{
set_ref(share_fields[1])
}


function check_share_code()
{
check_share_cntr++
if(check_share_cntr == 10 || share_fname != "")
	{
	window.clearInterval(check_time)
	check_share_cntr = 0
	if(share_fname == "")
		{
		alert("You have no shared movies or albums to view.  We'll take you to the\nhome page where you can find out more about shared movies.")
		return
		}
	else
		{
		switch_page("shares")
		return
		}
	}
}


var un_window = null
var help_window = null
var ns8_window = null
var wmp11_window = null

function show_screen(what_screen)
{
if(what_screen == "reinstall")
	{

	var un_url = "/support/reinstall-stashbox.stm"
	var options = 'dependent=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
	options = options + ',width=600'
	options = options + ',height=580'
	options = options + ',screenX=0,screenY=0,left=0,top=0';
	try
		{
		if(un_window == null)
			{
			un_window = window.open(un_url,'print_help',options)
			}
		else if(un_window.closed == false)
			{
				un_window.focus()	
			}
		else
			{
			un_window = window.open(un_url,'print_help',options)
			}
		}
	catch(err)
		{
		un_window = window.open(un_url,'print_help',options)
		}
	}
else if(what_screen == "ns8")
	{
	var ns8_url = "/support/enable-activex-in-netscape8.stm"
	var options = 'dependent=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
	options = options + ',width=600'
	options = options + ',height=580'
	options = options + ',screenX=0,screenY=0,left=0,top=0';
	try
		{
		if(ns8_window == null)
			{
			ns8_window = window.open(ns8_url,'print_help',options)
			}
		else if(ns8_window.closed == false)
			{
			ns8_window.focus()
			}
		else
			{
			ns8_window = window.open(ns8_url,'print_help',options)
			}
		}
	catch(err)
		{
		ns8_window = window.open(ns8_url,'print_help',options)
		}
	}
else if (what_screen == "wmp11")
	{
	var wmp11_options = 'dependent=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes';
	wmp11_options = wmp11_options + ',width=800';
	wmp11_options = wmp11_options + ',height=600';
	wmp11_options = wmp11_options + ',screenX=0,screenY=0,left=0,top=0';
	try
		{
		if(wmp11_window == null)
			{
			wmp11_window = window.open("http://www.microsoft.com/windows/windowsmedia/player/11/readme.aspx#RollingbacktoapreviousversionofthePlayer","wmp11_page",wmp11_options)
			}
		else if(wmp11_window.closed == false)
			{
			wmp11_window.focus()
			}
		else
			{
			wmp11_window = window.open("http://www.microsoft.com/windows/windowsmedia/player/11/readme.aspx#RollingbacktoapreviousversionofthePlayer","wmp11_page",wmp11_options)
			}
		}
	catch(err)
		{
		wmp11_window = window.open("http://www.microsoft.com/windows/windowsmedia/player/11/readme.aspx#RollingbacktoapreviousversionofthePlayer","wmp11_page",wmp11_options)
		}
	}
else if (what_screen == "security")
	{
	alert("Internet Security, Internet Schmecurity.  Just go ahead and don't worry about it.")
	}
}


function close_layer(which_layer)
{
document.getElementById(which_layer).style.visibility = "hidden"
if(which_layer == "ns8_alert")
	{
	document.location = "/my-stash/index.stm"
	}
else if(which_layer == "intelMac_alert")
	{
	document.location = "/my-account/index.stm"
	}
}


function load_stash_frames(skin)
{

random_location()
if(is_intelMac != 1)
	{
	if(allow == 1)
		{
		document.getElementById("player_frame").height = "740"
		if(GetCookie("homemovie"))
			{
			stash_code = "?l1~" + code + "~" + pass
			}
		else if(GetCookie("demo"))
			{
			stash_code = "?d~" + code + "~"  + enc_pass
			}
		stash_code += "~" + skin
		if(dont_use_control == 1)
			{
			stash_code += "~allow_no_x"
			}
		else if(dont_use_exe == 1)
			{
			stash_code += "~allow_no_exe"
			}
		stash_code = (sb_loc + "/sb_no_cache/sb_frames.htm" + stash_code)
		active_tab = "stash"
		document.getElementById("player_frame").src = stash_code
		}
	else
		{
		alert("You cannot open stashBox until your computer\nis checked for the stashBox application.")
		return
		}
	}
}

function load_stash_frames_compiled(skin)
{


if(is_intelMac != 1)
	{
	if(allow == 1)
		{
		document.getElementById("player_frame").height = "740"
		if(GetCookie("homemovie"))
			{
			stash_code = "?l1~" + code + "~" + pass
			}
		else if(GetCookie("demo"))
			{
			stash_code = "?d~" + code + "~"  + enc_pass
			}
		if(dont_use_control == 1)
			{
			stash_code += "~allow_no_x"
			}
		else if(dont_use_exe == 1)
			{
			stash_code += "~allow_no_exe"
			}
		stash_code = (sb_loc + "/sb_no_cache/sb_frames_compiled.htm" + stash_code)
		active_tab = "stash"
		// alert("load_stash_frames_compiled('"+skin+"') with " + stash_code)
		document.getElementById("player_frame").src = stash_code
		}
	else
		{
		alert("You cannot open stashBox until your computer\nis checked for the stashBox application.")
		return
		}
	}
}

function load_share_frames(skin)
{



if(browser_agent.toLowerCase().indexOf('safari') > -1)
	{
	alert('To view or edit your video on a Mac, you must use Firefox or Netscape.')
	document.location = "/index.stm"
	return
	}

if(is_intelMac != 1)
	{
	document.getElementById("player_frame").height = "740"
	if(share_code != "")
		{
		if(share_code.indexOf("?f~") > -1)
			{
			stash_code = (sb_loc + "/sb_no_cache/sb_frames.htm" + share_code)
			}
		else if(GetCookie("demo"))
			{
			stash_code = (sb_loc + "/sb_no_cache/sb_frames.htm?ds~" + share_code + "~" + enc_pass + "~" + skin)
			}
		else
			{
			stash_code = (sb_loc + "/sb_no_cache/sb_frames.htm?s1~" + share_code)
			if(share_fields.length > 2)
				{
				for(cntr=2;cntr<share_fields.length;cntr++)
					{
					if(cntr==3)
						{
						stash_code += "~" + skin + "~" + share_fields[cntr]
						}
					else
						{
						stash_code += "~" + share_fields[cntr]
						}
					}
				}
			else
				{
				stash_code += "~~" + skin
				}
			}
		active_tab = "share"
		//alert("load_share_frames('"+skin+"') with " + stash_code)
		document.getElementById("player_frame").src = stash_code
		}
	else
		{
		alert("You have no shared movies or albums to view.  We'll take you to the\nhome page where you can find out more about shared movies.")
		document.location = "/index.stm"
		//alert(document.location)
		}
	}
}

function load_share_frames_compiled(skin)
{
/*Sara this was added by chad to prevent macs from using the compiled version.*/
if(browser_platform == "Mac")
	{
	load_share_frames(skin)
	return
	}

if (share_fields[2] == "s")
	{
	load_share_frames(skin)
	return
	}
if(is_intelMac != 1)
	{
	document.getElementById("player_frame").height = "740"
	if(share_code != "")
		{
		if(share_code.indexOf("?f~") > -1)
			{
			stash_code = (sb_loc + "/sb_no_cache/sb_frames_compiled.htm" + share_code)
			}
		else
			{
			stash_code = (sb_loc + "/sb_no_cache/sb_frames_compiled.htm?s1~" + share_code)
			if(share_fields.length > 2)
				{
				for(cntr=2;cntr<share_fields.length;cntr++)
					{
					if(cntr==3)
						{
						stash_code += "~" + skin + "~" + share_fields[cntr]
						}
					else
						{
						stash_code += "~" + share_fields[cntr]
						}
					}
				}
			else
				{
				stash_code += "~~" + skin
				}
			}
		active_tab = "share"
		//alert("load_share_frames_compiled('"+skin+"') with " + stash_code)
		document.getElementById("player_frame").src = stash_code
		}
	else
		{
		alert("You have no shared movies or albums to view.  We'll take you to the\nhome page where you can find out more about shared movies.")
		document.location = "/index.stm"
		}
	}
}


function show_new_skin(skin)
{
for(cntr=0;cntr<skins_array.length;cntr++)
if(skin == skins_array[cntr])
	{
	document.getElementById("new_skin_img").src="/images/ele-stash-options-"+skin+".gif"
	}
}

function select_new_skin(skin)
{
selected_skin = skin
for(cntr=0;cntr<skins_array.length;cntr++)
	{
	document.getElementById(skins_array[cntr]).checked = false
	if(skin == skins_array[cntr])
		{
		document.getElementById(skin).checked = true
		document.getElementById("new_skin_img").src="/images/ele-stash-options-"+skin+".gif"
		}
	}
}

function save_new_skin()
{
document.getElementById("options").style.visibility = "hidden"
//if(code=="5099970544")alert(original_skin+"\n"+selected_skin)
if(selected_skin != original_skin)
	{
	original_skin = selected_skin
	set_special_cookie("skin",selected_skin,365)
	if(active_tab == "stash")
		{
		load_stash_frames(selected_skin)
		}
	else if(active_tab == "share")
		{
		if(!GetCookie("demo") && !GetCookie("homemovie"))
			{
			load_share_frames_compiled(selected_skin)		
			}
		else if(diff_domain == 1)
			{
			load_share_frames_compiled(selected_skin)		
			}
		else
			{
			load_share_frames(selected_skin)
			}
		}
	}
}


function show_drive_options()
{
if(GetCookie("homemovie"))
	{
	try
		{
		player_frame.upper.show_drive_bubble()		
		}
	catch(err)
		{
		if(code=="5099970544" || code=="0509996989")
			{
			alert (err.description)
			}
		else
			{
			alert("We apologize, this option is not available in this configuration.")
			}
		}
	}
else
	{
	alert("Please login first and try this option again.")
	}
}


function show_options()
{
if(document.getElementById("options"))
	{
	if (document.getElementById("options").style.visibility == "visible")
		{
		hide_options()
		}
	else
		{
		set_layer_vis('visible','options')
		}
	}
}

function hide_options()
{
select_new_skin(original_skin)
set_layer_vis('hidden','options')
}

function load_stash_options_menu(layer_id,obj)
{
var layer = document.getElementById(layer_id)
var curleft = adjleft = curtop = curheight = curwidth = menuwidth = 0;
curheight = obj.height
curwidth = obj.width
menuwidth = (layer.style.width).replace("px","")
if(curheight == "")
	{
	curheight = 20
	}
if(curwidth == "")
	{
	curwidth = 65
	}
if (layer.style.visibility == "hidden")
	{
	if (obj.offsetParent)
		{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
			{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
			layer.style.top = (curtop + curheight) + "px"
			adjleft = (eval(curwidth) - eval(menuwidth))/2
			layer.style.left = (eval(curleft) + eval(adjleft)) + "px"
			// alert(layer.style.left + " = " + eval(curleft) + " + ((" + eval(curwidth) + " + " + eval(menuwidth) + ") / 2)")
			set_layer_vis('visible',layer_id,"nav_menu_settings")
			set_layer_vis('hidden','options','nav_menu_stash','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
			if(typeof(active_tab) != "undefined")
				{
				var vis_layer = "nav_menu_"+active_tab
				//set_layer_vis('visible',vis_layer)
				}
			}
		}
	}
else
	{
	set_layer_vis('hidden',layer_id,'options','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
	}
}

function load_stash_help_menu(layer_id,obj)
{
var layer = document.getElementById(layer_id)
var curleft = adjleft = curtop = curheight = curwidth = menuwidth = 0;
curheight = obj.height
curwidth = obj.width
menuwidth = (layer.style.width).replace("px","")
if(curheight == "")
	{
	curheight = 20
	}
if(curwidth == "")
	{
	curwidth = 65
	}


if (layer.style.visibility == "hidden")
	{
	if (obj.offsetParent)
		{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
			{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
			layer.style.top = (curtop + curheight) + "px"
			adjleft = (eval(curwidth) - eval(menuwidth))/2
			layer.style.left = (eval(curleft) + eval(adjleft)) + "px"

//			alert(layer.style.left)
			// alert(layer.style.left + " = " + eval(curleft) + " + ((" + eval(curwidth) + " + " + eval(menuwidth) + ") / 2)")
			set_layer_vis('visible',layer_id)
			set_layer_vis('hidden','faq_list','nav_menu_settings','nav_menu_stash','nav_menu_stash_upgrade','nav_menu_share','nav_menu_overview','nav_menu_account','nav_menu_tapes','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
			if(typeof(active_tab) != "undefined")
				{
				if(active_tab == "stash" || active_tab == "share")
					{
					var vis_layer = "nav_menu_help_"+active_tab
					set_layer_vis('visible',vis_layer)
					}
				}
			}
		}
	}
else
	{
	set_layer_vis('hidden',layer_id,'faq_list','nav_menu_settings','nav_menu_stash','nav_menu_stash_upgrade','nav_menu_share','nav_menu_overview','nav_menu_account','nav_menu_tapes','nav_menu_help_stash','nav_menu_help_share','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
	if(document.getElementById("account_pages") && document.getElementById("account_pages").style.visibility == "visible")
		{
		if(document.getElementById("account_frame") && String(document.getElementById("account_frame").src).indexOf("tape-drive"))
			{
			set_layer_vis('visible','nav_menu_tapes')
			}
		else
			{
			set_layer_vis('visible','nav_menu_account')
			}
		}
	else if(typeof(active_tab) != "undefined")
		{
		var vis_layer = "nav_menu_"+active_tab
		set_layer_vis('visible',vis_layer)
		}
	}
}


function load_stash_help()
{
var help_url = "/support/help-edit-main.stm"
var options = 'dependent=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
options = options + ',width=1010'
options = options + ',height=690'
options = options + ',screenX=0,screenY=0,left=0,top=0';
try
	{
	if(help_window == null)
		{
		help_window = window.open(help_url,'help',options)
		}
	else if(help_window.closed == false)
		{
		help_window.focus()
		}
	else
		{
		help_window = window.open(help_url,'help',options)
		}
	}
catch(err)
	{
	help_window = window.open(help_url,'help',options)
	}
}


function load_share_help()
{
//player_frame.upper.show_help()
load_stash_help()
}

function cg_test()  //comes directly here after clicking send in tapes from the exe.
{
//Not able to set visibility property because it is to intensive and doesnt seem to work on some accounts, added z-Index stuff as a fix

document.getElementById("stashbox_player").style.zIndex = 30

//the setting of the .left property to 900 for hiding and to 0 for showing.
switch_page("tapes")
}


function switch_page(tab,cond,skip)
{
if(skip != 1 && tab == "shares" && GetCookie("homemovie") && share_code == "")
	{
	post_reload_cust_script = "switch_page('"+ tab + "','',1)"
	hold_chr = cust_script_path + code + ".js"
	loadjs(hold_chr)
	return
	//share_code = "3dr39h35g6"
	}
else if(skip == 1)
	{
	share_code = cust_share
	}


if(GetCookie("homemovie"))
	{
	document.getElementById("logged").style.visibility = "visible"
	document.getElementById("not-logged").style.visibility = "hidden"
	}
else
	{
	if(document.getElementById("not-logged"))
		{
		document.getElementById("not-logged").style.visibility = "visible"
		document.getElementById("logged").style.visibility = "hidden"
		}
	}
if (tab=="stash")
	{
	// alert("tab is " + tab +"\n"+ "active_tab is " + active_tab +"\n"+ "code is " + code)
	if(GetCookie("homemovie") || GetCookie("demo"))
		{
		if(GetCookie("demo") && document.getElementById("right_col_frame") && document.getElementById("right_col_frame").src != "/includes/mystash-box-demo.stm")
			{
			document.getElementById("right_col_frame").src = "/includes/mystash-box-demo.stm"
			}
		else if(document.getElementById("right_col_frame") && document.getElementById("right_col_frame").src != "/includes/mystash-box-stash.stm")
			{
			document.getElementById("right_col_frame").src = "/includes/mystash-box-stash.stm"
			}
		if(document.getElementById("nav_menu_stash") && document.getElementById("nav_menu_stash").style.visibility != "visible")
			{
			document.getElementById("central").style.height = "740px"
			set_layer_vis('visible','stashbox_player','nav_menu_stash')			
			set_layer_vis('hidden','nav_menu_settings','nav_menu_stash_upgrade','nav_menu_share','nav_menu_overview','account_pages','nav_menu_account','nav_menu_tapes','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
			if(active_tab != "stash")
				{
				if(share_fields[0] == "f")
					{
					active_tab = "stash"
					load_stash_frames(selected_skin)
					}
				else if(typeof(player_frame) != "undefined" && typeof(player_frame.upper) != "undefined" && typeof(player_frame.upper.sb_data_loaded) != "undefined")
					{
					var_settings = ("In Sara's function: switch_page(\"stash\")")
					var_settings += ("\nprevious tab = \"" + active_tab + "\"")
					var_settings += ("\nselected_skin = " + selected_skin)
					var_settings += ("\nhomemovie cookie = " + GetCookie('homemovie'))
					//var_settings += ("\nload_shares_next = " + load_shares_next)
					//var_settings += ("\nfeed_loading = " + feed_loading)
					//var_settings += ("\nshare_loading = " + share_loading)
					try
						{
						var_settings += ("\nsb_data_loaded = " + player_frame.upper.sb_data_loaded)
						}
					catch(err)
						{
						var_settings += ("\nsb_data_loaded = cannot be read")
						}
					if(code=="5099970544" || code=="0509996989") alert(var_settings)
					try
						{
						if(player_frame.upper.sb_data_loaded == 1 && GetCookie("homemovie"))
							{
							if(cond != 1)
								{
								active_tab = "stash"
								if(code=="5099970544" || code=="0509996989") alert("Sara's function now calling loadstash_tab(code).")
								player_frame.upper.loadstash_tab(code)
								if(code=="5099970544" || code=="0509996989") alert("The loadstash_tab(code) function is completed.")
								}
							}
						else
							{
							if(cond != 1)
								{
								active_tab = "stash"
								load_stash_frames(selected_skin)
								}
							}
						}
					catch(err)
						{
						if(code=="5099970544" || code=="0509996989") alert("Caught an error: "+err.description+".")
						if(cond != 1)
							{
							active_tab = "stash"
							if(code=="5099970544" || code=="0509996989") alert("Now calling Sara's load_stash_frames(selected_skin).")
							load_stash_frames(selected_skin)
							}
						}
					}
				else
					{
					if(cond != 1)
						{
						active_tab = "stash"
						load_stash_frames(selected_skin)
						}
					}
				}
			}
		}
	else
		{
		alert("You must be logged in order to view your stash.\n\nClick on \"login\" above to get to \"My Stash.\"")
		return
		}
	}
else if (tab=="shares")
	{
	if(need_ff_plugin == 1)
		{
		recommend_ff_plugin()
		return
		}
	if(load_shares_next == 1)
		{
		if(GetCookie("vs_guest"))
			{
			share_code = GetCookie("vs_guest")
			hold_chr = tape_script_path + "share_scripts/Afiniti%203/" + share_code + ".js"
			loadjs(hold_chr)
			check_time = window.setInterval("check_share_code()",500)
			return
			}
		else
			{
			if(share_fields[0] == "f")
				{
				// alert("You have no shared movies or albums on your account.\n\nHowever, you can still view the feed that you followed.")
				share_code = (document.location.search).toString()
				feed_loading = 1
				load_shares_next = 0
				switch_page("shares")
				return
				}
			else if(share_fields[0] == "share")
				{
				// alert("You have no shared movies or albums on your account.\n\nHowever, you can still view the share(s) from the email link that you followed.")
				share_code = share_fields[1]
				share_loading = 1
				load_shares_next = 0
				switch_page("shares")
				return
				}
			}
		}

	if(share_code != "" || GetCookie("demo"))
		{
		try
			{
			//added on 5-7-08 to force load of quick player for shares viewed from share link
			if(String(document.location).indexOf("/shares.stm?") != -1 && String(document.location).indexOf("~s~") == -1 )
				{
				active_tab = "share"
				load_share_frames_compiled(selected_skin)
				return
				}
			}
		catch(err)
			{
			}

		
		if(GetCookie("demo") && document.getElementById("right_col_frame") && document.getElementById("right_col_frame").src != "/includes/mystash-box-demo.stm")
			{
			document.getElementById("right_col_frame").src = "/includes/mystash-box-demo.stm"
			}
		else if(document.getElementById("right_col_frame") && document.getElementById("right_col_frame").src != "/includes/mystash-box-stash.stm")
			{
			document.getElementById("right_col_frame").src = "/includes/mystash-box-stash.stm"
			}
		if(document.getElementById("nav_menu_share") && document.getElementById("nav_menu_share").style.visibility != "visible")
			{
			document.getElementById("central").style.height = "740px"
			set_layer_vis('visible','stashbox_player','nav_menu_share')

			set_layer_vis('hidden','nav_menu_settings','nav_menu_stash','nav_menu_stash_upgrade','nav_menu_overview','account_pages','nav_menu_account','nav_menu_tapes','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
			}
		if(feed_loading == 1)
			{
			feed_loading = 0
			load_shares_next = 1
			if(!GetCookie("homemovie") && !GetCookie("demo"))
				{
				active_tab = "share"
				load_share_frames_compiled(selected_skin)
				}
			else if(diff_domain == 1)
				{
				active_tab = "share"
				load_share_frames_compiled(selected_skin)
				}
			else
				{
				active_tab = "share"
				load_share_frames(selected_skin)
				}
			}
		else if(share_loading == 1)
			{
			share_loading = 0
			load_shares_next = 1
			if(!GetCookie("homemovie") && !GetCookie("demo"))
				{
				active_tab = "share"
				load_share_frames_compiled(selected_skin)
				}
			else if(diff_domain == 1)
				{
				active_tab = "share"
				load_share_frames_compiled(selected_skin)
				}
			else
				{
				active_tab = "share"
				load_share_frames(selected_skin)
				}
			}
		else if(active_tab != "share" || load_shares_next == 1)
			{
			load_shares_next = 0
			if(GetCookie("demo"))
				{
				active_tab = "share"
				load_share_frames(selected_skin)
				}
			else if(typeof(player_frame) != "undefined" && typeof(player_frame.upper) != "undefined" && typeof(player_frame.upper.sb_data_loaded) != "undefined")
				{
				var_settings = ("In Sara's function: switch_page(\"share\")")
				var_settings += ("\nprevious tab = \"" + active_tab + "\"")
				var_settings += ("\nselected_skin = " + selected_skin)
				var_settings += ("\nhomemovie cookie = " + GetCookie('homemovie'))
				//var_settings += ("\nload_shares_next = " + load_shares_next)
				//var_settings += ("\nfeed_loading = " + feed_loading)
				//var_settings += ("\nshare_loading = " + share_loading)
				try
					{
					var_settings += ("\nsb_data_loaded = " + player_frame.upper.sb_data_loaded)
					}
				catch(err)
					{
					var_settings += ("\nsb_data_loaded = cannot be read")
					}
				if(code=="5099970544" || code=="0509996989") alert(var_settings)
				try
					{
					if(player_frame.upper.sb_data_loaded == 1 && GetCookie("homemovie"))
						{
						active_tab = "share"
						if(code=="5099970544" || code=="0509996989") alert("Sara's function now calling loadshare_tab(share_code).")
						player_frame.upper.loadshare_tab(share_code)
						if(code=="5099970544" || code=="0509996989") alert("The loadshare_tab(share_code) function is completed.")
						}
					else
						{
						if(!GetCookie("homemovie") || diff_domain == 1)
							{
							active_tab = "share"
							load_share_frames_compiled(selected_skin)
							}
						else
							{
							active_tab = "share"
							load_share_frames(selected_skin)
							}
						}
					}
				catch(err)
					{
					if(code=="5099970544" || code=="0509996989") alert("Caught an error: "+err.description+".")
					if(!GetCookie("homemovie") || diff_domain == 1)
						{
						active_tab = "share"
						if(code=="5099970544" || code=="0509996989") alert("Now calling Sara's load_share_frames_compiled(selected_skin).")
						load_share_frames_compiled(selected_skin)
						}
					else
						{
						active_tab = "share"
						if(code=="5099970544" || code=="0509996989") alert("Now calling Sara's load_share_frames(selected_skin).")
						load_share_frames(selected_skin)
						}
					}
				}
			else
				{
				if(!GetCookie("homemovie") || diff_domain == 1)
					{
					active_tab = "share"
					load_share_frames_compiled(selected_skin)
					}
				else
					{
					active_tab = "share"
					load_share_frames(selected_skin)
					}
				}
			}
		}
	else
		{
		alert("You have no shared movies or albums to view.")
		return
		}
	}
else if (tab=="account")
	{
//	alert("tab is " + tab +"\n"+ "active_tab is " + active_tab +"\n"+ "code is " + code)
	if(GetCookie("homemovie"))
		{
		reload_stats_for_sb()
		if(document.getElementById("right_col_frame").src != "/includes/mystash-box-account.stm")
			{
			document.getElementById("right_col_frame").src = "/includes/mystash-box-account.stm"
			}
		if(document.getElementById("account_frame").src != "/includes/mystash-my-account.stm")
			{
			document.getElementById("account_frame").src = "/includes/mystash-my-account.stm"
	 		document.getElementById("account_pages").style.height = "570px"
	 		document.getElementById("central").style.height = "570px"
			}
		if(document.getElementById("nav_menu_account").style.visibility != "visible")
			{
	 		document.getElementById("account_pages").style.height = "570px"
	 		document.getElementById("central").style.height = "570px"
			set_layer_vis('visible','account_pages','nav_menu_account')
			set_layer_vis('hidden','stashbox_player','nav_menu_settings','nav_menu_stash','nav_menu_stash_upgrade','nav_menu_share','nav_menu_overview','nav_menu_tapes','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
			}
		resize_layers()
		}
	else
		{
		alert("You must be logged in order to use \"My Account.\"\n\nClick on \"login\" above and then you can click on \"My Account.\"")
		return
		}
	}
else if (tab == "overview")
	{
//	alert("tab is " + tab +"\n"+ "active_tab is " + active_tab +"\n"+ "code is " + code)
	if(document.getElementById("right_col_frame").src != "/includes/mystash-box-overview.stm")
			{
			document.getElementById("right_col_frame").src = "/includes/mystash-box-overview.stm"
			}
	if(document.getElementById("nav_menu_overview").style.visibility != "visible")
		{
		document.getElementById("account_frame").src = "/includes/mystash-overview.stm"
 		document.getElementById("account_pages").style.height = "555px"
 		document.getElementById("central").style.height = "555px"
		set_layer_vis('visible','account_pages','nav_menu_overview')
		set_layer_vis('hidden','stashbox_player','nav_menu_stash','nav_menu_settings','nav_menu_stash_upgrade','nav_menu_share','nav_menu_account','nav_menu_tapes','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
		}
	else if(document.getElementById("account_frame").src != "/includes/mystash-overview.stm")
		{
		document.getElementById("account_frame").src = "/includes/mystash-overview.stm"
 		document.getElementById("account_pages").style.height = "555px"
 		document.getElementById("central").style.height = "555px"
		}
	}
else if(tab == "features")
	{
	document.getElementById("account_frame").src = "/content/pagetemplate-s.stm?fill-stashhelp"
	document.getElementById("account_pages").style.height = "555px"
	document.getElementById("central").style.height = "555px"
	set_layer_vis('visible','account_pages')
	set_layer_vis('hidden','stashbox_player')
	}
else if(tab == "upgrade_acct")
	{
	if(partner != "")
		{
		document.getElementById("account_frame").src = "/"+partner+"/includes/account-levels.stm"
		}
	else
		{
		document.getElementById("account_frame").src = "/content/account-levels.stm"
		}
	document.getElementById("account_pages").style.height = "750px"
	document.getElementById("central").style.height = "750px"
	set_layer_vis('visible',"nav_menu_stash_upgrade",'account_pages')
	set_layer_vis('hidden','stashbox_player','nav_menu_settings','nav_menu_stash','nav_menu_share','nav_menu_account','nav_menu_tapes','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
	}
else if (tab=="tapes")
	{
	if(partner_folder == "")
		{
		window.open ("http://www.stashspace.com/video-transfer/order-video-transfer.stm","send_in_tapes");
		return
		}
	//alert("tab is " + tab +"\n"+ "active_tab is " + active_tab +"\n"+ "code is " + code)
	if(document.getElementById("right_col_frame") && document.getElementById("right_col_frame").src != "/includes/mystash-box-account.stm")
		{
		document.getElementById("right_col_frame").src = "/includes/mystash-box-account.stm"
		}
	hold_chr = partner_folder + "/includes/tape-drive.stm"
	if(document.getElementById("account_frame") && document.getElementById("account_frame").src != hold_chr)
		{
		document.getElementById("account_frame").src = hold_chr
 		document.getElementById("account_pages").style.height = "740px"
 		document.getElementById("central").style.height = "740px"
		set_layer_vis('visible','account_pages','nav_menu_tapes')
		set_layer_vis('hidden','stashbox_player','nav_menu_settings','nav_menu_stash','nav_menu_stash_upgrade','nav_menu_share','nav_menu_overview','nav_menu_account','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
		}
	else if(document.getElementById("account_frame") && document.getElementById("account_frame").src == hold_chr)
		{
		set_layer_vis('visible','account_pages','nav_menu_tapes')
		set_layer_vis('hidden','stashbox_player','nav_menu_settings','nav_menu_stash','nav_menu_stash_upgrade','nav_menu_share','nav_menu_overview','nav_menu_account','nav_menu_help_stash','nav_menu_help_share','menu_stash_help','faq_list','menu_stash_options','options','nav_menu_contact_stash','nav_menu_contact_share','contact_info','live_chat_contact')
		}
	resize_layers()
	}

chg_log_in_out()
}


function goto_whats_new()
	{
	switch_page("account")
	parent.document.getElementById("account_frame").src = "/includes/mystash-whats-new.stm"
	document.getElementById("account_pages").style.height = "675px"
 	document.getElementById("central").style.height = "665px"
	}


function goto_tapes()
	{
	switch_page("tapes")
	//switch_page("account")
	//parent.document.getElementById("account_frame").src = "/includes/tape-drive.stm"
	//document.getElementById("account_pages").style.height = "840px"
 	//document.getElementById("central").style.height = "840px"
	}


function goto_film()
	{
	switch_page("account")
	document.getElementById("account_frame").src = "/includes/mystash-film-transfer.stm"
	document.getElementById("account_pages").style.height = "1440px"
 	document.getElementById("central").style.height = "1440px"
	}

function goto_signup()
{
document.location = "/sign-up.stm"
}

var overview_frame_heights = new Array()
overview_frame_heights["howtostash"] = "675"
overview_frame_heights["whystash"] = "675"
overview_frame_heights["features"] = "665"
overview_frame_heights["pricing"] = "675"
overview_frame_heights["contactus"] = "655"

function overview_frame(frame)
{
if(frame == "features")
 {
 document.getElementById("account_frame").src ="/content/pagetemplate-s.stm?fill-stashhelp"
 document.getElementById("account_pages").style.height = overview_frame_heights[frame]+"px"
 document.getElementById("central").style.height = (eval(overview_frame_heights[frame]) - 10)+"px"
 }
else if(document.getElementById("account_frame"))
 {
 document.getElementById("account_frame").src = "/includes/mystash-overview-"+frame+".stm"
 document.getElementById("account_pages").style.height = overview_frame_heights[frame]+"px"
 document.getElementById("central").style.height = (eval(overview_frame_heights[frame]) - 10)+"px"
 }
}



