function faq_sw (f_id) {
	var f1_but1 = '';	
	var a = '_txt';

	f1_but1 = f_id + a;
    if ( document.getElementById(f_id).className == 'faq_q_item') {
		document.getElementById(f_id).className = 'faq_q_item_opened';
	}  else {
	       if ( document.getElementById(f_id).className == 'faq_q_item_opened') {

		        document.getElementById(f_id).className = 'faq_q_item';
	           }
		else {
	       if ( document.getElementById(f_id).className == 'faq_q_item gray') {
		       document.getElementById(f_id).className = 'faq_q_item_opened gray';
	       }
	       else { if ( document.getElementById(f_id).className == 'faq_q_item_opened gray') {

		       document.getElementById(f_id).className = 'faq_q_item gray';
	       }
		   }
		}
	}
}
function faq_details (b_id) {
	var b1_txt1 = '';	
	var a = '_txt';

	b1_txt1 = b_id + a;
    if ( document.getElementById(b_id).className == 'faq_main_but') {
		document.getElementById(b1_txt1).style.display = 'block';
		document.getElementById(b_id).className = 'faq_main_but1';
	}  else {
                document.getElementById(b_id).className = 'faq_main_but';
		        document.getElementById(b1_txt1).style.display = 'none';
	           }
	
}

function show_func (b_id) 
{
 document.getElementById(b_id).style.display = 'block';
}
function hide_func (b_id) 
{
   document.getElementById(b_id).style.display = 'none';
 document.getElementById('fadeout').style.display='none';
}

function change_sort(s_id) {
	var sarray = [ 'fm_type', 'fm_name', 'fm_date', 'fm_downloads', 'fm_size', 'fm_f_link' ];
	var s_pressed1 = s_id + '_pressed1';
	var s_pressed2 = s_id + '_pressed2';
	
	
	if ( document.getElementById(s_id).className == s_id) {
		  document.getElementById(s_id).className = s_pressed1;
	}  else {
		  if ( document.getElementById(s_id).className == s_pressed1) {
		       document.getElementById(s_id).className = s_pressed2;
		  
		  } else {
		  document.getElementById(s_id).className = s_pressed1;
		  }
		  
	}
	
	for (var i = 0; i < 7; i++) {
		if ( document.getElementById(sarray[i]) && sarray[i] !== s_id) {
			
			document.getElementById(sarray[i]).className = sarray[i];
			
		}	
	}	     
}


function selectport(portnr)
{
	document.getElementById('checkbox80_div').className = 'checkboxOff';
	document.getElementById('checkbox800_div').className = 'checkboxOff';
	document.getElementById('checkbox1723_div').className = 'checkboxOff';
	document.getElementById('checkbox' + portnr + '_div').className = 'checkboxOn';
	setcookie('port',portnr,87600);
}




function blurS(el,txt)
{
	if(el.value == '')
	{
		el.value = txt;
		el.className = 'fm_input';
		document.searching=false;
	}
}
 
function focusS(el,txt)
{
	if(el.value == txt)
	{
		el.value = '';
		el.className = 'fm_input';
		document.searching=false;
	}
}
function blurL(el)
{
	if(el.value == '')
	{
		el.value = 'Enter your Email...';
	}
}
 
function focusL(el)
{
	if(el.value == 'Enter your Email...')
	{
		el.value = '';
	}
}

function tr_change(s_id) {

	
	if ( document.getElementById(s_id).className == 'pr_trouble_but') {
		  document.getElementById(s_id).className = 'pr_trouble_but1';
		  document.getElementById('tr_details').style.display = 'block';
		  document.getElementById('tr_bott1').className = 'main_shadow3 voucher1';
		  document.getElementById('tr_bott2').className = 'main_shadow1 pr_shadow2_opened';
		  document.getElementById('tr_block').className = 'pr_trouble_bl2';
		  
		  
		  
		  
	}  else {
		  document.getElementById(s_id).className = 'pr_trouble_but';
		  document.getElementById('tr_details').style.display = 'none';
		  document.getElementById('tr_bott1').className = 'main_shadow3';
		  document.getElementById('tr_bott2').className = 'main_shadow1 pr_shadow2_closed';
		  document.getElementById('tr_block').className = 'pr_trouble_bl';
	}
	
}

