function PeopleTabs(s, num) {
	if( num>0 ){
		var clsname = ""
		var item = ""
		var tab = ""
		for(var i=1; i<num+1; i++){
			clsname="item_bg"
			if(i==1){
				clsname = clsname + '_left'
			}else if(i==num){
				clsname = clsname + '_right'
			}
			item = document.getElementById('people-menu-'+i) ? document.getElementById('people-menu-'+i) : ""
			item.className = clsname + ( s == i ? ' active' : '')
			tab = document.getElementById('people-tab-'+i) ? document.getElementById('people-tab-'+i) : ""
			if(tab){
				tab.style.display = (s == i ? 'block' : 'none')
			}
		}
	}
}

function MovieTabs(s) {

	var item1 = document.getElementById('movie-menu-1')
	var item2 = document.getElementById('movie-menu-2')
	var item3 = document.getElementById('movie-menu-3')
	var item4 = document.getElementById('movie-menu-4')

	var tab1 = document.getElementById('movie-tab-1')
	var tab2 = document.getElementById('movie-tab-2')
	var tab3 = document.getElementById('movie-tab-3')
	var tab4 = document.getElementById('movie-tab-4')

	item1.className = 'item_bg_left'
	item2.className = 'item_bg'
	item3.className = 'item_bg'
	item4.className = 'item_bg_right'

	tab1.style.display = 'none'
	tab2.style.display = 'none'
	tab3.style.display = 'none'
	tab4.style.display = 'none'

	var cl = document.getElementById('movie-menu-'+s).className

	document.getElementById('movie-menu-'+s).className = cl + ' active'

	document.getElementById('movie-tab-'+s).style.display = 'block'

}



function ShowMessage() {

	lpos = screen.availWidth / 2  - 350;
	tpos = screen.availHeight / 2 - 103;


	w = window.open( "message.html", "Message", "width=500,height=206,resizable=no,status=no,toolbar=no,menubar=no,left=" + lpos + ",top=" + tpos );
	window.w.focus();
	//if( window.event != null )
		window.event.returnValue = false;

	return false;
}

function ShowSort() {

		l = document.getElementById('BrowseByList')

		if (l.style.visibility == 'hidden') {
			l.style.visibility = 'visible'
		}
		else {
			l.style.visibility = 'hidden'
		}

	}

function BrowseSelect(obj) {

		s = obj.innerHTML

		but = document.getElementById('btn_browseby')
		l = document.getElementById('BrowseByList')

		alph = document.getElementById('AlphabetBlock')
		gen = document.getElementById('GenresBlock')
		year = document.getElementById('YearsBlock')

		if (obj.id == 'calendar_alphabet') {

			alph.style.display = 'block'
			gen.style.display = 'none'
			year.style.display = 'none'
		}

		if (obj.id == 'calendar_genre') {

			gen.style.display = 'block'
			alph.style.display = 'none'
			year.style.display = 'none'
		}

		if (obj.id == 'calendar_year') {

			gen.style.display = 'none'
			alph.style.display = 'none'
			year.style.display = 'block'
		}

		but.innerHTML = s
		l.style.visibility = 'hidden'

	}

function showYearList() {

		list = document.getElementById('yearlist')

		document.getElementById('monthlist').style.visibility = 'hidden'

		if (list.style.visibility == 'hidden') {
			list.style.visibility = 'visible'
		}
		else {
			list.style.visibility = 'hidden'
		}

}

function showMonthList() {

		list = document.getElementById('monthlist')

		if (list.style.visibility == 'hidden') {
			list.style.visibility = 'visible'
		}
		else {
			list.style.visibility = 'hidden'
		}

}


function HideMonth() {
	document.getElementById('monthlist').style.visibility = 'hidden'
}

function HideMonth() {
	document.getElementById('yearlist').style.visibility = 'hidden'
}

function BrowseYear(obj) {

	var yearlist = document.getElementById('yearlist')
	var y = document.getElementById('year_txt')

	s = obj.innerHTML

	y.innerHTML = s
	yearlist.style.visibility = 'hidden'

}

function BrowseMonth(obj) {

	var monthlist = document.getElementById('monthlist')
	var m = document.getElementById('month_txt')

	s = obj.innerHTML

	m.innerHTML = s
	monthlist.style.visibility = 'hidden'

}

function drop() {

list = document.getElementById('drop_list')

 if (list.style.visibility == 'hidden') {

 	list.style.visibility = 'visible'

 }

 else {

 	list.style.visibility = 'hidden'

  }

}

function drop_sel(s) {
    list = document.getElementById('drop_list')
	droptext = document.getElementById('drop_text')
	droptext.innerHTML = s
	list.style.visibility = 'hidden'
	drop_text_value = s;
}


function ShowDescription(obj, s) {
	descr = document.getElementById(s)
	try {

	if (descr.style.display == 'none') {

		descr.style.display = 'block'
		obj.innerHTML = lang_hide_description

	}
	else {

		descr.style.display = 'none'
		obj.innerHTML = lang_show_description

	}
	}
	catch (err) {}
}

