var stName = '';
var stVal = '';
var puWin = '';
var lock_chbox;
var submit_chk;

function getBrowser(){
	if(document.ids)x='nc4';
	else if( document.all && !document.getElementById )x='ie4';
	else if( window.opera && !document.createElement )x='op5';
	else if( window.opera && window.getComputedStyle )  {
			  if(document.createRange)x='op8';
				else if(window.navigate)x='op7.5';
								 else x='op7.2'; }
	else if( window.opera && document.compatMode )x='op7';
	else if( window.opera && document.releaseEvents )x='op6';
	else if( document.contains && !window.opera )x='kq3';
	else if(window.pkcs11&&window.XML)x='f15';
	else if( window.getSelection && window.atob )x='nn7';
	else if( window.getSelection && !document.compatMode )x='nn6';
	else if( window.clipboardData && document.compatMode )
	  x=window.XMLHttpRequest? 'IE7' : 'IE6';
	else if( window.clipboardData ){x='ie5';
		 if( !document.createDocumentFragment ) x+='.5';
		 if( document.doctype && !window.print ) x+='m';}
	else if( document.getElementById && !document.all ) x='op4';
	else if( document.images && !document.all ) x='nn3';
	else if(document.clientWidth&&!window.RegExp)x='kq2';

	return x;
}

function validBrowser(){
	var browser = getBrowser();
	if(browser.indexOf('f') == -1) return false;
	return true;
}

// Set Cookie
function setCookie (dataStr, lifeTime) {
  var now = new Date();
  lifeTime = new Date(now.getTime() + lifeTime);
  document.cookie = dataStr + "; expires=" + lifeTime.toGMTString() + ";";
}

// Set setting
function setSetting (setName, setVal){
	// Run ajax
	var send_data = setName + '=' + setVal + '&event=set_setting&sid=' + sessionId;
	rq_res = makeR('/member/ajax_interface.php', '', send_data, 0);
	stName = setName;
	stVal  = setVal;
}
// Handle event after ajax
function hdlEvent (content){
	var matchStr = /\<event\>(.*)\<\/event\>\<result\>(.*)\<\/result\>\<ext\>(.*)\<\/ext\>/;
	matchStr.exec(content);
	evName   = RegExp.$1;
	evResult = RegExp.$2;
	evExt    = RegExp.$3;

	if (evResult){
		// msgbox autoopen
		if (stName == 'msgbox_auto_open'){
			if (document.getElementById('ao-bx-lnk') != null){
				msgAutoOpen = stVal;
				aoImgLnk = aoImageLnk (stVal);
				document.getElementById('ao-bx-lnk').innerHTML = aoImgLnk;
			}
		}
		// set readed msg
		else if (stName == 'set_readed'){
			msgAutoOpen = (evExt == 1) ? 1 : msgAutoOpenExt;
			checkNewMsg = 1;
			_status_request(requestData, 1);
		}
	}
}

// Set autoopen
function setMsgAutoOpen (aoFlag){
	setSetting ('msgbox_auto_open', aoFlag);
}

// Enable / disable a box with r/laquo
function showBox (tdId, clId){
	var tdObj =  document.getElementById(tdId);
	var clObj =  document.getElementById(clId);
	tdObj.style.display = "";
	clObj.innerHTML = '<a href="JavaScript:disBox (\'' + tdId + '\', \'' + clId + '\');" class="aquo">&laquo;</a>';
}

function disBox (tdId, clId){
	var tdObj =  document.getElementById(tdId);
	var clObj =  document.getElementById(clId);
	tdObj.style.display = "none";
	clObj.innerHTML = '<a href="JavaScript:showBox (\'' + tdId + '\', \'' + clId + '\');" class="aquo">&raquo;</a>';
}

// Set readed
function setReadedMsg (srMsg){
	hideDynMsg();

	msgLoadedMsg    = '';
	msgAvailable    = 0;
	document.getElementById('rq-hd-td').style.backgroundColor = 'transparent';
	document.getElementById('rq-msg-box').innerHTML = '';
	// Run ajax
	var send_data = 'set_viewed_msg=' + srMsg + '&event=set_readed&sid=' + sessionId;
	window.setTimeout ('makeR(\'/member/ajax_interface.php\', \'\', \'' + send_data + '\', 0);', 1000);
	stName = 'set_readed';
	stVal  = srMsg;
	// stop title animation
	stopAnim();
}

