var ajax = new Array();

function getStateList(first,second,selstate)
{
    var sel = document.getElementById(first);
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById(second).options.length = 0;	// Empty State select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = '/process/getStates.php?countryCode='+countryCode+'&menu='+second+'&selstate='+selstate;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createStates(index,second) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createStates(index,second)
{
	var obj = document.getElementById(second);
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}


function getSubCategoryList(sel)
{
	var category = sel.options[sel.selectedIndex].value;
	document.getElementById('dhtmlgoodies_subcategory').options.length = 0;	// Empty State select box
	if(category.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'getSubCategories.php?category='+category;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createSubCategories(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function createSubCategories(index)
{
	var obj = document.getElementById('dhtmlgoodies_subcategory');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

function shipctry()
{

if (document.getElementById('country').value == "other") {
document.getElementById('statewrap').style.display = "none";
document.getElementById('stateotherwrap').style.display = "block";
document.getElementById('countryotherwrap').style.display = "block";
}
else {
document.getElementById('statewrap').style.display = "block";
document.getElementById('stateotherwrap').style.display = "none";
document.getElementById('countryotherwrap').style.display = "none";
}

}





function shipctryPD()
{

if (document.getElementById('billcountry').value == "other") {
document.getElementById('billstatewrap').style.display = "none";
document.getElementById('billstateotherwrap').style.display = "block";
document.getElementById('billcountryotherwrap').style.display = "block";
}
else {
document.getElementById('billstatewrap').style.display = "block";
document.getElementById('billstateotherwrap').style.display = "none";
document.getElementById('billcountryotherwrap').style.display = "none";

}


if (document.getElementById('shipcountry').value == "other") {
document.getElementById('shipstatewrap').style.display = "none";
document.getElementById('shipstateotherwrap').style.display = "block";
document.getElementById('shipcountryotherwrap').style.display = "block";
}
else {
document.getElementById('shipstatewrap').style.display = "block";
document.getElementById('shipstateotherwrap').style.display = "none";
document.getElementById('shipcountryotherwrap').style.display = "none";
}


}

function showhide(d) {
if (document.getElementById('shipto').value == "b") {
document.getElementById(d).style.display = "none";
document.getElementById('hideshipto').style.display = "";
document.getElementById('showshipto').style.display = "none";
}
else {
document.getElementById(d).style.display = "";
document.getElementById('hideshipto').style.display = "none";
document.getElementById('showshipto').style.display = "";
}
}
