function screen_width(){
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3){
/* screenW = window.innerWidth;*/
	screenW = document.body.clientWidth
}
else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 screenW = document.body.clientHeight
 //screenH = jScreenSize.height;
}

if	(screenW>=1152 && screenW<1280){return 654;}
if  (screenW>=1280){return 654;}
if	(screenW<1280){return 540;}

}


function screen_height(){
if (screen_width()==654){return 407;}
if (screen_width()==540){return 343;}
}

function player_type (){
	if (screen_width()==654) {return '';}
	if (screen_width()==540) {return '2';}
	
}




function BuildBlocks (){
	
		
	if (screen_width()==654){

		document.getElementById('player_div').style.width='655';
		document.getElementById('player_div').style.height='407';
		document.getElementById('Bline').style.display='none';
		document.getElementById('shabka').style.width='655';
		shabka
	}
	
	if (screen_width()==540){
	document.getElementById('player_div').style.width='548';
	document.getElementById('player_div').style.height='360';
	document.getElementById('Rline').style.display='none';
	}	
}



function show_title(id){
document.getElementById(id).style.display = '';
} 
function hide_title(id){
document.getElementById(id).style.display = 'none';
}


function switch_info(id1,id2){

	show_title(id1);
	hide_title(id2);
	document.getElementById('b_'+id1).style.background = "#FE5B00";
	document.getElementById('b_'+id1).style.color = "#FFFFFF";
	document.getElementById('b_'+id2).style.background = "#E1E1E1";
	document.getElementById('b_'+id2).style.color = "#000000";
}




function rate(rateID){

	rid = rateID.substr(4);

	for (i=1; i<=rid; i++){	
	document.getElementById('rate'+i).style.display = '';
	}

	for (s=5; s>rid; s--){	
	document.getElementById('rate'+i).style.display = 'none';
	}
	
}

function rate_no(id){
//	for (i=5; i>=1; i++){
//	document.getElementById('rate'+i).style.display = 'none';
//	}
}




function transparent(element)
{
   if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
    var src = element.src;
    var realSrc = src;
    if ( /\.png$/.test( realSrc.toLowerCase() ) ) {
     element.src = "./themes/video/images/spacer.gif";
     if (src) {
      element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
     }
    }
   
}
}




	VideoSearchURL='http://video.boom.ge/index.php?action=10';


function SetSearchPlace (object){

allURL    = Array(
        'http://video.boom.ge/index.php?action=10',
        'http://links.boom.ge/search.php',
        'http://boom.ge/search.php'
      );	
	searchCount=3;
	 
  for(i=1; i<=searchCount ; i++)

     document.getElementById('search'+i).className =(object==i)?'searchActive':'searchInactive'; 
      
  VideoSearchURL = allURL[object-1]; 
  

  if(document.forms['search'].query.value!=""){
    SendRequestVideo();
    document.forms['search'].submit();
  }
  return false;
}



function SendRequestVideo (){
	document.forms['search'].action = VideoSearchURL;
}

function setsmile(code){
current_text = document.getElementById('coment_text').value;
all_text=current_text+code;

document.getElementById('coment_text').innerHTML=all_text;
document.getElementById('coment_text').value=all_text;
}

/*
function insert_smile (code) {
	
}

function replaceSelectedText(obj,cbFunc)
{
 obj.focus();
 
 if (document.selection) 
 {
   var s = document.selection.createRange(); 
   if (s.text)
   {
     eval("s.text="+cbFunc+"(s.text);");
	 s.select();
	 return true;
   }
 }
 else if (typeof(obj.selectionStart)=="number")
 {
   if (obj.selectionStart!=obj.selectionEnd)
   {
     var start = obj.selectionStart;
     var end = obj.selectionEnd;

     eval("var rs = "+cbFunc+"(obj.value.substr(start,end-start));");
     obj.value = obj.value.substr(0,start)+rs+obj.value.substr(end);
     obj.setSelectionRange(end,end);
   }
   return true;
 }

 return false;
}


*/



function upload_type (type){
	
	if (type=='L'){
		document.getElementById('L').style.display = 'block';
		document.getElementById('Y').style.display = 'none';
	}
	if (type=='Y'){
		document.getElementById('L').style.display = 'none';
		document.getElementById('Y').style.display = 'block';
	}
	
}

function gebi (uid){
	return document.getElementById(uid);
}

function show_div(div_id){
	gebi (div_id).style.visibility = 'show';
}
function hide_div(div_id){
	gebi (div_id).style.visibility = 'hidden';
}