// Reply message
function replyMsg (srMsg) {
	popUpWindow('/popup.php?action=reply&target=' + srMsg, 'sendMsg', 660, 465);
	// stop title animation
	stopAnim();
}

function afterReply (srMsg){
	setReadedMsg(srMsg);
}

// PopUp
function popUpWindow(url, name, width, height){
	x = (window.screen.width - width) / 2;
	y = (window.screen.height - height) / 2;
	settings    = 'width=' + width + ',height=' + height + ',left=' + x + ',top=' + y + ',status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=auto';

	puWin = window.open(url, name, settings);
	window.setTimeout('puWin.focus()', 500);
}

// Update Mood
var moodTTId = '';
function updateMood (mood_name, mood_icon){
	if (document.getElementById ('mood-lnk') == null){
		return;
	}
	el = document.getElementById('mood-lnk');
	el.innerHTML = '<img src="/images/moods/' + mood_icon + '"  alt="" class="pngimg" style="width: 20px; height: 20px;" />';
	mood_tt_name = mood_name;
	setTT_Title (el, true);
}

// Update status
var statusTTId = '';
function updateStatus(content, pu){
	if (document.getElementById('status-lnk') == null) {
		return;
	}
	el = document.getElementById('status-lnk');
	var matchStr = /\<statusId\>(\d+)\<\/statusId\>/;
	matchStr.exec(content);
	statusId = RegExp.$1;
	//alert(content);

	if (status_id != statusId) {
		status_tt_name = statusName[statusId];
		el.innerHTML = '<img src="/images/status/' +  statusImg[statusId] + '" alt="" class="pngimg" style="width: 20px; height: 20px;" />';
		setTT_Title (el, true);
		status_id = statusId;
	}
}

function showTT (el){
	setTT_Style(el);
	setTT_Title(el);
}

// Tooltip style
function setTT_Style (el, shrt, str){
	el.T_BORDERCOLOR = '#4A8B2F';
	el.T_BGCOLOR     = '#eeeeee';
	el.T_FONTFACE    = 'verdana';
	//el.T_FONTSIZE    = '12px';
	//el.T_FONTWEIGHT  = 'bold';
	//el.T_SHADOWCOLOR = '#aaaaaa';
	//el.T_BORDERWIDTH = 2;
	el.T_PADDING     = 5;
	el.T_OFFSETY     = 25;
	if(str)
		el.T_WIDTH       = str.length * 6.5;
	else
		el.T_WIDTH       = 250;

	if (shrt) {
		el.T_WIDTH  = 70;
	}
}

function setTT_Title (el, replace) {
	if (el.id == 'mood-lnk'){
		if (replace && document.getElementById (moodTTId) != null){
			var tt = document.getElementById (moodTTId);
			var tt_htm = tt.innerHTML;
			tt.innerHTML = tt_htm.replace(/<mood_name>.+<\/mood_name>/i, '<mood_name>' + mood_tt_name + '</mood_name>');
		} else {
			el.T_TITLE = '<div style=\'padding-top: 2px; padding-bottom: 2px; color: #fff; font-weight: bold;\'>' + mood_tt_ttl + ': <mood_name>' + mood_tt_name + '</mood_name></div>';
		}
	} else if (el.id == 'status-lnk') {
		if (replace && document.getElementById (statusTTId) != null){
			var tt = document.getElementById (statusTTId);
			var tt_htm = tt.innerHTML;
			tt.innerHTML = tt_htm.replace(/<status_name>.+<\/status_name>/i, '<status_name>' + status_tt_name + '</status_name>');
			//alert (status_tt_name + "\n" + tt.innerHTML);
		} else {
			el.T_TITLE = '<div style=\'padding-top: 2px; padding-bottom: 2px; color: #fff; font-weight: bold;\'>' + status_tt_ttl + ': <status_name>' + status_tt_name + '</status_name></div>';
		}
	}
}

// Check file checkbox
function setCheckBox (id, form){
	if (id && document.getElementById(id) != null) {
		if (document.getElementById(id).checked)
			document.getElementById(id).checked = 0;
		else
			document.getElementById(id).checked = 1;

		if_any_checked(form);
	}
}

// function over file checkbox
var trColC = '';
function overTR (el){
	trColC = el.style.backgroundColor;
	el.style.backgroundColor = '#FFFFCC';
}

// function over file checkbox
function outTR (el){
	el.style.backgroundColor = trColC;
}