function show_popup (b_id) 
{
	document.getElementById(b_id).style.display = 'block';	
	document.getElementById('fadeout').style.height = 

	poswindow();
	/*
	
    var popup = document.getElementById (b_id);
    var   ch= popup.clientHeight;
	var   cw= popup.clientWidth;
	ch = Math.floor(ch/2);
	cw = Math.floor(cw/2);
	popup.style.marginLeft = '-' + cw +'px';
	popup.style.marginTop = '-' + ch +'px';
	*/
}





function getHeight() 
{
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' )  myHeight = window.innerHeight;  
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )  myHeight = document.documentElement.clientHeight;   
  else if (document.body && ( document.body.clientWidth || document.body.clientHeight ) )  myHeight = document.body.clientHeight;
  return myHeight;
}


function getWidth() 
{
  var myWidth = 0;
  
  if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )  myWidth = document.documentElement.clientWidth;
  else if( typeof( window.innerWidth ) == 'number' )  myWidth = window.innerWidth;  
  else if (document.body && ( document.body.clientWidth || document.body.clientHeight ) )  myWidth = document.body.clientWidth;
  return myWidth;
}

function readcookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function setcookie(cookieName,cookieValue,nHours) 
{
	var today = new Date();
	var expire = new Date();
	if (nHours==null || nHours==0) nHours=1;
	expire.setTime(today.getTime() + 3600000*nHours);
	document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}

function checkMail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) 
	{
		return false;
	}
	else
	{
		return true;
	}
}

function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}


function cuttxt(str,maxlength,currentlength)
{
  var difference = currentlength - maxlength;
  difference = difference / currentlength;
  difference = Math.round(str.length * difference*1,1);
  return str.substr(0,(str.length-difference)) + '';
}

function measureText(pText,fontsize) 
{ 
	var lDiv = document.createElement('lDiv');  
	document.body.appendChild(lDiv);    
	lDiv.style.fontSize = fontsize + "px"; 
	lDiv.style.fontWeight = "bold"; 
	lDiv.style.position = "absolute"; 
	lDiv.style.left = "-1200px"; 
	lDiv.style.top = "-1200px";  
	lDiv.innerHTML = pText;  
	var width = lDiv.clientWidth; 
	document.body.removeChild(lDiv); 
	lDiv = null;  
	return width;
}

function posNotify()
{
	if (document.notifywindow)
	{
		var popup = document.getElementById ('popup_notify');
		var left = Math.round((getWidth()-popup.clientWidth)/2);
		var top  = Math.round((getHeight()-popup.clientHeight)/2);	
		document.getElementById('fadeout').style.top = getScrollHeight() + 'px';
		document.getElementById('fadeout').style.height = getHeight() + 'px';
		top = top + getScrollHeight();
		if (top < 50) top = 50;
		document.getElementById('popup_notify').style.left = left + 'px';
		document.getElementById('popup_notify').style.top  = top + 'px';
	}
}
function showNotify(msg,focusel)
{
	if(!document.notifywindow)
	{
		document.getElementById('notify_txt').innerHTML = msg;		
		document.getElementById ('popup_notify').style.display = 'block';	
		document.getElementById('fadeout').style.display = '';
		document.notifywindow=true;
		document.focusel=focusel;
		posNotify();
	}
}
function closeNotify()
{ 
  if(document.focusel) document.getElementById(document.focusel).focus();  	
  document.getElementById ('popup_notify').style.display = 'none';	
  document.getElementById('fadeout').style.display = 'none';
  document.notifywindow=false;
  document.fosucel=false;
	
}
document.notifywindow=false;




function showReverse()
{
	if(!document.reversewindow)
	{
		document.getElementById ('popup_reverse').style.display = 'block';	
		document.getElementById('fadeout2').style.display = '';
		document.reversewindow=true;
		posReverse();
	}
}
function closeReverse()
{ 
  document.getElementById ('popup_reverse').style.display = 'none';	
  document.getElementById('fadeout2').style.display = 'none';
  document.reversewindow=false;	
}
function posReverse()
{
	if (document.reversewindow)
	{
		var popup = document.getElementById ('popup_reverse');
		var left = Math.round((getWidth()-popup.clientWidth)/2);
		var top  = Math.round((getHeight()-popup.clientHeight)/2);	
		document.getElementById('fadeout2').style.top = getScrollHeight() + 'px';
		document.getElementById('fadeout2').style.height = getHeight() + 'px';
		top = top + getScrollHeight();
		if (top < 50) top = 50;
		document.getElementById('popup_reverse').style.left = left + 'px';
		document.getElementById('popup_reverse').style.top  = top + 'px';
	}
}
document.reversewindow=false;