// -------------------------------

var http_req_archive;
function setToIcart(format_id, vid_id, price, price_id, isalbum )
{
    http_req_archive = new Subsys_JsHttpRequest_Js();
    http_req_archive.onreadystatechange = addToIcartProcess;
    http_req_archive.caching = false;
    http_req_archive.open( 'GET', '/pages/addToIcart.php?start=1&vid=' + vid_id + "&fid=" + format_id + "&price=" + price + "&price_id=" + price_id + '&isalbum=' + isalbum, true );
    http_req_archive.send({ dump: 1 });
    return false;
}

function addToIcartProcess()
{
	if( http_req_archive.readyState == 4 )
	{
		if( http_req_archive.responseJS )
		{
			var check_stat = http_req_archive.responseJS.check_stat * 1;
			var responce_result_response = http_req_archive.responseJS.responce_result;
			if( check_stat == 1 )
			{
                HideDownloadMenu()
                var el = document.getElementById("numcart");
                el.innerHTML = http_req_archive.responseJS.num;
                openWin("video_added")

			}else{
			    alert('System is experiencing some technical difficulties at the moment.\nPlease try Your request again')
			}
		}
	}
}

function deleteFromOrders(ord_id, page)
{
   	http_req_archive = new Subsys_JsHttpRequest_Js();
   	http_req_archive.onreadystatechange = deleteFromOrdersProcess;
   	http_req_archive.caching = false;
   	http_req_archive.open( 'GET', '/pages/deleteFromOrders.php?start=1&ord_id=' + ord_id + "&page=" + page, true );
   	http_req_archive.send({ dump: 1 });
   	closeWin('video_delete');
}

function deleteFromOrdersProcess()
{
	if( http_req_archive.readyState == 4 )
	{
		if( http_req_archive.responseJS )
		{
			var check_stat = http_req_archive.responseJS.check_stat * 1;
			var responce_result_response = http_req_archive.responseJS.html;
			if( check_stat == 1 )
			{
                var el = document.getElementById("purchased_video");
                el.innerHTML = responce_result_response;
                drop_sel(drop_text_value);
			}else{
			    alert('System is experiencing some technical difficulties at the moment.\nPlease try Your request again')
			}
		}
	}
}

function setPaymentValue(num)
{
    var link_ = document.getElementById('link_to_payment');
    var value = ''
    var summ = 0;
    switch(num)
    {
        case "19.95":
            summ = 1995
            break;
        case "29.95":
            summ = 2995
            break;
        case "49.95":
            summ = 4995
            break;
        case "99.95":
            summ = 9995
            break;
    }
    if(link_){
        link_.href = link_.href.replace(/amount\=1995/,'amount=SUMM_NUM').replace(/amount\=2995/,'amount=SUMM_NUM').replace(/amount\=4995/,'amount=SUMM_NUM').replace(/amount\=9995/,'amount=SUMM_NUM');
        link_.href = link_.href.replace(/price\=1995/,'price=SUMM_NUM').replace(/price\=2995/,'price=SUMM_NUM').replace(/price\=4995/,'price=SUMM_NUM').replace(/price\=9995/,'price=SUMM_NUM');
        link_.href = link_.href.replace(/SUMM_NUM/,summ)
    }
}

function closeWin(k)
	{
  var win = document.getElementById(k)
  var win_bg = document.getElementById('win_bg')
  win.style.display = "none"
  win_bg.style.display = "none"
}

function openWin(k)
	{
  var win = document.getElementById(k)
  var win_bg = document.getElementById('win_bg')
  try
  {
  	win.style.display = "table"
  }
  catch (error)
  {
	  win.style.display = "block"
  }
  win_bg.style.display = "block"
}

function setNumPerPage(num, page)
{
    http_req_archive = new Subsys_JsHttpRequest_Js();
    http_req_archive.onreadystatechange = addNumPerPage;
    http_req_archive.caching = false;
    http_req_archive.open( 'GET', '/pages/setNumPerPage.php?start=1&num=' + num + "&page=" + page, true );
    http_req_archive.send({ dump: 1 });
    return false;
}

function addNumPerPage()
{
	if( http_req_archive.readyState == 4 )
	{
		if( http_req_archive.responseJS )
		{
			var check_stat = http_req_archive.responseJS.check_stat * 1;
			var responce_result_response = http_req_archive.responseJS.responce_result;
			if( check_stat == 1 ){
				document.location.href = document.location.href.replace(document.location.search, "") + "?page=1";
			}else{
			    alert('System is experiencing some technical difficulties at the moment.\nPlease try Your request again')
			}
		}
	}
}

function getPagingHTML(page, some_ind1, some_ind2, some_ind3, some_ind4){

	http_req_archive = new Subsys_JsHttpRequest_Js();
    http_req_archive.onreadystatechange = setPagingHTML;
    http_req_archive.caching = false;
    http_req_archive.open( 'POST', '/pages/ajaxPaging.php?start=1&page=' + page + "&idef1=" + some_ind1 + "&idef2=" + some_ind2 + "&idef3=" + some_ind3 + "&idef4=" + some_ind4, true );
    http_req_archive.send({ dump: 1 });
    return false;
}

