function choice1(obj){
	var priopcao = new Array("choose","All", "Textural", "Brushwork", "Geometric", "Palette Knife");
	var segopcao = new Array("choose","All", "Dolphin", "Fish", "Hibiscus", "Lily Flower", "Sun Flower", 
						   "Coast", "Boat", "Garden", "Lake", "Fruit", "Landscape", "Sugar Loaf", "Beach");
	var teropcao	= new Array("choose", "All");
	var todas = new Array("choose","All", "Dolphin", "Fish", "Hibiscus", "Lily Flower", "Sun Flower", 
						   "Coast", "Boat", "Garden", "Lake", "Fruit", "Landscape", "Sugar Loaf", "Beach",
						   "Textural", "Brushwork", "Geometric", "Palette Knife");
	
	var arr = null;

	if (obj.value == 'abstract') {
		arr = priopcao;
	} else if (obj.value == 'figurative') {
		arr = segopcao;
	} else if (obj.value == 'combination') {
		arr = teropcao;
	} else if (obj.value == 'All') {
		arr = todas;
	}
	var select = document.getElementById('selectLine');
	var color = document.getElementById('color');
	var size = document.getElementById('size');

	for (var i = select.options.length - 1; i >= 0; i--) {
		select.options[i] = null;
	}

	if (arr != null) {
		if(arr!=teropcao){
			select.disabled = false;
			select.style.background = '#FFFFFF';
			for (var i = 0; i < arr.length; i++) {
				select.options[i] = new Option(arr[i], arr[i]);
			}
		}else{
			size.disabled = false;
			size.style.background = '#FFFFFF';
		}
	} else {
		color.disabled = true;
		color.style.background = '#CCCCCC';
		size.disabled = true;
		size.style.background = '#CCCCCC';
		select.disabled = true;
		select.style.background = '#CCCCCC';
	}
}

function choice2(obj){
	var arr = document.getElementById('selectLine');
	var color = document.getElementById('color');
	var size = document.getElementById('size');

	if (arr != null) {
		if(document.getElementById('style').value!="combination"){
			color.disabled = false;
			color.style.background = '#FFFFFF';
		}else{
			size.disabled = false;
			size.style.background = '#FFFFFF';
		}
	}
}

function choice3(obj){
	var size = document.getElementById('size');
	var color = document.getElementById('color');
	if(size != null){
		if (color != null) {
			size.disabled = false;
			size.style.background = '#FFFFFF';
		}
	}
}

function search_paint(){
	var style=document.getElementById('style').value;
	var line=document.getElementById('selectLine').value;
	var color=document.getElementById('color').value;

	if(document.getElementById('size')!=null){
		var size=document.getElementById('size').value;
	}

	if(style!=0){
		location='result.php?style='+style.toUpperCase()+'&line='+line.toUpperCase()+'&color='+color.toUpperCase()+'&size='+size;
	}else{
		alert("Please select any option.");
	}
}

function print_01(){
window.print();
}

function register(){
window.location ='new_retalier.php';
}

function change_01(){
	window.location = '../to_order/credit_app.php';	
}

function reset_01(){
	window.location = 'new_retalier.php'	
}
//Função para ir para a página sales order
function buy_now(){
	window.open("sales_order.php","");
	window.close();
}
//Verificando esta sendo digitado somente números
function number_modifKey(e,cbox) {
	var xCode='';
	var i;
	var resp=0;
		isNetscape=(document.layers);
		eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
		which = String.fromCharCode(eventChooser);
		xCode=which.charCodeAt(0);
	for(i=96;i<106;i++){
		if(xCode==i){
			resp=1;
			break;
		}
	}
	for(i=48;i<58;i++){
		if(xCode==i){
			resp=1;
			break;
		}
	}
	if(xCode==9){resp=1;}
	if(resp==0){
		alert("Please only write numbers in this field.");
		cbox.value="";
		cbox.focus();
	}
}
//Contando quantos números foram digitados
function card_cont(valor) {
	var campo = valor.value;
	if(campo.length != 16){
		alert("Please insert a correct credit card number");
		valor.focus();
	}
}
//Validacao de email
function valid_mail(pat){
	if(pat.value!=""){
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(pat.value))) 
		{ 
			alert("Please write a valid mail.") 
			pat.focus(); 
			return false; 
		}
	}
}
//Função para a página new retalier
function valid_pass(pass1,pass2){
	if(pass1.value!=pass2.value){
		alert("Please re-type your password.");
		pass2.focus();
	}
}
//Função para abrir a janela com a pintura
function open_win(arq){
	window.open('amp_img.php?image='+arq,'','width=450,height=600,scrollbars=yes');
}
//Função para abrir a janela com a pintura no search
function open_win_search(arq){
	window.open('../online_gallery/amp_img.php?image='+arq,'','width=450,height=600,scrollbars=yes');
}
//Função para adicionar a pintura
function add_paint(um,dois,tres){
	var pintura = document.getElementById('cquantity'+dois).value;
	location=um+pintura+tres;
}
//Validação de data
function valid_data(pVal){
	if (!(/^\d{1,2}\/\d{1,2}\/\d{1,4}$/.test(pVal.value))) 
    { 
        alert("Please write a valid date.") 
        pVal.focus(); 
        return false; 
    }
}
//busca p nome
function searchcode(){
	var paint=document.getElementById('paint').value;
	location='result.php?paint='+paint;
}
function card_data(){
	var data = new Date();
	var ano = document.getElementById('ano');
	var mes = document.getElementById('mes');
	var mes_atual = data.getMonth() + 1;
	var i;

	for (i = 1; i <= 12; i++) {
		mes.options[i]=new Option("","");
		if(ano.value == data.getYear()){
			if(i >= mes_atual){
				mes.options[i] = new Option(i,i);
			}
		}else{
			mes.options[i] = new Option(i,i);
		}
	}

	mes.disabled = false;
	mes.style.background = '#cccccc';
}
function des_credit_app(){
	document.getElementById('last_company').disabled = true;
	document.getElementById('last_title').disabled = true;
	document.getElementById('signature').disabled = true;
	document.getElementById('l_comp_date').disabled = true;
}
function hab_credit_app(){
	document.getElementById('last_company').disabled = false;
	document.getElementById('last_title').disabled = false;
	document.getElementById('signature').disabled = false;
	document.getElementById('l_comp_date').disabled = false;
}
