function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function makemaddress(user, host, addons) {
	if(host){
		document.write('<a href="mailto:'+user+'@'+host+'" '+addons+'>'+user+'@'+host+'</a>');
	}else{
		document.write('<a href="mailto:'+user+'@'+'store.bg" '+addons+'>'+user+'@'+'store.bg</a>');
	}
}
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
function emelentSet(id,s) {
  if (id.indexOf('.')!=-1) {
    temp = document.getElementsByTagName("*");
    templength=temp.length;
    for (i=0;i<templength;i++) {
      if (id=='.'+temp[i].className) {
        temp[i].innerHTML = s;
      }
    }
  } else {
    if (document.getElementById(id)) {
      document.getElementById(id).innerHTML = s;
    }
  }
}
function emelentAdd(id,s) {
  if (id.indexOf('.')!=-1) {
    temp = document.getElementsByTagName("*");
    templength=temp.length;
    for (i=0;i<templength;i++) {
      if (id=='.'+temp[i].className) {
        if (!temp[i].innerHTMLmemo) { temp[i].innerHTMLmemo=temp[i].innerHTML; }
        temp[i].innerHTML = (parseFloat(temp[i].innerHTMLmemo) || 0)+s;
      }
    }
  } else {
    if (document.getElementById(id)) {
      if (!document.getElementById(id).innerHTMLmemo) { document.getElementById(id).innerHTMLmemo=document.getElementById(id).innerHTML; }
      document.getElementById(id).innerHTML = (parseFloat(document.getElementById(id).innerHTMLmemo) || 0)+s;
    }
  }
}
function showHide(showObjStr,hideObjStr,showObjStyle) {
  applyDisplay(hideObjStr,'none');
  applyDisplay(showObjStr,showObjStyle);
}
function showHideOnCheck(Checker, ObjStr,ObjStyle) {
  if (Checker.checked) { 
    applyDisplay(ObjStr,ObjStyle); 
  } else { 
    applyDisplay(ObjStr,'none'); 
  }
}
function applyDisplay(objStr,objDisplay) {
  temp=objStr.split(',');
  templength=temp.length;
  for (i=0;i<templength;i++) {
    if (temp[i].charAt(0)!='.') {
      if (document.getElementById(temp[i])) { document.getElementById(temp[i]).style.display = objDisplay; }
    }
  }
  if (objStr.indexOf('.')!=-1) {
    objStr+=',';
    temp = document.getElementsByTagName("*");
    templength=temp.length;
    for (i=0;i<templength;i++) {
      if (objStr.indexOf('.'+temp[i].className+',')!=-1) { temp[i].style.display = objDisplay; }
    }
  }
}
function applyVisibility(objStr,objDisplay) {
  temp=objStr.split(',');
  templength=temp.length;
  for (i=0;i<templength;i++) {
    if (temp[i].charAt(0)!='.') {
      if (document.getElementById(temp[i])) { document.getElementById(temp[i]).style.visibility = objDisplay; }
    }
  }
  if (objStr.indexOf('.')!=-1) {
    objStr+=',';
    temp = document.getElementsByTagName("*");
    templength=temp.length;
    for (i=0;i<templength;i++) {
      if (objStr.indexOf('.'+temp[i].className+',')!=-1) { temp[i].style.visibility = objDisplay; }
    }
  }
}

function getElementsByClassName(classname, node) {
	if(!node) node = document.getElementsByTagName("body")[0];
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for(var i=0,j=els.length; i<j; i++)
	if(re.test(els[i].className))a.push(els[i]);
	return a;
}

function applyCSS(objStr,newClass) {  
  temp=objStr.split(',');
  templength=temp.length;
  for (i=0;i<templength;i++) {
    if (temp[i].charAt(0)!='.') {
      if (document.getElementById(temp[i])) { document.getElementById(temp[i]).className = newClass; }
    }
  }
  if (objStr.indexOf('.')!=-1) {
    objStr+=',';
    temp = document.getElementsByTagName("*");
    templength=temp.length;
    for (i=0;i<templength;i++) {
      if (temp[i].realClassName) {
        if (objStr.indexOf('.'+temp[i].realClassName+',')!=-1) { temp[i].className = newClass; }
      } else {
        if (objStr.indexOf('.'+temp[i].className+',')!=-1) { temp[i].realClassName=temp[i].className; temp[i].className = newClass; }
      }
    }
  }
}


