/*
Stanislav R. Bogorad
WEBprogramer : Perl, PHP, JavaScript, JScript, HTML, CSS etc.. High quality;
stas@senteromediastore.com
http://www.abox.co.il
phone:  Israel 0546 308731
*/
var ThisPath = "";//
function setCookie(names, values, days){
if(days){
	var date = new Date();
	date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));//day, minute, second, milisecond
	var expires = "; expires=" + date.toGMTString();
}
else expires = "";
document.cookie = names + "=" + values + expires + "; path=/";
}

function elem(val){
return document.getElementById(val);
}

function echo(val){
document.writeln(val);
}


function PopUp(adress, titles, w, h, l, t){
titles = (titles)? titles : "";
w = w ? w : 300;
h = h ? h : H - 100;
l = l ? l : W/2 - w/2;
t = t ? t : H/3 - h/3;
//alert(w+'\n'+h+'\n'+l+'\n'+t+'\n'+adress+'\n'+titles);
window.open(adress, titles, "width=" + w + ",height=" + h + ",left=" + l + ",top=" + t + ",status=0,scroll=1,resizable=1");
}

function images(imgsrc){
	PopUp(''+xTHIS+'pop/pop.php?image='+imgsrc, '', 150, 150, 50, 50);
	void(0);
}


///////////////////////////////
////  LIST of OPTIONS
var forlist_avva = false;
var forlist_actionvalue = false;
var forlist_currentfield = false;
var forlist_pattern = "";

function getListOptions(val, forlist_list){
forlist_actionvalue = val.name;
forlist_currentfield = val;
forlist_pattern = eval("/^"+val.value+"\.*/i");
var i = 0;

//elem('forlist_select').style.left=-300+'px';

while(document.forlist_form.forlist_select.length>0)
	document.forlist_form.forlist_select.options[document.forlist_form.forlist_select.length-1]=null;

document.forlist_form.forlist_select.options[0] = new Option("select option", "", true, true);
j=1;
if(val.value.length){
	/*
	for(i = 0; i < forlist_list.length; i++){
		if(forlist_list[i] && val.value.length<forlist_list[i].length && forlist_pattern.test(forlist_list[i]) && forlist_list[i].length>1){
			document.forlist_form.forlist_select.options[j] = new Option(forlist_list[i], forlist_list[i]);
			j++;
		}
	}
	*/
	for(i in forlist_list){
		if(forlist_list[i] && val.value.length<forlist_list[i].length && forlist_pattern.test(forlist_list[i]) && forlist_list[i].length>1){
			document.forlist_form.forlist_select.options[j] = new Option(forlist_list[i], forlist_list[i]);
			j++;
		}
	}	
}
else{

	for(i in forlist_list){
		if(forlist_list[i]){
			document.forlist_form.forlist_select.options[j] = new Option(forlist_list[i], forlist_list[i]);
			j++;
		}
	}
}

if(document.forlist_form.forlist_select.length>1){
	elem('forlist_div').style.left = (getPositionX(val)+elem(val.id).offsetWidth)+'px';
	elem('forlist_div').style.top = getPositionY(val)+'px';// + elem(val.id).offsetHeight - 10;
	document.forlist_form.forlist_select.size = document.forlist_form.forlist_select.length > 15 ? 15 : document.forlist_form.forlist_select.length;
}
else{
	forlist_hidelist();
}
}


function forlist_hidelist(){
	forlist_avva = setTimeout("elem('forlist_div').style.left='-3000px';", 100);
}
function forlist_showlist(){
	clearTimeout(forlist_avva);
}

// <div id="forlist_div" style="position:absolute; left:-300;" onfocus="showlist();"><form name="forlist_form"><select id="forlist_select" multiple size="10" name="forlist_select" onchange="forlist_currentfield.value=this.value;elem('forlist_div').style.left=-300;"></select></form></div>

// onclick="getListOptions(this, Array());" onkeyup="getListOptions(this, Array());" onblur="forlist_hidelist();

////  END LIST of OPTIONS
///////////////////////////////
function formforloadinfo(requestform){

var mf = requestform;
var xdata = xTHIS+"srbajax.php?";
for(var i = 0; i < mf.length; i++){
	if(mf[i].type.toLowerCase() != "submit" && mf[i].value)
		xdata += mf[i].name + "=" + mf[i].value + "&";
}

eval(loadinfo(xdata, "POST"));
return false;
}



