function el(id){
	if (document.getElementById)
	return document.getElementById(id);
	if (document.all)
	return document.all(id);
	if (document.layers)
	return document.layers(id);
	alert('Brauser ERROR');
}

var first_open_search_types = 1;

function open_search_types(){
	if(first_open_search_types){
		first_open_search_types = 0;
		el('search_types_source').innerHTML = make_search_types();
	}

	if(el('search_types').style.display == 'block'){
		el('search_types').style.display = 'none';
		text = ckeck_for_checked_types() + '&nbsp;&nbsp;<img src="img/all_product_open.gif" width="5" height="3" border="0" alt="" align="absmiddle">';
		el('search_types_button').innerHTML = text;
	}else{
		el('search_types').style.display = 'block';
	}

}


arSearchTypes = new Array();
arSearchTypes['type_0'] = 'All Products';
arSearchTypes['type_1'] = 'Only Generics';
arSearchTypes['type_2'] = 'Only Brands';
arSearchTypes['type_3'] = 'Form Tablet';
arSearchTypes['type_4'] = 'Form Gel';
arSearchTypes['type_5'] = 'Form Pil';

function make_search_types(){
	var str = '';
	for(var type in arSearchTypes){
		if(type == 'type_0'){
			str += '<label for="' + type + '" onClick="sel_search_type(\'' + type + '\',this);">' + arSearchTypes[type] + '</label><br>';
		}else{
			str += '<input type="checkbox" id="' + type + '" name="' + type + '" value="1" ><label for="' + type + '" onClick="sel_search_type(\'' + type + '\',this);">' + arSearchTypes[type] + '</label><br>';
		}
	}
	return str;
}

function ckeck_for_checked_types(){
	var count = 0;
	var tid = 0;
	for(var type in arSearchTypes){
		if(type != 'type_0')
		if(el(type).checked){
			count++;
			tid = type;
		}
	}

	if(count == 0){
		return arSearchTypes['type_0'];
	}
	if(count == 1){
		return arSearchTypes[tid];
	}else{
		return 'Custom';
	}
}


function sel_search_type(id,thisEL){
	if(id == 'type_0'){
		for(var type in arSearchTypes){
			if(type != 'type_0'){
			el(type).checked = 0;
			}
		}
		open_search_types();

	}else{
		el(id).checked = 1;
		open_search_types();
	}
}

/**************************************************/

function start_DivScroll(id,time,type){
  	el(id).scrollTop = 0;
	if(type != 1){
		var Tsize = parseInt(el(id).style.fontSize.replace("px",""));
		var DH = parseInt(el(id).style.height.replace("px",""));
		var count = Math.ceil(DH/Tsize)-1;
		for (i=0;i<=count;i++){
			el(id).innerHTML += "<br>";
		}
	}
	DivScroll(id,-1,time);
}

function DivScroll(id,curent,time) {
	  el(id).scrollTop = el(id).scrollTop + 1;
	  if(curent == el(id).scrollTop){
	  	start_DivScroll(id,time,1);
	  }else{
	  	setTimeout("DivScroll('" + id + "','" + el(id).scrollTop + "','" + time + "')", time);
	  }
}
/*******************************************/

var kapchet_count = 0;
function rfresh_kapchet(){
	kapchet_count++;
	el('kapchet').src = "http://www.drugs-med.com/kcaptcha/index.php?k=" + kapchet_count;
	return False;
}



function buy_item(id,vid,czena){
	el('buy_form_id').value = id;
	el('buy_form_vid').value = vid;
	el('buy_form_czena').value = czena;
	el('buy_form').submit();
}

/****************************************************************************/