function switchTabs(tabsGroup,activeTab,tabCss, ind) {   
  applyCSS('.ac_tb_td_'+tabsGroup+'_l',tabCss+'-l-i-td');
  applyCSS('.ac_tb_tx_'+tabsGroup+'_l',tabCss+'-l-i-tx');
  applyCSS('.ac_tb_td_'+tabsGroup+'_m',tabCss+'-m-i-td');
  applyCSS('.ac_tb_tx_'+tabsGroup+'_m',tabCss+'-m-i-tx');
  applyCSS('.ac_tb_td_'+tabsGroup+'_r',tabCss+'-r-i-td');
  applyCSS('.ac_tb_tx_'+tabsGroup+'_r',tabCss+'-r-i-tx');  
  applyCSS('ac_tb_td_'+tabsGroup+'_'+ind+'_'+activeTab,tabCss+'-'+ind+'-a-td');
  applyCSS('ac_tb_tx_'+tabsGroup+'_'+ind+'_'+activeTab,tabCss+'-'+ind+'-a-tx');      
  showHide('sh_tb_table_'+tabsGroup+'_'+activeTab,'.sh_tb_table_'+tabsGroup,'block');
  showHide('sh_tb_errors_'+tabsGroup+'_'+activeTab,'.sh_tb_errors_'+tabsGroup,'block');
}
function checkResolution(objStr1,resLimit1,objStr2,resLimit2,objStr3,resLimit3,objStr4,resLimit4,objStr5,resLimit5) {
  windowWidth=(window.innerWidth || document.body.offsetWidth);
  applyDisplay(objStr1+','+objStr2+','+objStr3+','+objStr4+','+objStr5,'none');
  temp=objStr1;
  for (i=1;i<5;i++) { eval("if (windowWidth>resLimit"+i+" && objStr"+(i+1)+") { temp=objStr"+(i+1)+"; }"); }
  applyDisplay(temp,'block');
}

function get_cookie ( cookie_name ) {
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function set_cookie ( cookie_name, cookie_value, exp_y, exp_m, exp_d, cookie_path, cookie_domain, cookie_secure ) {
  var cookie_string = cookie_name + "=" + escape ( cookie_value );
  if ( exp_y ) {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }
  if ( cookie_path ) { cookie_string += "; path=" + escape ( cookie_path ); }
  if ( cookie_domain ) { cookie_string += "; domain=" + escape ( cookie_domain ); }
  if ( cookie_secure ) { cookie_string += "; secure"; }
  document.cookie = cookie_string;
}

function confirmclick(question, url){
  if(confirm(question)) {
    location.href = url;
  }
}

var dd_wait = 1300;
var dd_hideTimer;
function dd_menu_keep(){if(dd_hideTimer != null)clearTimeout(dd_hideTimer);}
function dd_menu_hide(hideObjStr){dd_hideTimer = setTimeout("applyVisibility('"+hideObjStr+"','hidden');", dd_wait);}

//switchblock
function switchblock(id, action){
	elementtoswitch = document.getElementById(id);
	if(action == 'hide'){
		elementtoswitch.style.display='none';
	}else if(action == 'show'){
		elementtoswitch.style.display='';
	}
}
var bigscreen=false;
document.cookie="usrdisplay="+window.screen.width+"x"+window.screen.height+"; domain=store.bg; path=/;";
if(window.screen.width > 1000){
	bigscreen=true;
}
//Text Sizer
//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr');
//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large' );
var startSz = 1;
function ts( trgt,inc ) {
if (!document.getElementById) return
var d = document,cEl = null,sz = startSz,i,j,cTags;
sz += inc;
if ( sz < 0 ) sz = 0;
if ( sz > 6 ) sz = 6;
startSz = sz;
if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
cEl.style.fontSize = szs[ sz ];
for ( i = 0 ; i < tgs.length ; i++ ) {
cTags = cEl.getElementsByTagName( tgs[ i ] );
for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
}
}
function checkUncheck(e, unchecked_color, checked_color){
	inputs=e.getElementsByTagName('input');
	
	if(inputs[0].checked == false){
		inputs[0].checked=true;	
		e.style.backgroundColor=checked_color;
	}else {
		inputs[0].checked=false;
		e.style.backgroundColor=unchecked_color;
	}
}