function loadinfo(sURL, xmethod){

xmethod = (xmethod == undefined || (xmethod != "GET" && xmethod != "POST")) ? "GET" : xmethod;

if(elem('ttt'))elem('ttt').innerHTML += "<br>method: " + xmethod;

var request = null;

if(!request){
	try{
	 	request = new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch(e){}
}
if(!request){
	try{
		request = new ActiveXObject('Microsoft.XMLHTTP');
	}
	catch(e){}
}
if(!request){
	try{
		request = new XMLHttpRequest();
	}
	catch(e){alert("AJAX DON'T WORK");}
}
if(!request)
	return "";

if(elem('ttt'))
	elem('ttt').innerHTML += [xmethod, sURL];
request.open(xmethod, sURL, false);//'POST' //xmethod
request.send(null);

return request.responseText;
}





function Dump(d, l) {
if(l == null) 
	l = 1;
var s = '';
if(typeof(d) == "object"){
	s += typeof(d) + " {\n";
	for(var k in d){
		for(var i=0; i<l; i++)
			s += "  ";
		s += k+": " + Dump(d[k], l+1);
	}
	for(var i=0; i<l-1; i++)
		s += "  ";
	s += "}\n"
} 
else s += "" + d + "\n";
return s;
}


var sl = {
	URL : "www.sentero.net",
	Mposition : 0,
	script : 0,
	vector : 0,
	scrollindex : {
		"current" : 1,
		"test" : 2
	},
	scrolllength : {
		"current" : 0,
		"test" : 0
	},	
	returnfalse : function(){
		return false;
	},
	draglayers : function(){
		if(sl.script!=0){
			if(sl.Mposition == 0){
				sl.Mposition = Mtop;
				if(sl.scrollindex[sl.script])
					sl.scrollindex['current'] = sl.scrollindex[sl.script];
			}
			var vector = Mtop - sl.Mposition;
			elem('scrolldiv_'+sl.script).scrollTop -= vector;
			elem('fulldiv_'+sl.script).scrollTop += vector * sl.scrollindex['current'];
			sl.Mposition = Mtop;
			setTimeout(sl.draglayers, 20);
		}	
	},
	cleardrag : function(){
		sl.script = 0;
		sl.Mposition = 0;
		sl.scrollindex['current'] = 1;
		sl.scrolllength['current'] = DocHeight() - (sl.heightofdesign+5);
		sl.vector = 0;
	},
	
	
	jumplayers : function(){
		if(sl.script!=0){
			var xscrollTop = Mtop - (elem("headdiv_"+sl.script).offsetHeight+40);
			elem('scrolldiv_'+sl.script).scrollTop = elem("lineup_"+sl.script).offsetHeight - xscrollTop;
			elem('fulldiv_'+sl.script).scrollTop = xscrollTop * sl.scrollindex[sl.script];
			//alert([xscrollTop, elem('scrolldiv_'+sl.script).scrollTop, elem('fulldiv_'+sl.script).scrollTop, elem("lineup_"+sl.script).offsetHeight]);
			sl.draglayers();
		}
	},
	clearjump : function(){
		sl.script = 0;
		sl.Mposition = 0;
		sl.scrollindex['current'] = 1;
		sl.scrolllength['current'] = DocHeight() - (sl.heightofdesign+5);
		sl.vector = 0;
	},
	
	
	movelayers : function(){
		if(sl.script!=0){
			if(sl.Mposition == 0){
				sl.Mposition = 1;
				if(sl.scrollindex[sl.script])
					sl.scrollindex['current'] = sl.scrollindex[sl.script];
				if(sl.scrolllength[sl.script])
					sl.scrolllength['current'] = sl.scrolllength[sl.script];
			}
			if(sl.vector!=0){
				currentposition_full = elem('fulldiv_'+sl.script).scrollTop - 10 * sl.vector;
				currentposition_scroll = sl.scrolllength['current'] - currentposition_full/sl.scrollindex['current'];
				elem('fulldiv_'+sl.script).scrollTop = currentposition_full;
				elem('scrolldiv_'+sl.script).scrollTop = currentposition_scroll;
				setTimeout(sl.movelayers, 20);
			}
		}
	},
	collapserows : function(script, vector){
		if(vector > 0){
			elem('hidden_'+script).style.display = 'none';
			elem('visible_'+script).style.display = 'block';
		}
		else{
			elem('visible_'+script).style.display = 'none';
			elem('hidden_'+script).style.display = 'block';		
		}
		setTimeout("sl.getHeightOfRows()", 100);
	},
	getHeightOfRows : function(){//parseInt
		document.body.height = DocHeight();
		elem('maintable').style.height = DocHeight() - sl.heightofdesign;
		elem('comoninfotable').style.height = DocHeight() - (sl.heightofdesign + (elem('topinfo') != null ? elem('topinfo').offsetHeight : 0));
		var allfulldivs = document.getElementsByTagName('DIV');
		var script, currentheight, curh, line, indexline;
		curh = DocHeight() - (sl.heightofdesign + 5 + (elem('topinfo') != null ? elem('topinfo').offsetHeight : 0));
		for(var i=0; i<allfulldivs.length; i++){
			if(allfulldivs[i].className == "fulldiv"){
				script = allfulldivs[i].id.substr(8);
				currentheight = curh;//DocHeight() - (sl.heightofdesign + 5);
				if(elem("visible_"+script) != null)
					elem("visible_"+script).style.height = currentheight - 6;
				if(elem("hidden_"+script) != null){
					elem("hidden_"+script).style.height = currentheight;
					elem("hiddentd_"+script).style.height = currentheight - 24;
				}

				if(elem("headdiv_"+script) != null)
					currentheight = currentheight - elem("headdiv_"+script).offsetHeight;
				if(elem("footdiv_"+script) != null)
					currentheight = currentheight - elem("footdiv_"+script).offsetHeight;


				elem("fulldiv_"+script).style.height = currentheight;
				if(elem("fulldivtd_"+script) != null)
					elem("fulldivtd_"+script).style.height = currentheight;
					
				elem("scrolldiv_"+script).style.height = currentheight - sl.heightofbar;
				indexline = Math.floor(Math.pow((currentheight - sl.heightofbar), 2) / elem("content_"+script).offsetHeight);//
				if(elem("hidden_"+script) != null)
					line = 50;
				else line = 36;
				if(elem("line_"+script) != null)
					elem("line_"+script).style.height = line;
				scrollindex = (elem("content_"+script).offsetHeight - (currentheight-sl.heightofbar)) / (currentheight-(line + sl.heightofbar));
				sl.scrollindex[script] = scrollindex;
				//sl.scrolllength[script] = elem("lineup_"+script).style.height = elem("linedn_"+script).style.height = currentheight - (line + sl.heightofbar);
				elem("scrolltable_"+script).style.height = Math.floor(2 * (currentheight - sl.heightofbar) - line);
				elem('scrolldiv_'+script).scrollTop = (currentheight - sl.heightofbar) - line + parseInt(allfulldivs[i].scrollTop) * scrollindex;
				sl.scrolllength[script] = currentheight - (line + sl.heightofbar);
				if(elem("lineup_"+script) != null && elem("linedn_"+script) != null)
					elem("lineup_"+script).style.height = elem("linedn_"+script).style.height = currentheight - (line + sl.heightofbar);
				elem("scrolltable_"+script).style.height = Math.floor(2 * (currentheight - sl.heightofbar) - line);
				elem('scrolldiv_'+script).scrollTop = (currentheight - (sl.heightofbar + line)) - parseInt(allfulldivs[i].scrollTop) / scrollindex;

				if(elem("line_"+script) != null){
					if(elem("content_"+script).offsetHeight > (currentheight - 24))
						elem('line_'+script).style.backgroundImage = 'url("'+xTHIS+'images/slider.gif")';
					else elem('line_'+script).style.backgroundImage = 'url("'+xTHIS+'images/void.gif")';
				}
			}
		}

/*
Control of specific functions of site
*/
		if(elem('alefbet'+currentlanguage) != null){
			if(DocHeight() - (elem('alefbet'+currentlanguage).offsetHeight + 100) < 0)
				elem('langalefbet').style.height = DocHeight() - (70 + elem('langselector').offsetHeight)
			else elem('langalefbet').style.height = elem('alefbet'+currentlanguage).offsetHeight;
			elem('langalefbet').scrollTop = 0;
			//elem('topdivlangalefbet').style.height = DocHeight() - sl.heightofdesign;
		}
		if(elem('linkscontent') != null){
			if(DocHeight() > 600){
				elem('linkscontent').style.display = 'block';
				if(DocHeight() - (elem('lc').offsetHeight + 530) < 0)
					elem('linkscontent').style.height = DocHeight() - 530;
				else elem('linkscontent').style.height = elem('lc').offsetHeight;
				elem('lc').scrollTop = 0;
			}
			else{
				elem('linkscontent').style.display = 'none';
			}
			//elem('topdivlangalefbet').style.height = DocHeight() - sl.heightofdesign;
		}
		if(elem('allscriptsentero_genries') != null)
			s_ganre.getbarganres();
/*
Control of specific functions of site
*/
		for(var i=0; i<10; i++){
			if(elem("row_"+i) != null){
				elem("row_"+i).style.height = DocHeight() - (sl.heightofdesign + 4);
				if(i>4){
					elem("row_"+i).style.height = elem("row_"+i).offsetHeight - (elem('topinfo') != null ? elem('topinfo').offsetHeight : 0);
					//if(elem('comoninfotable2') != null)
						//elem("comoninfotable2").style.height = DocHeight() - (sl.heightofdesign + 4 + (elem('topinfo') != null ? elem('topinfo').offsetHeight : 0))
				}
			}
		}
		//alert([(DocHeight()-10),elem('td_1').offsetHeight, elem('hideeditorchoice').offsetHeight]);
	},
	heightofbar : 24,
	heightofdesign : 10,
	hideeditorchoice : 0
}
//
function sentero_notices_delete(){
elem('comoninfotable').deleteRow(0);
sl.heightofdesign = 10;
sl.getHeightOfRows();
}

function sentero_notices_add(senteronotice){
if(typeof(elem('trrrr')) != "undefined" && elem('trrrr') && typeof(elem('senteromessage')) != "undefined" && elem('senteromessage'))
	elem('senteromessage').innerHTML = senteronotice;
else{
	elem("comoninfotable").insertRow(0);
	elem("comoninfotable").rows[0].id = 'trrrr';
	elem("comoninfotable").rows[0].insertCell(0);
	elem("comoninfotable").rows[0].insertCell(1);
	elem("comoninfotable").rows[0].insertCell(2);
	
	elem("comoninfotable").rows[0].cells[0].style.backgroundColor = '#9F0014';
	elem("comoninfotable").rows[0].cells[2].style.backgroundColor = '#9F0014';
	elem("comoninfotable").rows[0].cells[2].style.verticalAlign = 'top';
	elem("comoninfotable").rows[0].cells[0].innerHTML = '<img src="pic/void.gif" width="1" height="25" border="0">';
	elem("comoninfotable").rows[0].cells[2].innerHTML = '<a href="javascript:sentero_notices_delete();void(0);" title="close alert"><img src="images/close.gif" width="12" height="12" hspace="8" border="0"></a>';
	
	elem("comoninfotable").rows[0].cells[1].style.backgroundColor = '#9F0014';
	elem("comoninfotable").rows[0].cells[1].style.color = '#ffffff';
	elem("comoninfotable").rows[0].cells[1].style.fontSize = '80%';
	elem("comoninfotable").rows[0].cells[1].style.fontFamily = 'Tahoma, Verdana, Arial';
	elem("comoninfotable").rows[0].cells[1].style.textAlign = 'center';
	elem("comoninfotable").rows[0].cells[1].style.verticalAlign = 'top';
	elem("comoninfotable").rows[0].cells[1].innerHTML = '<b>Sentero:</b> <span id="senteromessage">'+senteronotice+'</span>';
}
sl.heightofdesign = 10 + elem('trrrr').offsetHeight;
sl.getHeightOfRows();
}


function sentero_notices_delete2(val){
	if(val == 'notice' && typeof(elem('bgcolorofinfoalert_friendform')) != "undefined" && elem('bgcolorofinfoalert_friendform').style.display == 'block'){
		elem('bgcolorofinfoalert_notice').style.display = 'none';
	}
	else{
		elem('bgcolorofinfoalert1').style.display = 'none';
		elem('bgcolorofinfoalert2').style.display = 'none';
		elem('bgcolorofinfoalert_notice').style.display = 'none';
		elem('bgcolorofinfoalert_friendform').style.display = 'none';
	}

}
function sentero_notices_add2(senteronotice){
	elem('senteromessage2').innerHTML = " "+senteronotice;
	elem('bgcolorofinfoalert1').style.display = 'block';
	elem('bgcolorofinfoalert2').style.display = 'block';
	elem('bgcolorofinfoalert_notice').style.display = 'block';
}
function sentero_friend_add2(songid, songname){
	document.mailFriend['songid'].value = songid;
	//document.mailFriend['artistname'].value = artistname;
	document.mailFriend['songname'].value = songname;
	//document.mailFriend['albumname'].value = albumname;
	//elem('aartistname').innerHTML = artistname;
	elem('asongname').innerHTML = songname;
	//elem('aalbumname').innerHTML = albumname;
	elem('senteromessage2').innerHTML = " "+senteronotice;
	elem('bgcolorofinfoalert1').style.display = 'block';
	elem('bgcolorofinfoalert2').style.display = 'block';
	elem('bgcolorofinfoalert_friendform').style.display = 'block';
}



//alert(["INTERNET-EXPLOER 7- test:\n",navigator.userAgent.toLowerCase(),"\n",Dump(currentBrowser)]);
var ajaxurlfragment = /w2\/#/i;
var systemname = /(\w){1,}/;
var empt = /(\s)*/;
var e_mail   = /^[a-z]\w*@([a-z]|[0-9]|-){2,}(\.[a-z]+){1,3}/;
var e_mail1 = /^\w([\w]|[\.])*@([a-z]|[0-9]|-){2,}(\.[a-z]+){1,3}/i;
var phones = /^(|\([0-9]+\))?([0-9]|[\d|\s|\-|\/|\:|\_])+/;    //
var passports = /[\d]{7,9}/;
var message = "";