// get link
function getLink(link_id, id, sub_domain, sid)
{
	var link = um_domain;
	if (link_id == 1) link = 'http://www.' + um_domain + '/popup.php?action=message&target=' + id + '&ssn=' + sid;
	if (link_id == 2) link = 'http://www.' + um_domain + '/popup.php?action=to_friends&target=' + id + '&ssn=' + sid;
	if (link_id == 3) link = 'http://www.' + um_domain + '/popup.php?action=to_favorites&target=' + id + '&ssn=' + sid;
	return link;
}

function if_any_checked(forma) {
	if (document.forms[forma] != null){
		var f = document.forms[forma];
		var i;
		var selected;
		selected = 0;
		for(i = 0; i < f.elements.length; i++) {
			var c = f.elements[i];
			if((c.type) && (c.type.toLowerCase() == 'checkbox') && (c.checked == true)) {
				selected = 1;
			}
		}

		if (selected == 0) {
			submit_chk = false;
		} else {
			submit_chk = true;
		}
	}
}

function setInvitationStatus(srMsg, target){
	if (srMsg) {
		window.location.href = target + '&set_viewed_msg=' + srMsg;
	}
}

/* frontend functions */

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//open popup window for password
function mbOpenFileWindow (file_name, key, width, height, curUrl)
{
	var url         = '/password_popup.php?file=' + file_name + '&key=' + key;
	var settings    = 'width=' + width + ',height=' + height + ',left=100,top=150,status=yes,toolbar=no,menubar=no,location=no';
	window.open(url, 'FilePassword', settings);
	//window.opener.document.reload();
	 window.parent.location.reload()
	//window.location.href = curUrl;
}

//open popup window for password
function mbOpenFolderWindow (file_name, key, width, height, curUrl)
{
	var url         = '/password_popup.php?folder=' + file_name + '&key=' + key;
	var settings    = 'width=' + width + ',height=' + height + ',left=100,top=150,status=yes,toolbar=no,menubar=no,location=no';
	window.open(url, 'FolderPassword', settings);
	window.location.href = curUrl;
}

//open popup window for member search form
function mbOpenSearchWindow(width, height, url)
{
	var settings    = 'width=' + width + ',height=' + height + ',left=100,top=150,status=yes,toolbar=no,menubar=no,location=no,scrolling=auto';
	window.open(url, 'Search_form', settings);
}

//open popup window for member search form
function mbOpenMemberWindow(width, height, url)
{
	var settings    = 'width=' + width + ',height=' + height + ',left=100,top=150,status=yes,toolbar=no,menubar=no,location=no';
	window.open(url, 'Friend_List', settings);
}

//open popup window for Agb
function AgbPopUp(anhor, ads)
{
	var url = '/agb.php?popup=1';
	if (anhor != null) url += '#' + anhor;
	if (ads) url = '/ads' + url;
	var settings    = 'width=700,height=600,left=150,top=140,status=yes,toolbar=no,menubar=no,location=no,scrolling=auto,scrollbars=yes';
	window.open(url, 'AGB', settings);
}

//open popup window for Faq
function FaqPopUp(anhor, ads)
{
	var url = '/faq.php?popup=1';
	if (anhor != null) url += '#' + anhor;
	if (ads) url = '/ads' + url;
	var settings    = 'width=700,height=600,left=150,top=140,status=yes,toolbar=no,menubar=no,location=no,scrolling=auto,scrollbars=yes';
	window.open(url, 'FAQ', settings);
}

//Advanced search form
function mbAdvancedForm(val)
{
	if (document.getElementById('advanced_search').style.display == "none") {
		document.getElementById('advanced_search').style.display = "block";
		document.getElementById('simple_input_text').style.display = "block";
		document.getElementById('simple_input').style.display = "none";
		document.getElementById('simple_input_feld').style.display = "none";
		document.member_search_form.advanced_search_button.innerHTML = '<< ' + val;
		document.member_search_form.username.value = document.member_search_form.search_value.value;
		document.member_search_form.search_type.value = "advanced";
	} else {
		document.getElementById('advanced_search').style.display = "none";
		document.getElementById('simple_input_text').style.display = "none";
		document.getElementById('simple_input').style.display = "block";
		document.getElementById('simple_input_feld').style.display = "block";
		document.member_search_form.advanced_search_button.innerHTML = val + ' >>';
		document.member_search_form.search_value.value = document.member_search_form.username.value;
		document.member_search_form.search_type.value = "simple";
	}
}

//add member 'to' field and close popup
function addMemberTo(val) {
	//if (document.getElementById('member_list').value == 0) return;
	window.opener.document.compose_form.sendmessage_to.value = val;
	window.close();
}


