var width;
var height;

function readScreenSize() {
	if (self.screen) {
		width = screen.width
		height = screen.height
	}
	else if (self.java) {
		var jkit = java.awt.Toolkit.getDefaultToolkit();
		var scrsize = jkit.getScreenSize();
		width = scrsize.width;
		height = scrsize.height;
	}
	if (!width && !height) {
		width=1024;
		height=768;
	}
}
readScreenSize();

function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sProp]
		el = el.offsetParent
	}
	return iPos
}

function redirect(l) {
	alert(l);
	//location.href=l;
}

function openMenu(n,el) {
	html=" ";
	document.getElementById("dropmenu").innerHTML=html;
	html="";
	for(i=1;i<=submenu[n].length-1;i++) {
		mlink="index.php?page=show&c1="+n+"&c2="+i;
		mname=submenu[n][i];
				
		//html=html+"<a class='menulink' href='"+mlink+"'>"+mname+" </a><br>";
		html=html+"<a class='menulink' href='"+mlink+"'><div class='subdiv'>"+mname+" </div></a>";
	}
	html=html+"<br>";
	
	
	document.getElementById("dropmenu").innerHTML=html;
	document.getElementById("dropmenu").style.visibility="visible";
	document.getElementById("dropmenu").style.left=getPos(el,"Left")+"px";
	document.getElementById("dropmenu").style.top=getPos(el,"Top")+30+"px";
}
function closeMenu() {
	document.getElementById("dropmenu").style.visibility="hidden";
}

//==============

function checkString(s,al) {
	allow=al.split(",");
	
	for(z=0;z<=(s.length-1);z++) {
		
		flag=false;
		for(i=0;i<=allow.length-1;i++) {
			if(s.charAt(z).toLowerCase()==allow[i]) {
				flag=true;
			}
		}
		if(!flag) {
			return false;
		}
	}
	return flag;
}

function toCart(code) {
	count=document.getElementById("tf_count").value;
	if(count<1 || !checkString(count.toString(),"1,2,3,4,5,6,7,8,9,0")) {
		alert("Укажите количество!");
	} else {
		ref="index.php?page=view&code="+code+"&act=buy&count="+count;
		location.href=ref;
	}
}

function toCartFast(code) {
	ref="index.php?page=view&code="+code+"&act=buy&count=1";
	location.href=ref;
}



