function themedb_dropdowns(){
    this.init=function()
    {
	  var bSelect=document.getElementById('brand');
	  bSelect.disabled=true;
	  bSelect.style.backgroundColor='#CCCCCC';
	  bSelect.style.color='#AAAAAA';
	  if(document.getElementById('brandLabel'))
	  {
		document.getElementById('brandLabel').innerHTML='Brand:';
	  }

	  var mSelect=document.getElementById('mid');
	  mSelect.disabled=true;
	  mSelect.style.backgroundColor='#CCCCCC';
	  mSelect.style.color='#AAAAAA';

	  var cSelect=document.getElementById('cid');
	  cSelect.disabled=true;
	  cSelect.style.backgroundColor='#CCCCCC';
	  cSelect.style.color='#AAAAAA';
    };
    this.set_lists=function(clear_lists)
    {

	  if(clear_lists == 1)
	  {
		ipb_var_ct = 0;
		ipb_var_m = 0;
		ipb_var_b = '';
		ipb_var_c = 0;

		var bSelect=document.getElementById('brand');
		bSelect.options.length=1;
		bSelect.disabled=true;
		bSelect.style.backgroundColor='#CCCCCC';
		bSelect.style.color='#AAAAAA';
	  	if(document.getElementById('brandLabel'))
	  	{
			document.getElementById('brandLabel').innerHTML='Brand:';
	  	}

		var mSelect=document.getElementById('mid');
		mSelect.options.length=1;
		mSelect.disabled=true;
		mSelect.style.backgroundColor='#CCCCCC';
		mSelect.style.color='#AAAAAA';

		var cSelect=document.getElementById('cid');
		cSelect.options.length=1;
		cSelect.disabled=true;
		cSelect.style.backgroundColor='#CCCCCC';
		cSelect.style.color='#AAAAAA';
	  }

	  var ctSelect=document.getElementById('ctid');
	  if (ipb_var_ct > 0)
	  {
		var ct=ipb_var_ct;
  	  }
	  else
	  {
	 	 var ct_index=ctSelect.selectedIndex;
	  	 var ct=ctSelect.options[ct_index].value;
	  }

	  if (ct)
	  {
		var url=ipb_var_base_url+'autocom=themes&code=getbrandoptions&ctid='+ct;
		if (ipb_var_b != '')
		{
			url = url+'&brand='+ipb_var_b;
		}
		if (ipb_var_inputcode)
		{
			if (ipb_var_inputcode == 'upload')
			{
				url = url+'&inputcode='+ipb_var_inputcode;
			}
		}
		do_request_function=function()
		{
			if(!xmlobj.readystate_ready_and_ok())
			{
				xmlobj.show_loading('');
				return;
			}
			xmlobj.hide_loading();
			var _result=xmlobj.xmlhandler.responseText;
			var _lists=_result.split("|");
			
			var brandSelect = document.getElementById('brand');
			brandSelect.options.length=0;
			var option=document.createElement('option');
			option.value='';
			if (_lists[1] == 'BRAND')
			{
				option.text='Select Brand';
	  			if(document.getElementById('brandLabel'))
				{
					document.getElementById('brandLabel').innerHTML='Brand:';	
				}			
			}
			else
			{
				option.text='Select Screensize';
	  			if(document.getElementById('brandLabel'))
	  			{
					document.getElementById('brandLabel').innerHTML='Screensize:';
	  			}
			}
			try{
				brandSelect.add(option,null);
			}catch(ex){
				brandSelect.add(option);
			}

		      var catSelect = document.getElementById('cid');
		      catSelect.options.length = 0;
		      var option=document.createElement('option');
		      option.value='';
		      option.text='Select Category';
		      try{
			  catSelect.add(option,null);
		      }catch(ex){
			  catSelect.add(option);
		      }

			if (document.getElementById('screenshotRow2'))
			{
				var screenshotRow2 = document.getElementById('screenshotRow2');
				if (_lists[0] == 1)
				{
					try{
						screenshotRow2.style.display = 'table-row';
					}catch(ex){
						screenshotRow2.style.display = 'block';
					}
				}
				else
				{
					screenshotRow2.style.display = 'none';
				}
			}
			
			if (document.getElementById('screenshotRow'))
			{
				var screenshotRow = document.getElementById('screenshotRow');
				if (_lists[0] == 1)
				{
					try{
						screenshotRow.style.display = 'table-row';
					}catch(ex){
						screenshotRow.style.display = 'block';
					}
				}
				else
				{
					screenshotRow.style.display = 'none';
				}
			}

			if (document.getElementById('brandRow'))
			{
				var brandRow = document.getElementById('brandRow');
				if ((_lists[2] == 'disable') || (_lists[2] == ''))
				{
					brandRow.style.display = 'none';
				}
				else
				{
					try{
						brandRow.style.display = 'table-row';
					}catch(ex){
						brandRow.style.display = 'block';
					}
				}
			}

			if (document.getElementById('modelRow'))
			{
				var modelRow = document.getElementById('modelRow');
				if ((_lists[2] == 'disable') || (_lists[2] == ''))
				{
					modelRow.style.display = 'none';
				}
				else if (_lists[1] == 'BRAND')
				{
					try{
						modelRow.style.display = 'table-row';
					}catch(ex){
						modelRow.style.display = 'block';
					}
				}
				else
				{
					modelRow.style.display = 'none';
				}
			}

			if((_lists[2] == 'disable') || (_lists[2] == ''))
			{
				var brandSelect = document.getElementById('brand');
				brandSelect.disabled=true;
				brandSelect.style.backgroundColor='#CCCCCC';
				brandSelect.style.color='#AAAAAA';
	  			if(document.getElementById('brandLabel'))
	  			{
					document.getElementById('brandLabel').innerHTML='Brand:';
	  			}	
			}
			else
			{
				var brandSelect = document.getElementById('brand');
				brandSelect.disabled=false;
				brandSelect.style.backgroundColor='#FFFFFF';
				brandSelect.style.color='#000000';

				var brandoptions=_lists[2].split(",");
				var option=document.createElement('option');
				option.value='all';
				if(_lists[1] == 'BRAND')
				{
					option.text='All Brands';
				}
				else
				{
					option.text='All Screensizes';
				}
				try{
					brandSelect.add(option,null);
				}catch(ex){
					brandSelect.add(option);
				}
				if (ipb_var_b == 'all')
				{
					var b_index=1;
				}

				for(i=0;i<brandoptions.length;i++)
				{
					var option=document.createElement('option');
					option.value=brandoptions[i];
					option.text=brandoptions[i];
					try{
						brandSelect.add(option,null);
					}catch(ex){
						brandSelect.add(option);
					}

				 	if (ipb_var_b)
					{
						if(ipb_var_b == brandoptions[i])
						{
							var b_index = i+2;
						}
					}
				}

				if (b_index)
				{
					brandSelect.selectedIndex=b_index;
				}

			}

			if((_lists[3] == 'disable') || (_lists[3] == ''))
			{
				catSelect.disabled=true;
				catSelect.style.backgroundColor='#CCCCCC';
				catSelect.style.color='#AAAAAA';
			}
			else
			{
				var catoptions=_lists[3].split(",");
				catSelect.disabled=false;
				catSelect.style.backgroundColor='#FFFFFF';
				catSelect.style.color='#000000';

				var option=document.createElement('option');
				option.value='all';
				option.text='All Categories';
				try{
					catSelect.add(option,null);
				}catch(ex){
					catSelect.add(option);
				}
				if (ipb_var_c == 'all')
				{
					var c_index=1;
				}

				for(i=0;i<catoptions.length;i++)
				{
					var option=document.createElement('option');
				      temp=catoptions[i].split(":");
					option.value=temp[0];
					option.text=temp[1];
					try{
						catSelect.add(option,null);
					}catch(ex){
						catSelect.add(option);
					}

				 	if (ipb_var_c)
					{
						if(ipb_var_c == temp[0])
						{
							var c_index = i+2;
						}
					}
				}

				if (c_index)
				{
					catSelect.selectedIndex=c_index;
				}
			}

			if (_lists[4])
			{
				var modelSelect=document.getElementById('mid');
				var modeloptions=_lists[4].split(",");
				modelSelect.disabled=false;
				modelSelect.style.backgroundColor='#FFFFFF';
				modelSelect.style.color='#000000';

				var option=document.createElement('option');
				option.value='all';
				option.text='All Models';
				try{
					modelSelect.add(option,null);
				}catch(ex){
					modelSelect.add(option);
				}
				if (ipb_var_m == 'all')
				{
					var m_index=1;
				}

				for(i=0;i<modeloptions.length;i++)
				{
					var option=document.createElement('option');
				      temp=modeloptions[i].split(":");
					option.value=temp[0];
					option.text=temp[1];
					try{
						modelSelect.add(option,null);
					}catch(ex){
						modelSelect.add(option);
					}

				 	if (ipb_var_m)
					{
						if(ipb_var_m == temp[0])
						{
							var m_index = i+2;
						}
					}
				}

				if (m_index)
				{
					modelSelect.selectedIndex=m_index;
				}
			}
		};
            xmlobj=new ajax_request();
            xmlobj.onreadystatechange(do_request_function);
            xmlobj.process(url);
	  }
	  return false;
    };
    this.set_models=function()
    {
	  var brandSelect=document.getElementById('brand');
	  var b_index=brandSelect.selectedIndex;
	  var b=brandSelect.options[b_index].value;
	  if (b)
	  {
            var url=ipb_var_base_url+'autocom=themes&code=getmodeloptions&brand='+b;
            do_request_function=function()
            {
                if(!xmlobj.readystate_ready_and_ok())
                {
                    xmlobj.show_loading('');
                    return;
                }
                xmlobj.hide_loading();
                var modelstring=xmlobj.xmlhandler.responseText;

		    var modelSelect = document.getElementById('mid');
		    modelSelect.options.length = 0;
		    var option=document.createElement('option');
		    option.value='';
		    option.text='Select Model';
		    try{
			modelSelect.add(option,null);
		    }catch(ex){
			modelSelect.add(option);
		    }

		    if(modelstring == '')
		    {
			  modelSelect.disabled=true;
			  modelSelect.style.backgroundColor='#CCCCCC';
			  modelSelect.style.color='#AAAAAA';
		    }
		    else
                {
			  var modeloptions = modelstring.split(",");
			  modelSelect.disabled=false;
			  modelSelect.style.backgroundColor='#FFFFFF';
			  modelSelect.style.color='#000000';

			  var option=document.createElement('option');
			  option.value='all';
			  option.text='All Models';
			  try{
				modelSelect.add(option,null);
			  }catch(ex){
				modelSelect.add(option);
			  }
			  if (ipb_var_m == 'all')
			  {
				var m_index=1;
			  }

			  for(i = 0;i < modeloptions.length;i++)
			  {
			      var temp = modeloptions[i].split(":");
				var option = document.createElement('option');
				option.value = temp[0];
				option.text = temp[1];
				try{
					modelSelect.add(option,null);
				}
				catch(ex)
				{
					modelSelect.add(option);
				}

			 	if (ipb_var_m)
				{
					if(ipb_var_m == temp[0])
					{
						var m_index = i+2;
					}
				}
			}
			if (m_index)
			{
				modelSelect.selectedIndex=m_index;
			}

                  menu_action_close();
                }
            };
            xmlobj=new ajax_request();
            xmlobj.onreadystatechange(do_request_function);
            xmlobj.process(url);
	  }
        return false;
    };
}