//Mark all checkboxes
function select_all(o,forma) {
	var f = document.forms[forma];
	var i;
	for(i = 0; i < f.elements.length; i++) {
		var c = f.elements[i];
		if((c != o) && (c.type) && (c.type.toLowerCase() == 'checkbox')) {
			c.checked = o.checked;
		}
	}
}


// Comment form smiles

function addSmile(smile_id) {
	smile = '[' + smile_id + ']';
	txtarea = document.forms['comment_form'].comment_text;

	 //IE support
	if (document.selection) {
		txtarea.focus();
		sel = document.selection.createRange();
		sel.text = smile;
	}
	//MOZILLA/NETSCAPE support
	else{
		if (txtarea.selectionStart || txtarea.selectionStart == '0') {
			var startPos = txtarea.selectionStart;
			txtarea.value = txtarea.value.substring(0, startPos)
			+ smile
			+ txtarea.value.substring(startPos, txtarea.value.length);
			txtarea.selectionStart = startPos + smile.length;
			txtarea.selectionEnd = startPos + smile.length;
			txtarea.focus();
		} else {
			txtarea.value += smile;
			txtarea.focus();
		}
	}
}

function wait_for_load()
{
	if (wait_lt > 0 && document.getElementById('time') != null) {
		wait_lt--;
		document.getElementById('time').innerHTML = wait_lt;
		setTimeout("wait_for_load()", 1000);
	} else if (wait_lt == 0) {
		document.getElementById('download_url').style.display = "block";
		document.getElementById('dl_timerr').style.display = "none";
	}
}

function wait_for_view(time_id, ctime)
{
	if (ctime > 0 && document.getElementById(time_id) != null) {
		ctime--;
		document.getElementById(time_id).innerHTML = ctime;
		setTimeout("wait_for_view('" + time_id + "', '" + ctime + "')", 1000);
	}
}

function setIframeHeight() {
	h = document.body.scrollHeight;
	parent.document.getElementById('comment_iframe').style.height = h+"px";
}

function count(strobj) {
	if(strobj.value.length > maxlen) {
		strobj.value = strobj.value.substring(0,maxlen);
		cc++;
		if(cc > 0) {
			cc = 0;
		}
	}
}

function show_hide_report_iframe() {
	ifr = document.getElementById('report_iframe');
	if (ifr.style.height == 0) {
		ifr.style.height = 200;
	} else {
		ifr.style.height = 0;
	}
}

function show_hide_div(a_id) {
   wmtt = document.getElementById(a_id);
   if (wmtt.style.display == "none"){
		wmtt.style.display = "block";
   } else{
		wmtt.style.display = "none";
   }
}


function CopyText(txt)
{
	window.clipboardData.setData('text', txt);
	window.status="Code copied to clipboard.";
	setTimeout("window.status=''",3000);
}

function CopyHTMLLinkBack(txt1, txt2)
{
	var a="<a href='" + txt1 + "'>" + txt2 + "</a>";
	window.clipboardData.setData('text', a);
	window.status="Code copied to clipboard.";
	setTimeout("window.status=''",3000)
}

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Temporary variables to hold mouse x-y pos.s
var tempX = 0

// Main function to retrieve mouse x-y pos.s
function rating(obj, val_r, bg_col, tx_col) {
	document.getElementById(obj).style.backgroundColor = bg_col;
	document.getElementById(obj).style.color = tx_col;
	if (typeof document.frmRate !== 'undefined' && document.frmRate != null)
		document.frmRate.rating.value = val_r;
}

function norating(obj) {
	document.getElementById(obj).style.backgroundColor = '#EEEEEE';
	document.getElementById(obj).style.color = '#000000';
}

function getMouseXY(e) {
  if (IE) {
	tempX = event.clientX + document.body.scrollLeft
  } else {
	tempX = e.pageX
  }
  if (tempX < 0){tempX = 0}

   var curleft = curtop = 0;
	if (document.getElementById('site').offsetParent) {
		curleft = document.getElementById('site').offsetLeft + document.getElementById('r_bar').offsetLeft
	}
	var pleft = 0;
	tempX = tempX - curleft;
   if (tempX < pleft+10) {tempX = pleft+10}
	else if (tempX > (pleft + 208)) {tempX = pleft + 208}
	else {tempX = tempX}
	val_r =  Math.round(tempX/20);
	if (val_r == 11 ) val_r = 10;

  document.frmRate.rating.value = val_r
  document.getElementById('r_bar').style.width = tempX+10+'px'
  return true
}

