function popup(url,scroll)
{
	if (scroll == 'yes') newwindow = window.open(url,'name','height=720,width=600,scrollbars');
	else if (scroll == 'no') newwindow = window.open(url,'name','height=720,width=600');
	else newwindow = window.open(url,'name','height=300,width=300');
	if (window.focus) newwindow.focus();
	return false;
}

function validate() {
	var inp = document.getElementsByTagName('input');
	var flag = 0;
	var msg = "";
	for (var i=0; i<inp.length; i++) {
		var ii = inp[i].getAttribute('id');
		if (ii == 'required' && inp[i].value == '') {
			var titlos = inp[i].getAttribute('title');
			msg = msg + titlos + "<br>";
			flag++;
		}
	}
	var inp = document.getElementsByTagName('select');
	for (var i=0; i<inp.length; i++) {
		var ii = inp[i].getAttribute('id');
		if (ii == 'required' && inp[i].value == '0') {
			var titlos = inp[i].getAttribute('title');
			msg = msg + titlos + "<br>";
			flag++;
		}
	}
	if (flag > 0) {
		Ext.MessageBox.alert('Warning', 'Please, fill the required fields:<br><font color="red">' + msg + '</font>', void(0));
		return false;
	}
	else return true;
}

function chk_email(obj) {
	apos = obj.value.indexOf("@");
	dotpos = obj.value.lastIndexOf(".");
	if (apos < 1 || dotpos - apos < 2) {
		Ext.MessageBox.alert('Warning', 'Please, fill a valid e-mail address.', void(0));
		obj.value = '';
		return false;
	}
	else return true;
}

function chk_member_card(obj) {
	if (!isNaN(obj.value)) return true;
	else {
		Ext.MessageBox.alert('Warning', 'Please, fill a valid member card number.', void(0));
		obj.value = '';
		return false;
	}
}

function to_upper_case(obj) {
	if (obj.value.length == 1) obj.value = obj.value.toUpperCase();
}

function chk_box() {
	var obj = document.getElementById('9');
	if (obj.checked == true) return(true);
	else {
		Ext.MessageBox.alert('Warning', 'Please, tick the last checkbox.', void(0));
		return(false);
	}
}

function chg_foto() {
	var obj = document.getElementById('foto');
	if (obj.innerHTML == '1') obj.innerHTML = '2';
	else if (obj.innerHTML == '2') obj.innerHTML = '1';
}

function get_city()
{
	var xmlhttp=false;
	if (window.ActiveXObject) // Browser IE
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	if (window.XMLHttpRequest) // Browser Firefox
		xmlhttp = new XMLHttpRequest();
	var id = document.getElementById('country').value;
	xmlhttp.open('GET', 'm_ajax.php?action=city&id=' + id, true);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 1) // Loading
			document.getElementById('city_txt').innerHTML = '<div style="width: 16px; height: 16px; padding-left: 100px;"><img src="main_images/m_s_loader.gif"></div>';
		else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) // Loaded
		{
			var content = xmlhttp.responseText;
			document.getElementById('city_txt').innerHTML = content;
		}
	}
	xmlhttp.send(null)
	return;
}

function get_category()
{
	var xmlhttp=false;
	if (window.ActiveXObject) // Browser IE
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	if (window.XMLHttpRequest) // Browser Firefox
		xmlhttp = new XMLHttpRequest();
	//var id = document.getElementById('country').value;
	xmlhttp.open('GET', 'm_ajax.php?action=category', true);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 1) // Loading
			document.getElementById('category_txt').innerHTML = '<div style="width: 16px; height: 16px; padding-left: 100px;"><img src="main_images/m_s_loader.gif"></div>';
		else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) // Loaded
		{
			var content = xmlhttp.responseText;
			document.getElementById('category_txt').innerHTML = content;
		}
	}
	xmlhttp.send(null)
	return;
}

function get_shop()
{
	var xmlhttp=false;
	if (window.ActiveXObject) // Browser IE
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) // Browser Firefox
		xmlhttp = new XMLHttpRequest();
	var id = document.getElementById('city').value;
	var id_categories = document.getElementById('category').value;
	xmlhttp.open('GET', 'm_ajax.php?action=shop&id=' + id + '&id_categories=' + id_categories, true);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 1) // Loading
			document.getElementById('shop_txt').innerHTML = '<div style="width: 16px; height: 16px; padding-left: 100px;"><img src="main_images/m_s_loader.gif"></div>';
		else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) // Loaded
		{
			var content = xmlhttp.responseText;
			document.getElementById('shop_txt').innerHTML = content;
		}
	}
	xmlhttp.send(null);
	return;
}

function show_shop(id)
{
	var xmlhttp=false;
	if (window.ActiveXObject) // Browser IE
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) // Browser Firefox
		xmlhttp = new XMLHttpRequest();
	//var id = document.getElementById('shop').value;
	xmlhttp.open('GET', 'm_ajax.php?action=show_shop&id=' + id, true);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 1) // Loading
			document.getElementById('show_shop').innerHTML = '<div style="width: 563px; height: 197px; text-align: center;"><img src="main_images/m_loader.gif" vspace="80"></div>';
		else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) // Loaded
		{
			var content = xmlhttp.responseText;
			document.getElementById('show_shop').innerHTML = content;
		}
	}
	xmlhttp.send(null);
	return;
}

function add_vote(id)
{
	var xmlhttp=false;
	if (window.ActiveXObject) // Browser IE
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) // Browser Firefox
		xmlhttp = new XMLHttpRequest();
	xmlhttp.open('GET', 'm_ajax.php?action=add_vote&id=' + id, true);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 1) // Loading
			document.getElementById('show_shop').innerHTML = '<div style="width: 563px; height: 197px; text-align: center;"><img src="main_images/m_loader.gif" vspace="80"></div>';
		else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) // Loaded
		{
			var content = xmlhttp.responseText;
			document.getElementById('show_shop').innerHTML = content;
		}
	}
	xmlhttp.send(null);
	return;
}

function show_flash(vote, max_vote)
{
	document.getElementById('show_shop').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="565" height="200" id="myflash" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="myflash.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#f2f9ff" /><param name="FlashVars" value="voteLimit=' + max_vote + '&' + vote + '=true" /><embed FlashVars="voteLimit=' + max_vote + '&' + vote + '=true" src="myflash.swf" quality="high" bgcolor="#f2f9ff" width="565" height="200" name="myflash" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	document.getElementById('shop_txt').innerHTML = '';
	document.getElementById('city_txt').innerHTML = '';
	document.getElementById('category_txt').innerHTML = '';
	document.getElementById('country').value = 0;
}