function file_rate(){


		  
    this.settings={
        'allow_rating':1,
        'default_rating':0,
        'img_star_on':'star.gif',
        'img_star_selected':'star.gif',
        'img_star_off':'star-faded.gif',
        'img_main_star_0':'rating_0.gif',
        'img_main_star_1':'rating_1.gif',
        'img_main_star_2':'rating_2.gif',
        'img_main_star_3':'rating_3.gif',
        'img_main_star_4':'rating_4.gif',
        'img_main_star_5':'rating_5.gif',
        'img_base_url':'/forum/style_images/themes',
        'div_rating_wrapper':'rate-select',
	  'div_rating_label':'rate-select-label',
	  'div_rating_count':'rate-ratings',
	  'text_rating_1':'',
	  'text_rating_2':'',
	  'text_rating_3':'',
	  'text_rating_4':'',
	  'text_rating_5':'',
        'text_rating_image':'file-rating-img-'
    };
    this.languages={
        'img_alt_rate':'',
        'rate_me':''
    };
    this.init_rating_images=function()
    {
        var html='';
        if(!this.settings['allow_rating'])
        {
            return false;
        }
        for(var i=1;i<=5;i++){
            var _onmouseover='';
            var _onmouseout='';
            var _onclick='';
            var _title='';
            _onmouseover=' onmouseover="this.style.cursor=\'pointer\'; file_rate.show_rating_images('+i+', 0)"';
            _onmouseout=' onmouseout="file_rate.show_rating_images('+this.settings['default_rating']+', 1)"';
            _onclick=' onclick="file_rate.send_rating('+i+')"';
            _title=this.languages['img_alt_rate'];
            html+="<img style='vertical-align:top' src='"+this.settings['img_base_url']+'/'+this.settings['img_star_off']+"' "+_onmouseover+_onmouseout+_onclick+"id='"+this.settings['text_rating_image']+i+"' alt='-' title='"+_title+"' />";
        }
        document.getElementById(this.settings['div_rating_wrapper']).innerHTML=this.languages['rate_me']+' '+html;
        this.show_rating_images(this.settings['default_rating'],1);
    };
    this.send_rating=function(rating)
    {
	
	var ipb_var_base_url = "http://www.tehkseven.net/forum/index.php?s=&";
	
        rating=rating?rating:0;
        if(rating)
        {

		  
            var url=ipb_var_base_url+'autocom=themes&code=addrating&fid='+fid+'&rating='+rating;
            do_request_function=function()
            {
                if(!xmlobj.readystate_ready_and_ok())
                {
                    xmlobj.show_loading('');
                    return;
                }
                xmlobj.hide_loading();
                var html=xmlobj.xmlhandler.responseText;
                if(html=='invalid_file')
                {
                    alert(js_error_invalid_file);
                }
		    else if (html == 'invalid_rating')
		    {
			  alert(js_error_invalid_rating);
		    }
		    else if (html == 'no_permission')
		    {
			  alert(js_error_no_permission);
		    }
		    else if (html == 'already_rated')
		    {
			  alert(js_error_already_rated);
		    }
		    else
                {
                    var _result=html.split(',');
			  var _totalrating=parseInt(_result[0]);
			  var _rating=parseInt(_result[1]);
                    file_rate.show_rating_images(_rating,1);
			  document.getElementById(file_rate.settings['div_rating_count']).innerHTML=_totalrating+' ratings';
                    menu_action_close();
                    show_inline_messages_instant('rating_updated');
                }
            };
            xmlobj=new ajax_request();
            xmlobj.onreadystatechange(do_request_function);
            xmlobj.process(url);
            return false;
        }
    };
    this.show_rating_images=function(rating,restore_default)
    {
        rating=parseInt(rating);
        var star=this.settings['img_star_selected'];
        for(var i=1;i<=5;i++)
        {
            var _img=document.getElementById(this.settings['text_rating_image']+i);
            _img.src=this.settings['img_base_url']+'/'+this.settings['img_star_off'];
        }
        for(var i=1;i<=rating;i++)
        {
            var _img=document.getElementById(this.settings['text_rating_image']+i);
            _img.src=this.settings['img_base_url']+'/'+star;
        }

	  if (restore_default)
	  {
		document.getElementById(this.settings['div_rating_label']).innerHTML=rate_me;
	  }
	  else
	  {
		document.getElementById(this.settings['div_rating_label']).innerHTML=this.settings['text_rating_'+rating];
	  }
    };
};
function admin()
{
	this.showHideDiv=function()
	{
		var admin_div = document.getElementById('admin_edit');
		if (admin_div.style.display == 'none')
		{
			admin_div.style.display == 'block';
		}
		else
		{
			admin_div.style.display == 'none';
		}
	};
};