function showHide(obj, iobj) {
	ele = document.getElementById(obj);
	if (ele.style.display == 'none'){
		ele.style.display = 'block';
		if (document.getElementById(iobj) != null)
			document.getElementById(iobj).style.display = 'none';
	}
	else {
		ele.style.display = 'none';
		if (document.getElementById(iobj) != null)
			document.getElementById(iobj).style.display = 'block';
	}
}

//report
function setReport(url, obj, obj2, e_obj) {
	//document.getElementById(obj2).innerHTML = '<img src="/images/ajax_load.gif" />';
	if (obj == '') {
		window.setTimeout('makeR("'+url+'", "'+obj2+'");',1000);
	} else {
		var val = document.getElementById(obj).value;
		var mail = document.getElementById(e_obj).value;
		url1 = url + '&val='+val + '&email=' + mail;
		window.setTimeout('makeR("'+url1+'", "'+obj2+'");',1000);
	}

}

function setReport2(url, obj, obj2) {
	if (obj == '') {
		window.setTimeout('makeR("'+url+'", "'+obj2+'");',1000);
	} else {
		val = document.getElementById(obj).value;
		val = escape(val);
		url1 = url + '&val='+val;
		window.setTimeout('makeR("'+url1+'", "'+obj2+'");',1000);
	}
}

//header form action
function chAction(new_act) {
	document.head_form.action = new_act;
}

//help div open and close
function helpDiv() {
ele = document.getElementById('help-o');
	if (ele.style.display == 'none' || ele.style.display == '') {
		ele.style.display = 'block';
	} else {
		ele.style.display = 'none';
	}
}

function divScroll(obj_id) {
	obj_id = 'fsp-' + obj_id;
	if (document.getElementById(obj_id) != null) {
		//alert(obj_id + ' - ' + document.getElementById(obj_id) + ' - ' + document.getElementById(obj_id).offsetTop);
		var scrollX = document.getElementById(obj_id).offsetTop - document.getElementById('f-navi').offsetTop -120;
		document.getElementById('f-navi').scrollTop = scrollX;
		document.getElementById(obj_id).style.border="solid 1px #090";
		document.getElementById(obj_id).style.backgroundColor="#f5f5f5";
	}
}

rfmax = 16;

/* fix PNG */
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage)
{
 /*   if ((version >= 5.5) && (version < 7) && (document.body.filters))
	{
	   var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ?
					 "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
				  + " style=\"" + "width:" + myImage.width
				  + "px; height:" + myImage.height
				  + "px;" + imgStyle + ";"
				  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML
	}         */
}

// Set msg-box position for netscape
function setMBPosition(){
	var browser = getBrowser();

	if (browser.indexOf("nn") != -1) {
		var posx = 0;
		var posy = 0;
		var mb_el = document.getElementById('dyn-msg-box');

		p = $('#dyn-msg-box').position();

		posx = p.left;
		posy = p.top;

		/*
		var pr = mb_el.offsetParent;

		while (pr) {
			posx = posx + pr.offsetLeft;
			posy = posy + pr.offsetTop;
			pr = pr.offsetParent;
		}
		*/
		posx-= 250;

		//if (typeof console != 'undefined')
			//console.debug(p);

		document.getElementById('msg-box-tbl').style.top = (posy + mb_el.offsetHeight) + 'px';
		document.getElementById('msg-box-tbl').style.left = (posx + mb_el.offsetWidth) + 'px';
	}

	setTimeout('setMBPosition()', 500);
}



function submitSendEmailForm(){
	var friends_email   = document.send_form.friends_email.value;
	var email_comment   = document.send_form.email_comment.value;
	var captcha_phrase  = document.send_form.captcha_phrase.value;
	var current_file_id = document.send_form.current_file_id.value;
	var current_member_id = document.getElementById('current_member_id').value;
	var phrase = 'current_file_id=' + current_file_id + '&friends_email=' + friends_email + '&email_comment=' + email_comment + '&captcha_phrase=' + captcha_phrase + '&submit_send_email=true&current_member_id='+current_member_id;
	makeR('/send_file_by_email_ajax.php', 'email_to_friend', phrase);
}

var offset;