function setPagingHTML()
{
	if( http_req_archive.readyState == 4 )
	{
		if( http_req_archive.responseJS )
		{
			var check_stat = http_req_archive.responseJS.check_stat * 1;
			var responce_result_response = http_req_archive.responseJS.html;
			var responce_id = http_req_archive.responseJS.responce_div_id;
			var id = http_req_archive.responseJS.id;
			var idef1 = http_req_archive.responseJS.idef1;
			if( check_stat == 1 )
			{
				// all ok
				// *
				var item_change = document.getElementById(responce_id);
				if(item_change && item_change.innerHTML)
				{
					item_change.innerHTML = responce_result_response;
					if(id && idef1=='player')	{
						var max_num_tab = 0;
						var num_tb = document.getElementById("nmtb");
						if(num_tb)
							max_num_tab = num_tb.value
					}else if(id && idef1=='video_album_screens'){
						var num_tb = document.getElementById(responce_id);
						num_tb.innerHTML = responce_result_response;
					}
					else if(idef1=='opinions' && idef2){
						var num_tb = document.getElementById(responce_id);
						num_tb.innerHTML = responce_result_response;
					}
				}

			}else{
			    alert('2. System is experiencing some technical difficulties at the moment.\nPlease try Your request again')
			}
		}
	}
}

function changeAwardPageFilter(page, some_ind1, some_ind2, some_ind3, some_ind4){

    http_req_archive = new Subsys_JsHttpRequest_Js();
    http_req_archive.onreadystatechange = setAwardPageHTML;
    http_req_archive.caching = false;
    http_req_archive.open( 'POST', '/pages/ajaxPaging.php?start=1&page=' + page + "&idef1=" + some_ind1 + "&idef2=" + some_ind2 + "&idef3=" + some_ind3 + "&idef4=" + some_ind4, true );
    http_req_archive.send({ dump: 1 });
    return false;
}

function setAwardPageHTML()
{
	if( http_req_archive.readyState == 4 )
	{
		if( http_req_archive.responseJS )
		{
			var check_stat = http_req_archive.responseJS.check_stat * 1;
			var responce_result_response = http_req_archive.responseJS.html;
			var responce_id = http_req_archive.responseJS.responce_div_id;
			var id = http_req_archive.responseJS.id;
			var idef1 = http_req_archive.responseJS.idef1;
			if (check_stat == 1)
			{
				// all ok
				// *
				var item_change = document.getElementById(responce_id);
				if (item_change)
				{
					item_change.innerHTML = responce_result_response;

					var item_year = http_req_archive.responseJS.idef4;
					$(".year_links").removeClass("active");

					if (item_year)
					{
						$("#year_link_" + item_year).addClass("active");
						document.getElementById('award_current_year').innerHTML = item_year;
					}
					else
						$("#year_link_all").addClass("active")
				}

			}else{
			    alert('System is experiencing some technical difficulties at the moment.\nPlease try Your request again')
			}
		}
	}
}

function awardsYearsShift(some_ind1, some_ind2, some_ind3, some_ind4){

    http_req_archive = new Subsys_JsHttpRequest_Js();
    http_req_archive.onreadystatechange = setAwardYearsHTML;
    http_req_archive.caching = false;
    http_req_archive.open( 'POST', '/pages/ajaxPaging.php?start=1' + "&idef1=" + some_ind1 + "&idef2=" + some_ind2 + "&idef3=" + some_ind3 + "&idef4=" + some_ind4, true );
    http_req_archive.send({ dump: 1 });
    return false;
}

function setAwardYearsHTML()
{
	if( http_req_archive.readyState == 4 )
	{
		if( http_req_archive.responseJS )
		{
			var check_stat = http_req_archive.responseJS.check_stat * 1;
			var responce_result_response = http_req_archive.responseJS.html;
			var responce_id = http_req_archive.responseJS.responce_div_id;
			var id = http_req_archive.responseJS.id;
			var idef1 = http_req_archive.responseJS.idef1;
			if (check_stat == 1)
			{
				// all ok
				// *
				var item_change = document.getElementById(responce_id);
				if (item_change && item_change.innerHTML && responce_result_response.length > 0)
				{
					item_change.innerHTML = responce_result_response;
				}

			}else{
			    alert('System is experiencing some technical difficulties at the moment.\nPlease try Your request again')
			}
		}
	}
}

function textCounter( field, countfield, maxlimit ) {
  if ( field.value.length > maxlimit )
  {
    field.value = field.value.substring( 0, maxlimit );
    str = lang_text_length_limit.replace('[LIMIT]', maxlimit);
    alert( str );
    return false;
  }
  else
  {
    document.getElementById(countfield).innerHTML=maxlimit - field.value.length;
  }
}