function clear_text(target) {


	target.S_Name.value = '';
	target.S_LastName.value = '';
	target.S_Phone.value = '';
	target.S_Mail.value = '';
	target.S_Address.value = '';
	target.S_City.value = '';
	target.S_State.value = '';
	target.S_ZipCode.value = '';
	target.S_Country.value = '';

	target.B_Name.value = '';
	target.B_LastName.value = '';
	target.B_Phone.value = '';
	target.B_Mail.value = '';
	target.B_Address.value = '';
	target.B_City.value = '';
	target.B_State.value = '';
	target.B_ZipCode.value = '';
	target.B_Country.value = '';

	target.C_Name.value = '';
	target.C_LastName.value = '';
	target.C_Phone.value = '';
	target.C_Mail.value = '';
	target.C_Address.value = '';
	target.C_City.value = '';
	target.C_State.value = '';
	target.C_ZipCode.value = '';
	target.C_Country.value = '';

}

function chi() {

document.OrderForm.addr2.checked=0;

}









function unlockText(target) {

// Anee iinoaaeai oea?ie, nieiaai aeiee?iaaiea eiiiee
if (target.addr.checked) {


	target.S_Name.value = target.B_Name.value;
	target.S_LastName.value = target.B_LastName.value;
	target.S_Phone.value = target.B_Phone.value;
	target.S_Mail.value = target.B_Mail.value;
	target.S_Address.value = target.B_Address.value;
	target.S_City.value = target.B_City.value;
	target.S_State.value = target.B_State.value;
	target.S_ZipCode.value = target.B_ZipCode.value;
	target.S_Country.value = target.B_Country.value;

	target.C_Name.value = target.B_Name.value;
	target.C_LastName.value = target.B_LastName.value;
	target.C_Phone.value = target.B_Phone.value;
	target.C_Mail.value = target.B_Mail.value;
	target.C_Address.value = target.B_Address.value;
	target.C_City.value = target.B_City.value;
	target.C_State.value = target.B_State.value;
	target.C_ZipCode.value = target.B_ZipCode.value;
	target.C_Country.value = target.B_Country.value;
	}
// A i?ioeaiii neo?aa aiiau aeiee?oai eiiieo
else {

	target.S_Name.value = '';
	target.S_LastName.value = '';
	target.S_Phone.value = '';
	target.S_Mail.value = '';
	target.S_Address.value = '';
	target.S_City.value = '';
	target.S_State.value = '';
	target.S_ZipCode.value = '';
	target.S_Country.value = '';

	target.C_Name.value = '';
	target.C_LastName.value = '';
	target.C_Phone.value = '';
	target.C_Mail.value = '';
	target.C_Address.value = '';
	target.C_City.value = '';
	target.C_State.value = '';
	target.C_ZipCode.value = '';
	target.C_Country.value = '';
}
}
function unlockText1(target) {

// Anee iinoaaeai oea?ie, nieiaai aeiee?iaaiea eiiiee
if (target.addr2.checked) {


	target.C_Name.value = target.B_Name.value;
	target.C_LastName.value = target.B_LastName.value;
	target.C_Phone.value = target.B_Phone.value;
	target.C_Mail.value = target.B_Mail.value;
	target.C_Address.value = target.B_Address.value;
	target.C_City.value = target.B_City.value;
	target.C_State.value = target.B_State.value;
	target.C_ZipCode.value = target.B_ZipCode.value;
	target.C_Country.value = target.B_Country.value;
	}
// A i?ioeaiii neo?aa aiiau aeiee?oai eiiieo
else {

	target.C_Name.value = '';
	target.C_LastName.value = '';
	target.C_Phone.value = '';
	target.C_Mail.value = '';
	target.C_Address.value = '';
	target.C_City.value = '';
	target.C_State.value = '';
	target.C_ZipCode.value = '';
	target.C_Country.value = '';
}
}

function unlockButton(target) {

// Anee iinoaaeai oea?ie, nieiaai aeiee?iaaiea eiiiee
if (target.addr2.checked) target.verify.disabled = 0

// A i?ioeaiii neo?aa aiiau aeiee?oai eiiieo
else target.verify.disabled = 1
}
function predi_carta(target) {

target.za_carta.value = '0';

}
function predi_carta3(target) {

target.za_carta.value = '1';

}
function predi_carta2(target) {

target.za_carta.value = '2';

}
function edit_order(target) {

target.action ="https://www.drugs-med.com/shipping_info";

}