function makeScroll(direction)
{
	var offset = document.getElementById('offset').value;

	if(direction == 'prev'){
		offset = parseInt(offset) - 25;
		var position_offset = "&position=" + (offset - 25);

	}else if(direction == 'next'){
		var position_offset = "&position=" + offset;
		offset = parseInt(offset) + 25;

	}

	var user_id = "user_id=" + document.getElementById('user_id').value;
	var folder_id = "&folder_id=" + document.getElementById('folder_id').value;
	var current_member_id = "&current_member_id=" + document.getElementById('current_member_id').value;
	var current_file_id = "&current_file_id=" + document.getElementById('current_file_id').value;
	var sel_file_id = "&sel_file_id=" + document.getElementById('sel_file_id').value;

	document.getElementById('offset').value = offset;
	document.getElementById('b-f-t').style.display = 'none';
	document.getElementById('wait-t').style.display = 'block';
	document.getElementById('b-f-b').style.display = 'none';
	document.getElementById('wait-b').style.display = 'block';
	makeR('/get_folder_contents_ajax.php', 'file_container', user_id + folder_id + current_member_id + current_file_id + sel_file_id + position_offset);
}

function shiftScroll(obj_id) {


	obj_id = 'fsp-' + obj_id;
	if (document.getElementById(obj_id) != null) {
		document.getElementById('file_container').scrollTop = document.getElementById(obj_id).offsetParent.offsetTop;
		//var offsetParent = document.getElementById('file_container');
		//alert(document.getElementById(obj_id).offsetParent.offsetTop);
	}

	//document.getElementById('file_container').scrollTop = document.getElementById('scroll').value * 190;
}

// Open popup faq
function openFAQ(chapter){
	JavaScript:FaqPopUp(chapter, false)
}


// check for frame and make FileView
function getFileView(vid, fid, sid)
{
	/*
	if(parent == this.window)
			alert('Main window');
		else
			alert('In Frame');
	*/

	if(parent != this.window){
		if(this.window.innerWidth < 800 || this.window.innerHeight < 600){
			  alert('The minimum size of www.filer.lv window must be WxH 800x600px!');
		} else {
			if(vid != '' && fid != '' && sid != ''){
				makeR_FV('/add_file_view_ajax.php', '', 'vid='+vid+'&fid='+fid+'&sid='+sid+'&width='+this.window.innerWidth+'&height='+this.window.innerHeight);
			}
		}
	} else {
		if(vid != '' && fid != '' && sid != '' && this.window.innerWidth >= 800 && this.window.innerHeight >= 600){
			if(parent == this.window)
				makeR_FV('/add_file_view_ajax.php', '', 'vid='+vid+'&fid='+fid+'&sid='+sid+'&width='+this.window.innerWidth+'&height='+this.window.innerHeight);
		}
	}
}

// open buy function popup
function buyFunction()
{
	popUpWindow('/member/buy_function.php', 'BuyFunction', 700, 580)
}

//open hidden
function checkEmailBlock() {
	if (document.getElementById('s-box').style.display == 'none' || document.getElementById('s-box').style.display == '')
		document.getElementById('s-box').style.display = 'block';
	else
		document.getElementById('s-box').style.display = 'none';
}

//send data to subscriber data to table
function sendSubscribeData(type, member) {

   var id = document.getElementById('f-id').value;

   if (member) {
	  document.getElementById('s-box').style.display = 'block';
	  if (document.getElementById('subscribe_c').checked) {
		 var phrase = 'type=' + type + '&id=' + id;
		 makeR('/make_subscription.php', 's-box', phrase);
	  } else {
		 var phrase = 'act=unsubscribe&' + 'type=' + type + '&id=' + id;
		 makeR('/unsubscribe.php', 's-box', phrase);
	  }
		 //alert(phrase);

   } else {
	   var email = ''; var go = '';
	   if (document.getElementById('subscribe_c').checked) {
		 document.getElementById('s-box').style.display = 'block';

		 if (document.getElementById("s-email") != null && document.getElementById("s-email").value != '') {
			if (document.getElementById("s-email") != null)
				email = 'email=' + document.getElementById("s-email").value + '&';

			if (document.getElementById("submit_email_adress") != null) {
				go = '&submit_email_adress=' + document.getElementById("submit_email_adress").value;
				 subscrButton(true);
				 window.setTimeout('subscrButton(0)', 5000);
			}

			var phrase = email + 'type=' + type + '&id=' + id + go;
		 }  else var phrase = 'type=' + type;
		 //alert(phrase);
		 makeR('/make_subscription.php', 's-box', phrase);
	   } else {
		 document.getElementById('s-box').style.display = 'none';
	   }

   }

}

function subscrButton(status){
	document.getElementById('submit_email_adress').disabled = status;
}