function showPayment(txt)
{
	if(!document.paymentwindow)
	{
		document.getElementById ('popup_payment').style.display = 'block';	
		document.getElementById('fadeout4').style.display = '';
		document.getElementById('payment_txt').innerHTML = txt;
		document.paymentwindow=true;
		posPayment();
	}
}
function closePayment()
{ 
  document.getElementById ('popup_payment').style.display = 'none';	
  document.getElementById('fadeout4').style.display = 'none';
  document.paymentwindow=false;	
}
function posPayment()
{
	if (document.paymentwindow)
	{
		var popup = document.getElementById ('popup_payment');
		var left = Math.round((getWidth()-popup.clientWidth)/2);
		var top  = Math.round((getHeight()-popup.clientHeight)/2);	
		document.getElementById('fadeout4').style.top = getScrollHeight() + 'px';
		document.getElementById('fadeout4').style.height = getHeight() + 'px';
		top = top + getScrollHeight();
		if (top < 50) top = 50;
		document.getElementById('popup_payment').style.left = left + 'px';
		document.getElementById('popup_payment').style.top  = top + 'px';
	}
}
document.paymentwindow=false;






function posNotifyReverse()
{
	if (document.notifywindow) posNotify();
	else if (document.playerwindow) posPlayer();
	else if (document.reversewindow) posReverse();
}



function posNotifyReversePayment()
{
	if (document.notifywindow) posNotify();
	else if (document.playerwindow) posPlayer();
	else if (document.reversewindow) posReverse();
	else if (document.paymentwindow) posPayment();
}



function acc_info(acc_id) {
		var sarray = [ 'acc_id1', 'acc_id2', 'acc_id3'];
	
	if (document.getElementById(acc_id).className == 'acc_t_closed') {
		document.getElementById(acc_id).className = 'acc_t_opened';
		
		for (var i = 0; i < 4; i++) {
		if ( document.getElementById(sarray[i]) && sarray[i] !== acc_id) {
			
			document.getElementById(sarray[i]).className = 'acc_t_closed';
			
		}
		
		}
		
		
	} else {
		 document.getElementById(acc_id).className = 'acc_t_closed';
	}
	
	
	
}

function ty_change(t_id) {
	var sarray = [ 'ty1', 'ty2'];
	
	for (var i = 0; i < 3; i++) {
		
		if ( document.getElementById(sarray[i]) && sarray[i] == t_id) {
		document.getElementById(sarray[i]).className = 'but_on_'+sarray[i];
	    document.getElementById(sarray[i]+'_rad_div').className = 'radioOn';
		document.getElementById(sarray[i]+'_rad').className = 'radioOn';
		document.getElementById(sarray[i]+'_div').style.display = 'block';
		var m=2-i;
		document.getElementById('ty'+m).className = 'but_off_ty'+m;
	    document.getElementById('ty'+m+'_rad_div').className = 'radioOff';
		document.getElementById('ty'+m+'_rad').className = 'radioOff';
		document.getElementById('ty'+m+'_div').style.display = 'none';
		
	} 
	
}
}

function file_show(f_id) {
	
	var f_id_lnk = f_id + '_lnk';
	var f_id_adv = f_id + '_adv';
		
		if ( document.getElementById(f_id_lnk).className == 'start_file_show')  {
		     document.getElementById(f_id_lnk).className = 'start_file_hide';
		     document.getElementById(f_id_adv).style.display = 'block';
		} else {
			 document.getElementById(f_id_lnk).className = 'start_file_show';
		     document.getElementById(f_id_adv).style.display = 'none';
		}
	

}

function file_del(f_id) {
	 var f_id_del = f_id + '_del';
	 document.getElementById(f_id).style.display = 'none';
	 document.getElementById(f_id_del).style.display = 'none';
}

function carousel(c_id) {
	var c_id_block = c_id + '_block';
	
	if (document.getElementById(c_id_block).className == 'start_carousel_block_closed') {
		document.getElementById(c_id).style.display = 'none';
		document.getElementById(c_id_block).className = 'start_carousel_block';
	} else {
		document.getElementById(c_id).style.display = 'block';
		document.getElementById(c_id_block).className = 'start_carousel_block_closed';
	}
	
}