function plashtane_carta(target) {

target.action ="https://www.drugs-med.com/verify";

}

function plashtane_other_carta(target) {

target.action ="https://www.drugs-med.com/PAY_CARD";

}

function plashtane_chek(target) {

target.action ="https://www.drugs-med.com/verify_chek";

}

function redirect() {

location.href="http://www.drugs-med.com/";

}

function redirect_time1() {

setTimeout('redirect();',4000);

}
function redirect_time() {

setTimeout('redirect();',8000);

}
function prati(target) {
if(!target.za_carta.value){target.za_carta.value = '1';alert("stava");}


//target.za_carta.value = '1';
target.submit();
}
function prati2(target) {
target.za_carta.value = '2';
//target.submit();
}

function prati3(target) {
target.za_carta.value = '3';
//target.submit();
}



function prati1(target) {
target.za_carta.value = '1';
//target.submit();
}

function deistvie(act)
{
var pole = document.getElementById('hid');
var forma = document.getElementById('or');
pole.value = act;
forma.submit();
}

function deistvie1(act)
{
//var pole = document.getElementById('hid');
//var forma = document.getElementById('or');
//pole.value = act;
act.submit();
}


function HideRow(id_to)
{
var row = document.getElementById(id_to);
var osn=id_to-10000;
var pic=id_to+10000;

var row0 = document.getElementById(osn);
var pici = document.getElementById(pic);
var browse = navigator.appName;
//var browse = navigator.userAgent;
//alert(browse);

if (browse == 'Netscape'||browse == 'Mozilla')
{


if (row.style.display == 'table-row')
{
row.style.display = 'none';
row0.style.backgroundColor='#F2F2F3';
pici.src="kopcheta/bulet_right.png";
}
else
{
row.style.display = 'table-row';
row0.style.backgroundColor='#D4D4D5';
pici.src="kopcheta/bulet_left.png";
}
}
else
{


if (row.style.display == 'block')
{
row.style.display = 'none';
row0.style.backgroundColor='#F2F2F3';
pici.src="kopcheta/bulet_right.png";
}
else
{
row.style.display = 'block';
row0.style.backgroundColor='#D4D4D5';
pici.src="kopcheta/bulet_left.png";
}
}
}


function getX(evt){
if(evt.x){ return evt.x; }
if(evt.pageX){ return evt.pageX; }
}
function getY(evt){
if(evt.y){ return evt.y; }
if(evt.pageY){ return evt.pageY; }
}

function alertCoords1(evt,id){
//alert("X = "+ getX(evt) +"\nY = "+ getY(evt));
var xixa=getX(evt);
var ygreka=getY(evt);

showWMTT(id,xixa,ygreka);

}
da=0;
ne=0;
wmtt = null;
menuobj= null;
var ie5=document.all && !window.opera
var ns6=document.getElementById

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}


function alertCoords(e,id)
{

if(ne==0){
menuobj=document.getElementById(id)


/*menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth-190+"px" : window.pageXOffset+eventX-menuobj.contentwidth-190+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-190+"px" : window.pageXOffset+eventX-190+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight-25+"px" : window.pageYOffset+eventY-menuobj.contentheight-25+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY-25+"px" : window.pageYOffset+eventY-25+"px"
*/
menuobj.style.display="block"


ne=1;
return 0;
}
}

function hide() {

setTimeout('hideWMTT();',2000);

}
function hideWMTT() {

if(da==0){

menuobj.style.display = "none";
ne=0;}
}



function open_chat(){
	var url = "http://www.drugs-med.com/chat/index.php";
	var target = "CHAT";
	window.open(url, target, 'width=625,height=500,status=0,location=0,menubar=0,resizable=1,scrollbars=1,toolbar=0');

}



