// JavaScript Document
function roller1(what,dir,f_type)
{var img = document.getElementById(what);
 var imgString = new String(img.src);
 var imgs = imgString.lastIndexOf("/");
 var imge = imgString.lastIndexOf("_");
  imgString = imgString.substr(imgs+1,imge-imgs-1)
 var the_url = 'images/vprofile/';
 var img_type = (f_type)? f_type : 'gif';
 var the_end = (dir == 1)? '_on.' + img_type : '_off.' + img_type;
 img.src = the_url + imgString + the_end;
 }
 
 function backer(x,id,img_name,have_repeat)
 {
  if (document.getElementById('left_column'))
  	{
	 document.getElementById('left_column').style.backgroundImage = 'url(images/vprofile/background1.jpg)';
	}
  if (document.getElementById('login_div'))
  	{
	 document.getElementById('login_div').style.backgroundImage = 'url(images/vprofile/background2.jpg)';
	}
  if (document.getElementById('prod_text_td'))
  	{
	 document.getElementById('prod_text_td').style.backgroundImage = 'url(images/vprofile/prod_detail_bk.jpg)';
	 document.getElementById('prod_text_td').style.backgroundRepeat = 'no-repeat';
	}
  if(x != null)
  	{
	 document.getElementById(x).style.backgroundImage = 'url(images/vprofile/shopping_bk.jpg)';
	 document.getElementById(x).style.backgroundRepeat = 'no-repeat';
	}
  if(id)
  	{
	 var bk_img = document.getElementById(id);
	 var img_url = 'url(images/vprofile/' + img_name + ')';
	 bk_img.style.backgroundImage = img_url;
	 bk_img.style.backgroundRepeat = (have_repeat == 0)? 'no-repeat' : 'repeat';
	 
	}
 }

var the_Pop_Up_window = null;
function newPopUpWin(the_url,win_name,the_width,the_height,bars)
{var final_width = (the_width == 0)? (screen.width - 20) : the_width; //pass 0 as value for the_width to set width to available screen size
 var final_height = (the_height == 0)? (screen.height - 100) : the_height; //same for height
 var settings = 'width=' + final_width + ',height=' + final_height + ',scrollbars=' + bars + ',left=5,top=5,resizable';
 the_Pop_Up_window = window.open(the_url,win_name,settings);
}

function divRoller(id,kolor)
{
 document.getElementById(id).style.backgroundColor = kolor;
}

var btn; //the edit button 
var btn_cancel; //the cancel button
var table1; // the table with info only
var table2; //the editable table
var resetter = 0; // test var used later
//showHide('btn_edit_this1','current_email','enter_email',1);
function showHide(btn_id,table_id1,table_id2,num)
{
 if(resetter > 0)//if an edit button has been pushed, but no info submitted, this will hide edit ability.
 	{
	 btn.style.display = 'block';
	 btn_cancel.style.display = 'none';
 	 table1.style.display = 'block';
 	 table2.style.display = 'none';
 	}
	btn = document.getElementById(btn_id);
	btn_cancel = document.getElementById(btn_id + '_cancel');
	table1 = document.getElementById(table_id1);
	table2 = document.getElementById(table_id2);
	btn.style.display = (num == 0)? 'block' : 'none';
	btn_cancel.style.display = (num == 1)? 'block' : 'none';
	table1.style.display = (num == 0)? 'block' : 'none';
	table2.style.display = (num == 1)? 'block' : 'none';
	resetter = 1;
}
function roller(id,source,which) //rollover function for images
{var the_url = (id.indexOf('btn') != -1)? 'images/buttons/' : 'images/common/';
 var _end = (which == 1)? '_on' : '_off';
 var elem = document.getElementById(id);
 elem.src = the_url + source + _end + '.gif';
}

//function for hiding recommended products on vresult page
var hr_array = new Array();
var hr_array_counter = 0;
var ben_array = new Array();
var ben_array_counter = 0;
//hr_hide_status = 0;
//ben_hide_status = 0;
var show_txt = 'Click the "+" to show your list of';
var hide_txt = 'Click the "-" to hide your list of';
var hr_txt = ' highly recommended products.';
var ben_txt = ' beneficial products.';
var plus_sign = '+';
var minus_sign = '-';
function makeDivList()
{
 var div_list = document.getElementsByTagName('div'); //alert(div_list[6].id); 
 for (i=0; i<div_list.length; i++)
 	{
		if(div_list[i].id.indexOf('hr_') != -1)
			{
				hr_array[hr_array_counter] = div_list[i]; 
				//alert('hr_array[' + hr_array_counter + '].id(' + hr_array[hr_array_counter].id + ') = div_list[' + i + '].id(' + div_list[i].id + ')');
				document.getElementById(hr_array[hr_array_counter].id).style.display = 'none';
				hr_array_counter++;
			}
		else if(div_list[i].id.indexOf('ben_') != -1)
			{
				ben_array[ben_array_counter] = div_list[i];
				document.getElementById(ben_array[ben_array_counter].id).style.display = 'none';
				ben_array_counter++;
			}
	}
}
function hideList(which,link_id,span_id)//hideList(0,'hr_plus','hr_span')
{
 if (which == 0)
 	{
	 for (d=0; d<hr_array.length; d++)
		{
		 var the_div = document.getElementById(hr_array[d].id);//alert('the_div = ' + the_div);
		 //alert('the_div.style.display = ' + the_div.style.display);
		 //alert('hr_hide_status = ' + hr_hide_status);
		 the_div.style.display = (the_div.style.display != 'block')? 'block':'none';//hr_hide_status == 0
		 //alert('the_div.style.display now = ' + the_div.style.display);
		}
	 document.getElementById(link_id).innerHTML = (the_div.style.display == 'block')? minus_sign : plus_sign;
	 document.getElementById(span_id).innerHTML = (the_div.style.display == 'block')? hide_txt + hr_txt : show_txt + hr_txt;
	 //hr_hide_status = (hr_hide_status == 0)? 1:0;
	}
	else if(which == 1)
	{
	 for (d=0; d<ben_array.length; d++)
		{
		 var the_div = document.getElementById(ben_array[d].id);
		 the_div.style.display = (the_div.style.display != 'block')? 'block':'none';
		}
	 document.getElementById(link_id).innerHTML = (the_div.style.display == 'block')? minus_sign : plus_sign;
	 document.getElementById(span_id).innerHTML = (the_div.style.display == 'block')? hide_txt + ben_txt : show_txt + ben_txt;
	
	}
}