/* Copyright (c) Fotki Inc */

function TopNav () {
}
TopNav.not_text_only_menu = 1;
TopNav.closing = 0;
TopNav.closing1 = 0;
TopNav.s_closing = 0;
TopNav.allMenuItems = new Array();
TopNav.dev = null;
TopNav.staging = null;
TopNav.timeOuts = new Array;
TopNav.timeOuts["top_menu_selector"] = 0;
TopNav.text_only = 1;
TopNav.hide_menu_items = 0;
if (Core.isDev()) {
TopNav.dev = ".dev.";
} else if (Core.isStaging()) {
TopNav.dev = ".staging.";
} else {
TopNav.dev = "";
}
if (profile_type_value == null || profile_type_value == "") {
var profile_type_value = "My";
}
var login_logut;
var about_url = null;
if (is_member && is_member == 1) {
login_logut = 'ilogout';
about_url = 'about/';
} else {
login_logut = 'ilogin';
about_url = '';
}
TopNav.allMenuItems["ihome"]		= [ LangDict.translateToken('TopNav.FotkiHome'), 'http://www.fotki.com',    LangDict.translateToken('TopNav.FotkiHome')	];
TopNav.allMenuItems["imyfotki"]	= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Fotki'),  'http://my.fotki.com', LangDict.translateToken('TopNav.' + profile_type_value + 'Fotki')  ];
TopNav.allMenuItems["imyfotkifeed"]  = [ LangDict.translateToken('TopNav.MyFotkiFeed'),  'http://friends.fotki.com/feed/', LangDict.translateToken('TopNav.MyFotkiFeed')  ];
TopNav.allMenuItems["ialbums"]	= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Albums'),	'http://public.fotki.com',	LangDict.translateToken('TopNav.' + profile_type_value + 'Albums')	];
TopNav.allMenuItems["icomments"]	= [  LangDict.translateToken('TopNav.Comments'),	'http://comments.fotki.com/##username##',	LangDict.translateToken('TopNav.Comments') ];
TopNav.allMenuItems["itags"]	= [LangDict.translateToken('TopNav.' + profile_type_value + 'Tags'),		'http://search.fotki.com/##username##', LangDict.translateToken('TopNav.' + profile_type_value + 'Tags') ];
TopNav.allMenuItems["imap"]	= [ LangDict.translateToken('TopNav.' + profile_type_value + 'FotkiMap'), 'http://maps.fotki.com/##username##',	LangDict.translateToken('TopNav.' + profile_type_value + 'FotkiMap') ];
TopNav.allMenuItems["imyvideo"]		= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Video'), 'http://video.fotki.com/##username##',	LangDict.translateToken('TopNav.' + profile_type_value + 'Video') ];
TopNav.allMenuItems["imylinks"]		= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Links'), 'http://links.fotki.com/##username##',	LangDict.translateToken('TopNav.' + profile_type_value + 'Links') ];
TopNav.allMenuItems["imyjournals"]	= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Journals'),	'http://journals.fotki.com/##username##',	LangDict.translateToken('TopNav.' + profile_type_value + 'Journals') ];
TopNav.allMenuItems["imyforums"]	= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Forums'),	'http://forum.fotki.com/##username##',	LangDict.translateToken('TopNav.' + profile_type_value + 'Forums') ];
TopNav.allMenuItems["iguestbook"]	= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Guestbook'),	'http://guestbooks.fotki.com', LangDict.translateToken('TopNav.' + profile_type_value + 'Guestbook')	];
TopNav.allMenuItems["imyfriends"]	= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Friends'),	'http://friends.fotki.com', LangDict.translateToken('TopNav.' + profile_type_value + 'Friends')	];
TopNav.allMenuItems["ibook"]		= [ LangDict.translateToken('TopNav.' + profile_type_value + 'AddrBook'),	'http://address.fotki.com', LangDict.translateToken('TopNav.' + profile_type_value + 'AddrBook')	];
TopNav.allMenuItems["iemail"]		= [ LangDict.translateToken('TopNav.' + profile_type_value + 'Email'),			'http://mail.fotki.com',	LangDict.translateToken('TopNav.' + profile_type_value + 'Email') ];
TopNav.allMenuItems["isearch"]	= [ LangDict.translateToken('TopNav.Search'),	'http://search.fotki.com',      LangDict.translateToken('TopNav.Search') ];
TopNav.allMenuItems["ilinks"]		= [ LangDict.translateToken('TopNav.Links'),       'http://all-links.fotki.com',   LangDict.translateToken('TopNav.Links') ];
TopNav.allMenuItems["ijournals"]	= [ LangDict.translateToken('TopNav.Journals'),    'http://journals.fotki.com',    LangDict.translateToken('TopNav.Journals') ];
TopNav.allMenuItems["icontests"]	= [ LangDict.translateToken('TopNav.Contests'),		'http://contests.fotki.com',   LangDict.translateToken('TopNav.Contests') ];
TopNav.allMenuItems["iblog"]		= [ LangDict.translateToken('TopNav.FotkiBlog'),	'http://journals.fotki.com/fotkicom/fotkiblog', LangDict.translateToken('TopNav.FotkiBlog') ];
TopNav.allMenuItems["ifotkieeblog"]	= [ LangDict.translateToken('TopNav.FotkiEstoniaBlog'),	'http://journals.fotki.com/fotkiestonia', LangDict.translateToken('TopNav.FotkiEstoniaBlog') ];
TopNav.allMenuItems["iaccount"]	= [ LangDict.translateToken('TopNav.MyAccount'),	'http://myaccount.fotki.com',	LangDict.translateToken('TopNav.MyAccount')	];
TopNav.allMenuItems["istatistics"]	= [ LangDict.translateToken('TopNav.MyStats'),		'http://stats.fotki.com',		LangDict.translateToken('TopNav.MyStats')	];
TopNav.allMenuItems["ihistory"]		= [ LangDict.translateToken('TopNav.OrderHistory'),'http://cart.fotki.com/history', LangDict.translateToken('TopNav.OrderHistory')	];
TopNav.allMenuItems["iselling"]		= [ LangDict.translateToken('TopNav.Selling'),		'http://selling.fotki.com',	LangDict.translateToken('TopNav.Selling')	];
TopNav.allMenuItems["ishop"]		= [ LangDict.translateToken('TopNav.ShoppingCart'),	'http://cart.fotki.com',		LangDict.translateToken('TopNav.ShoppingCart')	];
TopNav.allMenuItems["ihelp"]		= [ LangDict.translateToken('TopNav.Help'),            'http://help.fotki.com',  		LangDict.translateToken('TopNav.Help')      ];
TopNav.allMenuItems["iservice"]	= [ LangDict.translateToken('TopNav.Support'),		'http://myaccount.fotki.com/customer_service',	LangDict.translateToken('TopNav.Support') ];
TopNav.allMenuItems["ilogout"]	= [ LangDict.translateToken('TopNav.Logout'),		'http://logout.fotki.com',	LangDict.translateToken('TopNav.Logout')	];
TopNav.allMenuItems["ilogin"]	= [ LangDict.translateToken('TopNav.Login'),		'http://login.fotki.com',	LangDict.translateToken('TopNav.Login')	];
TopNav.allMenuItems["inavigation"]	= [ LangDict.translateToken('TopNav.GoTo'),		'http://fotki.com',	LangDict.translateToken('TopNav.GoTo')	];
TopNav.allMenuItems["iprofile"]	= [ LangDict.translateToken('TopNav.MyProfile'),		'http://members.fotki.com/##username##' + about_url,	LangDict.translateToken('TopNav.MyProfile')	];
TopNav.allMenuItems["idownloads"]	= [ LangDict.translateToken('TopNav.Downloads'),		'http://downloads.fotki.com',	LangDict.translateToken('TopNav.Downloads')	];
TopNav.allMenuItems["ifotkiforums"]   = [ LangDict.translateToken('TopNav.FotkiForums'),      'http://forum.fotki.com/fotkicom', LangDict.translateToken('TopNav.FotkiForums')  ];
TopNav.allMenuItems["imyguests"]   = [ LangDict.translateToken('TopNav.' + profile_type_value + 'Guests'),      'http://guests.fotki.com/##username##', LangDict.translateToken('TopNav.' + profile_type_value + 'Guests')  ];
TopNav.allMenuItems["imyhostimages"]		= [ LangDict.translateToken('TopNav.HostImages'),            'http://host.fotki.com',  		LangDict.translateToken('TopNav.HostImages' )      ];
TopNav.open_menu_id = -1;
if (if_regional_page_eq == 'ee') {
TopNav.default_top_menu_items = ['ihome', 'imyfotki', 'ialbums', 'ijournals', 'icontests', 'isearch'];
} else {
TopNav.default_top_menu_items = ['ihome', 'imyfotki', 'ialbums', 'ijournals', 'icontests', 'isearch', 'ihelp'];
}
var domain_prefix  = Core.getDomainPrefix();
var layouts_editor = '';
if ( if_regional_page_eq.match(/^(us|ca|ee|lt|lv|de|fr|it|es|fi|no|se|dk|sw|ua|pl)$/) || domain_prefix.match(/^(dev\.|staging\.)$/)) {
}
if (if_regional_page_eq == 'ee') {
TopNav.all_top_menu_items = ['ihome', '-', 'imyfotki', 'imyfotkifeed', '-', 'iprofile', 'ialbums', 'icomments', 'itags', 'imap', 'imyvideo', 'imylinks', 'imyjournals', 'imyforums', 'imyfriends', 'iguestbook', 'imyguests',  'imyhostimages', '-', 'ibook', 'iemail', '-', 'isearch', 'ifotkieeblog', 'icontests', '-', 'iaccount', 'istatistics', layouts_editor, '-', login_logut];
} else {
TopNav.all_top_menu_items = ['ihome', '-', 'imyfotki', 'imyfotkifeed', '-', 'iprofile', 'ialbums', 'icomments', 'itags', 'imap', 'imyvideo', 'imylinks', 'imyjournals', 'imyforums', 'imyfriends', 'iguestbook', 'imyguests', 'imyhostimages', '-', 'ibook', 'iemail', '-', 'isearch', 'ilinks', 'ijournals', 'icontests', 'iblog', 'ifotkiforums', 'idownloads', 'ishop', 'ihelp', 'iservice', '-', 'iaccount', 'istatistics', 'ihistory', 'iselling', layouts_editor, '-', login_logut];
}
TopNav.menu_size = -1;
TopNav.biggerMenu = function() {
TopNav.default_top_menu_items.push('ihome');
var expdate = new Date();
fixDate(expdate);
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000)*365);
setCookie("menu_size", TopNav.default_top_menu_items.length, expdate, '/', '.fotki.com');
TopNav.menu_size = -1;
Core.flushElementCache();
}
TopNav.smallerMenu = function() {
var expdate = new Date();
fixDate(expdate);
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000)*365);
TopNav.default_top_menu_items.pop();
setCookie("menu_size", TopNav.default_top_menu_items.length, expdate, '/', '.fotki.com');
TopNav.menu_size = -1;
Core.flushElementCache();
}
TopNav.isCurrentlyUsed = function(item) {
var found = 0;
for (var i in TopNav.default_top_menu_items) {
if (TopNav.default_top_menu_items[i] == item) {
found = 1;
}}
return found;
}
TopNav.isCurrentlySelected = function(item) {
if (TopNav.open_menu_id != -1) {
if (item == TopNav.default_top_menu_items[TopNav.open_menu_id]) {
return 1;
} else {
return 0;
}} else {
return 0;
}}
TopNav.reCreateMenu = function() {
var msizemult = 7;
TopNav.isnotText = getCookie("top_nav");
if (TopNav.isnotText == "text_only") TopNav.text_only = 0;
if (TopNav.menu_size == -1 ) {
TopNav.menu_size = getCookie("menu_size");
if (TopNav.menu_size == null) {
TopNav.menu_size = -1;
} else {
TopNav.default_top_menu_items = TopNav.default_top_menu_items.slice(0, TopNav.menu_size);
}}
for (var i = 0; (TopNav.menu_size != -1 ? i < TopNav.menu_size : i < TopNav.default_top_menu_items.length ); i++) {
var cookie = getCookie("top_menu_" + i);
if (cookie != null) {
TopNav.default_top_menu_items[i] = cookie;
}
if (TopNav.default_top_menu_items[i] == null) {
TopNav.default_top_menu_items[i] = 'ihome';
}}
var e = Core.getElementU('navigation');
var cell_width = 0;
if (Core.getClassName('top_nav_select') == 'text_only') {
cell_width = '';
} else {
cell_width = ' style="width:' + Core.round( 99 / (TopNav.default_top_menu_items.length + 1) - 1) + '%;"';
}
if (e != null) {
var menu = TopNav.allMenuItems["inavigation"];
var new_navigation = "<div id=\"sub\">\n";
if (Core.getClassName('top_nav_select') == 'text_only')  {
cell_width = '';
} else if (Core.getClassName('top_nav_select') == 'pics_only')  {
cell_width = ' style="width:' + Core.round( 99 / (TopNav.default_top_menu_items.length + 1) - 1) + '%;"';
} else {
cell_width= ' style="min-width:' + menu[0].length*msizemult +'px;width:' + Core.round( 99 / (TopNav.default_top_menu_items.length + 1) - 1) + '%;"';
}
new_navigation += "<div" + cell_width + "><a title='" + menu[2] + "' alt='" + menu[2] + "' href=\"javascript:TopNav.createGotoMenu();DropMenu.show('goto_menu','goto_menu_td',0,0);\" class='menu_a inavigation' onmouseout=\"javascript:DropMenu.hide('goto_menu');\" id=\"goto_menu_td\"><span><u id='td_goto'></u></span><b>" + menu[0] + "</b></a></div>\n";
for (var i = 0; (TopNav.menu_size != -1 ? i < TopNav.menu_size : i < TopNav.default_top_menu_items.length); i++) {
var menu_id = TopNav.default_top_menu_items[i];
var menu = TopNav.allMenuItems[TopNav.default_top_menu_items[i]];
if (menu != null) {
var href = menu[1];
href = Core.localizeURL(href);
if (Core.getClassName('top_nav_select') == 'text_only')  {
cell_width = '';
} else if (Core.getClassName('top_nav_select') == 'pics_only')  {
cell_width = ' style="width:' + Core.round( 99 / (TopNav.default_top_menu_items.length + 1) - 1) + '%;"';
} else {
cell_width= ' style="min-width:' + menu[0].length*msizemult +'px;width:' + Core.round( 99 / (TopNav.default_top_menu_items.length+1 ) - 1) + '%;"';
}
new_navigation += "<div" + cell_width + " onMouseover=\"TopNav.mouseover('td" + i + "')\" onMouseout=\"TopNav.mouseout('td" + i + "')\" id=td" + i + "><a href='" + href + "' title='" + menu[2] + "' alt='" + menu[2] + "' class=\"menu_a " + menu_id +"\" id=" + "top_menu_" + i + "><span><u></u></span><b>" + menu[0] + "</b></a><a href=\"javascript:TopNav.reCreateTopMenuSelector('"+i+"');DropMenu.show('top_menu_selector','" + "tdi" + i + "',0,8);\" class=\"tdi\" id=tdi" + i + "></a></div>\n";
}}
new_navigation += '</div>\n';
e.innerHTML = new_navigation;
} else {
Logger.log("error creating top navigation");
}}
TopNav.removeItem = function(m_id) {
TopNav.default_top_menu_items.splice(m_id, 1);
var expdate = new Date();
fixDate(expdate);
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000)*365);
for (i=0; i<TopNav.default_top_menu_items.length; i++) {
setCookie("top_menu_" + i, TopNav.default_top_menu_items[i], expdate, '/', '.fotki.com');
}
setCookie("menu_size", TopNav.default_top_menu_items.length, expdate, '/', '.fotki.com');
TopNav.menu_size = -1;
Core.flushElementCache();
TopNav.reCreateMenu();
}
TopNav.reCreateTopMenuSelector = function(m_id) {
var menu = Core.getElementU('top_menu_selector');
if (menu != null) {
var new_menu = "";
for (var i = 0; i<TopNav.all_top_menu_items.length; i++) {
if (TopNav.all_top_menu_items[i] != '-') {
if(TopNav.all_top_menu_items[i] != '') {
var menu_id = "top_menu_selection_" + i;
var menu_item = TopNav.allMenuItems[TopNav.all_top_menu_items[i]];
var menu_title = (menu_item != null) ? menu_item[0] : TopNav.all_top_menu_items[i];
new_menu += "<li class='" + (TopNav.isCurrentlyUsed(TopNav.all_top_menu_items[i]) ? "used text4b" : "") + " " + (TopNav.isCurrentlySelected(TopNav.all_top_menu_items[i]) ? "selected text4b" : "") + "' id=" + menu_id + "><a href=\"javascript:TopNav.switch_navigation_item('" + TopNav.all_top_menu_items[i] + "','"+m_id+"');\">" + menu_title + "</a></li>\n";
}} else {
new_menu += '<li id="menu_seporator"><i>...</i></li>\n';
}}
new_menu += '<li id="menu_seporator"><i>...</i></li>\n';
new_menu += '<li class="top_nav_remove_me"><a href=\"javascript:TopNav.removeItem(' + m_id + ')\">' + LangDict.translateToken('TopNav.RemoveItem') + "</a></li>\n";
menu.innerHTML = new_menu;
} else {
Logger.log("error creating selection menu");
}}
TopNav.createGotoMenu = function() {
var menu = Core.getElementU('goto_menu');
if (menu != null) {
var new_menu = "";
for (var i=0; i<TopNav.all_top_menu_items.length; i++) {
if (TopNav.all_top_menu_items[i] != '-') {
var menu_id = "goto_menu_selection_" + i;
var menu_item = TopNav.allMenuItems[TopNav.all_top_menu_items[i]];
var menu_title = (menu_item != null) ? menu_item[0] : TopNav.all_top_menu_items[i];
var menuhref = TopNav.allMenuItems[TopNav.all_top_menu_items[i]];
if (menuhref != null) {
var href = menuhref[1];
href = Core.localizeURL(href);
}
new_menu += "<li id=" + menu_id + "><a href=\"" + href  + "\">" + menu_title + "</a></li>\n";
} else {
new_menu += '<li id="menu_seporator"><i>...</i></li>\n';
}}
menu.innerHTML = new_menu;
} else {
Logger.log("error creating selection menu");
}}
TopNav.switch_navigation_item = function(to_item,menu_id) {
TopNav.open_menu_id = menu_id;
var expdate = new Date();
fixDate(expdate);
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000)*365);
setCookie("top_menu_" + TopNav.open_menu_id, to_item, expdate, '/', '.fotki.com');
TopNav.default_top_menu_items[TopNav.open_menu_id] = to_item;
DropMenu.hide('top_menu_selector');
Core.flushElementCache();
TopNav.reCreateMenu();
}
TopNav.mouseover = function(td_num) {
var td_id = Core.getElementU(td_num);
if (td_id.ieHover) {
clearTimeout(td_id.ieHover);
td_id.ieHover = 0;
} else {
td_id.className += 'hover';
if ( (td_num.substr( 0, 3) != 'tdi') && ( td_num != 'selector') ) {
var tdi = Core.getElementU('tdi' + td_num.substr( 2, 1));
var td_width =  Core.getElementWidth( td_num );
tdi.style.left = (td_width / 2) - 30 + 'px';
}}
}
TopNav.mouseout = function(td_num) {
var td_id = Core.getElementU(td_num);
td_id.ieHover = setTimeout(function () {
td_id.className = td_id.className.replace('hover', '');
td_id.ieHover = 0;
}, 50);
}
TopNav.switch_style = function(to){
Core.setClassName('top_nav_select', to);
TopNav.reCreateMenu();
Core.setClassName('st_full','');
Core.setClassName('st_pics_only','');
Core.setClassName('st_text_only','');
Core.addToClassName('st_' + to, 'st_sel');
TopNav.reCreateMenu();
var expdate = new Date();
fixDate(expdate);
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000)*365);
setCookie('top_nav', to,  expdate, "/", "." + fotki_hostname);
TopNav.reCreateMenu();
Core.flushElementCache();
}
TopNav.addToShoppingCartItemsCount = function(i) {
var items = Core.getText("shoppingcartitem") || 0;
items *= 1;
var is_empty = (items > 0 ? 0 : 1);
items += i;
if(items > 0) {
Core.setText("shoppingcartitem", items);
if(is_empty) {
Core.setClassName("shopping_cart", "shoppingcart");
Core.showElement("shoppingcartlabel");
}} else {
Core.hideElement("shoppingcartlabel");
Core.setText("shoppingcartitem", 0);
Core.setClassName("shopping_cart", "shoppingcartempty");
}}
TopNav.setToShoppingCartItemsCount = function(i) {
var items = Core.getText("shoppingcartitem") || 0;
items *= 1;
var is_empty = (items > 0 ? 0 : 1);
if(i > 0) {
Core.setText("shoppingcartitem", i);
if(is_empty) {
Core.setClassName("shopping_cart", "shoppingcart");
Core.showElement("shoppingcartlabel");
}} else {
Core.hideElement("shoppingcartlabel");
Core.setText("shoppingcartitem", 0);
Core.setClassName("shopping_cart", "shoppingcartempty");
}}