function explode (delimiter, string, limit) {
    var emptyArray = {
        0: ''
    };

    if (arguments.length < 2 || typeof arguments[0] == 'undefined' || typeof arguments[1] == 'undefined') {
        return null;
    }

    if (delimiter === '' || delimiter === false || delimiter === null) {
        return false;
    }

    if (typeof delimiter == 'function' || typeof delimiter == 'object' || typeof string == 'function' || typeof string == 'object') {
        return emptyArray;
    }

    if (delimiter === true) {
        delimiter = '1';
    }

    if (!limit) {
        return string.toString().split(delimiter.toString());
    }
    // support for limit argument
    var splitted = string.toString().split(delimiter.toString());
    var partA = splitted.splice(0, limit - 1);
    var partB = splitted.join(delimiter.toString());
    partA.push(partB);
    return partA;
}



function bytesToSize(bytes, precision)
{	
	var kilobyte = 1024;
	var megabyte = kilobyte * 1024;
	var gigabyte = megabyte * 1024;
	var terabyte = gigabyte * 1024;
	
	if ((bytes >= 0) && (bytes < kilobyte)) {
		return bytes + ' B';

	} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
		return (bytes / kilobyte).toFixed(precision) + ' KB';

	} else if ((bytes >= megabyte) && (bytes < gigabyte)) {
		return (bytes / megabyte).toFixed(precision) + ' MB';

	} else if ((bytes >= gigabyte) && (bytes < terabyte)) {
		return (bytes / gigabyte).toFixed(precision) + ' GB';

	} else if (bytes >= terabyte) {
		return (bytes / terabyte).toFixed(precision) + ' TB';

	} else {
		return bytes + ' B';
	}
}


function start_sel_func(sel_id) {
	
	if (document.getElementById(sel_id).className == 'start_select_butt') 
	{		
		document.getElementById(sel_id).className = 'start_add_more_butt';
		document.getElementById(sel_id+'_txt').style.display = 'block';
		document.getElementById(sel_id+'_bg').className = 'start_bott_bl';
		document.getElementById(sel_id+'_lnk').style.display = 'block';
		document.getElementById('filesblock_pad').style.display = 'block';
		document.getElementById('checkbox1_div').style.display = 'block';
		document.getElementById(sel_id+'_step1_txt').style.display = 'none';
		document.getElementById('sel_but2').style.display = 'block';
	}
	else
	{
		document.getElementById(sel_id).className = 'start_select_butt';
		document.getElementById(sel_id+'_txt').style.display = 'none';
		document.getElementById(sel_id+'_bg').className = '';
		document.getElementById(sel_id+'_lnk').style.display = 'none';
		document.getElementById('filesblock_pad').style.display = 'none';
		document.getElementById('checkbox1_div').style.display = 'none';
		document.getElementById(sel_id+'_step1_txt').style.display = 'block';
		document.getElementById('sel_but2').style.display = 'none';


	}
	
	
}


function uplpad(number, length) 
{   
    var str = '' + number;
    while (str.length < length) 
	{
        str = '0' + str;
    }   
    return str;
}



function secondsToTime(secs)
{
	var hours = uplpad(Math.floor(secs / (60 * 60)),2);	
	var divisor_for_minutes = secs % (60 * 60);
	var minutes = uplpad(Math.floor(divisor_for_minutes / 60),2);
	var divisor_for_seconds = divisor_for_minutes % 60;
	var seconds = uplpad(Math.ceil(divisor_for_seconds),2);	
	var returnvar = hours + ':' + minutes + ':' + seconds;
	return returnvar;
}


function getXmlHttpRequestObject() 
{	
	if (window.XMLHttpRequest) 
	{		
		return new XMLHttpRequest();	
	} 
	else if(window.ActiveXObject) 
	{		
		return new ActiveXObject("Microsoft.XMLHTTP");		
	} 
	else 
	{		
		alert('Please update your browser!');
	}
}


function stristr (haystack, needle, bool) 
{
    var pos = 0; 
    haystack += '';
    pos = haystack.toLowerCase().indexOf((needle + '').toLowerCase());    if (pos == -1) {
        return false;
    } else {
        if (bool) {
            return haystack.substr(0, pos);        } else {
            return haystack.slice(pos);
        }
    }
}