function send_mail() {
	
		var Param = Form.serialize('email');
		var div_id = 'send_to_friend';
		var url = 'send_msg.php';
	    var myAjax = new Ajax.Updater	(div_id,url,{
	    														method: 'POST',
	    														parameters: Param,
	    														evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);

}



/*

function Upload_window(domain) {
	

		var div_id = 'up_win';
		//var url = 'other/watching.php';
		var url = 'other/upload_ajax.php?domain='+domain;
	    var myAjax = new Ajax.Updater	(div_id,url,{
	    														method: 'GET',
	    														evalScripts: true

	    													}
	    								);

}
*/






function GR_TP_addClassName (ele, className)
{
 if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
  return;
 ele.className += (ele.className ? " " : "") + className;
};

function GR_TP_removeClassName (ele, className)
{
 if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
  return;
 ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};



function redirect_url (){
	top.location.href='http://video.boom.ge/?action=15&comp=&name=Youtube';
}

function main_videos(param){
	
		
		for(i=1;i<6;i++){
				if (i==param){
				GR_TP_addClassName(gebi('link'+i),'tab_bg');	
				}
				else{
				GR_TP_removeClassName(gebi('link'+i),'tab_bg');
				}
				
		}
		var div_id = 'main_videos';
		var url = 'main_videos.php?param='+param;

	    var myAjax = new Ajax.Updater	(div_id,url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
		
	
}

function main_events(param){
	


		var div_id = 'main_events';
		var url = 'main_videos.php?param='+param;
	
	    var myAjax = new Ajax.Updater	(div_id,url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
		
	
}




function change_class(total_,button,prefix){
	//alert(button);
	for(i=1;i<=total_;i++){
		if (i==button){
			GR_TP_removeClassName(gebi(prefix+i),'inactive_tab_bg');
			GR_TP_addClassName(gebi(prefix+i),'active_tab_bg');	
		}
		else{
			//alert(prefix+i);
			GR_TP_removeClassName(gebi(prefix+i),'active_tab_bg');
			GR_TP_addClassName(gebi(prefix+i),'inactive_tab_bg');
		}		
	}
}






function related_switcher(param,num,dom_id,button,total,pref_name){
	
	change_class(total,button,pref_name);
	
	url='pages/related_switcher.php?switch='+param+'&object='+num;
	var myAjax = new Ajax.Updater	(dom_id,url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
		
	
}



function select_Cnt(elm_Name, num, formID){
	formID =  formID||0;
	
	obj_Form	= document.forms[formID];
	elm_Cnt		= obj_Form.elements[elm_Name].length;

	cnt = 0;
	for (i=0; i<elm_Cnt; i++){
		if(obj_Form.elements[elm_Name][i].selected){
			cnt++;
		}
	}

	if(cnt > num){
		alert("The number of Brand that can be selected is up to "+num);
		for (i=0; i<elm_Cnt; i++){
			obj_Form.elements[elm_Name][i].selected = false;
		}
	}
}





function listen(music,artist,sid){
  var params = 'width=260, height=200, status=no, toolbar=no, menubar=no,resizable=no, scrollbars=no,titlebar=no, left=500,top=30';
  window.open('listen.php?action=6&num='+music+'&artist='+artist+'&sid='+sid,'name',params,true);
  return false;
}



function show_code(){
  var params = 'width=480, height=380, status=no, toolbar=no, menubar=no,resizable=no, scrollbars=no,titlebar=no, left=500,top=30';
  window.open('get_code.php','get_code',params,true);
  return false;
}
function show_embed_code(num,artist,sid){
  var params = 'width=480, height=380, status=no, toolbar=no, menubar=no,resizable=no, scrollbars=no,titlebar=no, left=500,top=30';
  window.open('get_embed_code.php?num='+num+'&artist='+artist+'&sid='+sid,'get_code',params,true);
  return false;
}
function listen_pl(pl){
  var params = 'width=400, height=650, status=no, toolbar=no, menubar=no,resizable=no, scrollbars=no,titlebar=no, left=500,top=30';
  window.open('pl_listen.php?action=6&pl_id='+pl,'pl',params,true);
  return false;
}
function listen_album(album_params){
  var params = 'width=400, height=370, status=no, toolbar=no, menubar=no,resizable=no, scrollbars=no,titlebar=no, left=500,top=30';
  window.open('pl_listen.php?action=6'+album_params+'','pl',params,true);
  return false;
}
function upload_form(url,unum){
  var params = 'width=800, height=420, status=no, toolbar=no, menubar=no,resizable=yes, scrollbars=no,titlebar=no, left=300,top=100';
  window.open(url+'select_file2.php?unum='+unum,'',params,true);
  return false;
}

function add_playlist_form(url,desg){
  var params = 'width=468, height=150, status=no, toolbar=no, menubar=no,resizable=yes, scrollbars=no,titlebar=no, left=300,top=100';
  window.open(url+'?unum='+desg,'add',params,true);
  return false;
}

function share_playlist(pl_id,share_mode){
	dom_id = 'pl'+pl_id;
	url='pages/share_playlist.php?pl_id='+pl_id+'&mode='+share_mode;
	var myAjax = new Ajax.Updater	(dom_id,url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
	
}


function show_details(artist_numid,who){
	

	if (gebi(artist_numid).innerHTML==''){
	gebi(artist_numid).style.display='block';
	gebi(artist_numid).innerHTML = '<img src="themes/video/images/loading.gif">';
	
	object_url='pages/show_details.php?action=6&art='+who;
//	alert(object_url);

	var myAjax = new Ajax.Updater	(artist_numid,object_url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
	}else{
	if (gebi(artist_numid).style.display=="none"){
	gebi(artist_numid).style.display="block";
	}else{
	gebi(artist_numid).style.display="none";	
	}
	}
}


function add_Playlist(num,div_id){
	
	url='pages/add_playlist.php?track_id='+num+'&div_id='+div_id;
	var myAjax = new Ajax.Updater	(div_id,url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
	
}

function add_Playlist_Process(form_id){
	
		var Param = Form.serialize('pl_add'+form_id);
		var div_id = 'add_playlist';
		var url = 'pages/add_playlist.php';
	    var myAjax = new Ajax.Updater	(div_id,url,{
	    														method: 'POST',
	    														parameters: Param,
	    														evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
	
}


function writeCookie_ok(cookieName, cookieContent, cookieExpireTime){

  var cookiePath = '/';
  if(cookieExpireTime>0){
    var expDate=new Date()
    expDate.setTime(expDate.getTime()+cookieExpireTime*1000*60*60)
    var expires=expDate.toGMTString()
    document.cookie=cookieName+"="+escape(cookieContent)+";path="+escape(cookiePath)+";expires="+expires+";domain=fans.ge";
  }
  else{
    document.cookie=cookieName+"="+escape(cookieContent)+";path="+escape(cookiePath)+";domain='fans.ge'";
  } 
}

function switch_alfavit (alph_id){
	
	if (alph_id=='alph_ge'){
		gebi('alph_en').style.display='none';
		gebi('alph_ru').style.display='none';
		gebi('alph_ge').style.display='block';
		
		gebi('b_ge').style.backgroundImage="url('themes/video/images/abc_switch_bg.gif')";
		gebi('b_en').style.backgroundImage='';
		gebi('b_ru').style.backgroundImage='';

		writeCookie_ok ('abc','ge','60');
	}
	
	if (alph_id=='alph_ru'){
		gebi('alph_en').style.display='none';
		gebi('alph_ru').style.display='block';
		gebi('alph_ge').style.display='none';
		
		gebi('b_ru').style.backgroundImage="url('themes/video/images/abc_switch_bg.gif')";
		gebi('b_en').style.backgroundImage='';
		gebi('b_ge').style.backgroundImage='';
		writeCookie_ok ('abc','ru','60');
	}
	if (alph_id=='alph_en'){
		gebi('alph_en').style.display='block';
		gebi('alph_ru').style.display='none';
		gebi('alph_ge').style.display='none';
		
		gebi('b_en').style.backgroundImage="url('themes/video/images/abc_switch_bg.gif')";
		gebi('b_ru').style.backgroundImage='';
		gebi('b_ge').style.backgroundImage='';
		writeCookie_ok ('abc','en','60');
	}
	
}



 function suggest_title (){
	setTimeout(function() {
		param = gebi('searchBox').value;
		if (param==''){
			param = gebi('searchBox').InnerHTML;
		}
		url='other/suggest.php?param='+encodeURIComponent(param);
		dom_id = 'suggest_div';
		var myAjax = new Ajax.Updater	(dom_id,url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
	}, 1000 );
	

}

 function suggest_title2(){
	setTimeout(function() {
		param = gebi('searchBox').value;
		if (param==''){
			param = gebi('searchBox').InnerHTML;
		}
		url='other/suggest2_for_code.php?param='+encodeURIComponent(param);
		dom_id = 'suggest_div';
		var myAjax = new Ajax.Updater	(dom_id,url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    														//onComplete:   function() { showHide(div_id,'show'); },
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
	}, 1000 );
	

}

function set_tr_color(tr_id){

	gebi(tr_id).style.background='#FFF6B7';
}

function set_search_text(new_param){
	
	//gebi('searchBox').value = new_param;
	//gebi('suggest_div').style.display = 'none';
	top.location.href='index.php?action=10&query='+new_param;
}

function turn_off_suggest(){

	gebi('suggest_div').innerHTML = '';
}


function ShowFaceBookLogin(){
   
    dom_id = 'FB_Login_form';
     url='other/FB_ajax_login.php';
    document.getElementById(dom_id).style.display = 'block'; 
	var myAjax = new Ajax.Updater	(dom_id,url,{
	    														method: 'GET',
																evalScripts: true
	    														
	    													//	onComplete:   function() {document.getElementById(dom_id).style.display = 'block';},
	    														/*onException:  function() { document.forms['SF_products_search'].submit(); }*/
	    													}
	    								);
}

function close_FB_login_form(){
    gebi('FB_Login_form').innerHTML='';
    gebi('FB_Login_form').style.display = 'none';
}