VGift = {
dlg           : null,
div_id        : 'virtgift_container',
loading_html  : "<div style='width:128px;padding:1px 6px;'><img src=http://images.fotki.com/ajax-loader.gif></div>",
progress_img  : "<img src=http://images.fotki.com:/progress.gif>",
error_html    : "<div style='color:red;padding:0 4px;font-size:11px;width:340px'><b>Temporary system error. Please reload page &#60;F5&#62;.</b></div>",
redirect_html : "<center style='padding:3px 6px 0 6px'><img src=http://images.fotki.com/ajax-loader.gif><br>" +
"<b style='font-size:11px;color:black'>Redirect to the payment page...</b></center>",
badword_msg   : "Inappropriate text found, please correct your text!",
curr_page     : 1,
prev_link_id  : 'prev_vg_link',
next_link_id  : 'next_vg_link',
init : function() {
if (!VGift.dlg) {
if(Core.getElementU(VGift.div_id) == null) {
var new_div = document.createElement("div");
new_div.setAttribute("id", VGift.div_id);
new_div.innerHTML = content; //div_content;
Core.getDocumentBody().appendChild(new_div);
Core.flushElementCache();
}
VGift.dlg = new ModalDialog(VGift.div_id);
}},
select : function(login) {
try {
VGift.init();
advAJAX.get({
url  : ('/_global/vgifts?ajax=selectvg&login='+login),
onLoading: function(obj) {
setTimeout('VGift.dlg.show();', 20);
VGift.dlg.setContent(VGift.loading_html);
},
onSuccess : function(obj) {
var response = obj.responseText;
if (response.match("error")) {
VGift.dlg.setContent(VGift.error_html);
} else {
VGift.dlg.setContent(response);
}},
onError  : function(obj) {
VGift.dlg.setContent(VGift.error_html);
}});
return true;
} catch(ex) {
return false;
}},
nextSelPage : function(login, pages_n, this_ref) {
try {
if (this.curr_page < pages_n) {
this.curr_page++;
} else {
return false;
}
advAJAX.get({
url  : ('/_global/vgifts?ajax=selectvgnextpage&login='+login+'&vgpg='+this.curr_page),
onLoading: function(obj) {
},
onSuccess : function(obj) {
var response = obj.responseText;
if (response.match("error")) {
VGift.dlg.setContent(VGift.error_html);
} else {
if (VGift.curr_page >= pages_n) Core.hideElement(this_ref);
if (VGift.curr_page > 1) Core.showElement(VGift.prev_link_id);
Core.setText('virtual_gift_cont', response);
}},
onError  : function(obj) {
VGift.dlg.setContent(VGift.error_html);
}});
return true;
} catch(ex) {
return false;
}},
prevSelPage : function(login, pages_n, this_ref) {
try {
if (this.curr_page > 1) {
this.curr_page--;
} else {
return false;
}
advAJAX.get({
url  : ('/_global/vgifts?ajax=selectvgnextpage&login='+login+'&vgpg='+this.curr_page),
onLoading: function(obj) {
},
onSuccess : function(obj) {
var response = obj.responseText;
if (response.match("error")) {
VGift.dlg.setContent(VGift.error_html);
} else {
if (VGift.curr_page <= 1) Core.hideElement(this_ref);
if (VGift.curr_page < pages_n) Core.showElement(VGift.next_link_id);
Core.setText('virtual_gift_cont', response);
}},
onError  : function(obj) {
VGift.dlg.setContent(VGift.error_html);
}});
return true;
} catch(ex) {
return false;
}},
order : function(vgid, login) {
try {
VGift.init();
advAJAX.get({
url    : ('/_global/vgifts'),
'ajax' : 'ordervg',
'vgid' : vgid,
'login': login,
onLoading: function(obj) {
VGift.dlg.setContent(VGift.loading_html);
},
onSuccess : function(obj) {
var response = obj.responseText;
if (response.match("error")) {
VGift.dlg.setContent(VGift.error_html);
} else {
VGift.dlg.setContent(response);
}},
onError  : function(obj) {
VGift.dlg.setContent(VGift.error_html);
}});
return true;
} catch(ex) {
return false;
}},
submit : function(this_ref) {
try {
VGift.init();
if(this_ref) this_ref.disabled = true;
Core.setText('warnmsg', '&nbsp;');
advAJAX.submit(document.getElementById("vg_form"), {
onSuccess : function(obj) {
var response = obj.responseText;
if (response.match("error")) {
VGift.dlg.setContent(VGift.error_html);
return false;
}
if (response.match("badword")) {
Core.setText('warnmsg', VGift.badword_msg);
return false;
}
if (response.match('url:')) {
var url = response.split('url:')[1];
VGift.dlg.setContent(VGift.redirect_html);
document.location.href = url;
return false;
} else {
if (Core.getElementU('uservglist') != null) {
Core.setText('uservglist', response);
}
VGift.dlg.hide();
}},
onFinalization : function(obj) {
if(this_ref) this_ref.disabled = false;
},
onError  : function(obj) {
VGift.dlg.setContent(VGift.error_html);
}});
return true;
} catch(ex) {
return false;
}},
show : function(id, login) {
try {
VGift.init();
advAJAX.get({
url     : ('/_global/vgifts'),
'ajax'  : "show_virtgift",
'vgid'  : id,
'login' : login,
onLoading: function(obj) {
VGift.dlg.setContent(VGift.loading_html);
setTimeout('VGift.dlg.show();', 20);
},
onSuccess : function(obj) {
var response = obj.responseText;
if (response.match("error")) {
VGift.dlg.setContent(VGift.error_html);
} else {
VGift.dlg.setContent(response);
}},
onError  : function(obj) {
VGift.dlg.setContent(VGift.error_html);
}});
return true;
} catch(ex) {
return false;
}},
togglePrivate : function(this_ref, user_vg, login) {
try {
VGift.init();
var lbl_id = '';
this_ref.disabled = true;
Core.getElementU('vgift_opt_form').disabled = true;
if (this_ref.value == 'on') {
this_ref.value = 'off';
lbl_id = 'lbl_make_public';
} else {
this_ref.value = 'on';
lbl_id = 'lbl_make_private';
}
advAJAX.get({
url               : ('/_global/vgifts'),
'ajax'            : 'save_vgift_opt',
'vgprivate_check' : this_ref.value,
'user_vg'         : ''+user_vg,
'login'           : login,
onLoading: function(obj) {
Core.showElement('progress_cont');
},
onSuccess : function(obj) {
var response = obj.responseText;
if (response.match("error")) {
VGift.dlg.setContent(VGift.error_html);
} else {
if (this_ref.value == 'on') {
Core.hideElement('lbl_make_private');
Core.showElement('lbl_make_public');
Core.showElement('privately_lbl');
} else {
Core.hideElement('lbl_make_public');
Core.showElement('lbl_make_private');
Core.hideElement('privately_lbl');
}
Core.hideElement('progress_cont');
}
this_ref.disabled = false;
Core.getElementU('vgift_opt_form').disabled = false;
},
onError  : function(obj) {
VGift.dlg.setContent(VGift.error_html);
}});
return true;
} catch(ex) {
return false;
}},
del : function(this_ref, user_vg, login) {
try {
VGift.init();
var r=confirm("Do you want to delete your virtual gift?");
if (r==true) {
if(this_ref) this_ref.disabled = true;
Core.getElementU('vgift_opt_form').disabled = true;
advAJAX.get({
url      : ('/_global/vgifts'),
'ajax'   : 'delete_vgift',
'user_vg': ''+user_vg,
'login'  : login,
onLoading: function(obj) {
setTimeout('VGift.dlg.show();', 20);
VGift.dlg.setContent(VGift.loading_html);
},
onSuccess : function(obj) {
var response = obj.responseText;
if (response.match("error")) {
VGift.dlg.setContent(VGift.error_html);
} else {
Core.setText('uservglist', response);
VGift.dlg.hide();
}},
onError  : function(obj) {
VGift.dlg.setContent(VGift.error_html);
}});
return true;
}} catch(ex) {
return false;
}}
}

