
//**************************************//
//                                      //
//	 Programing by ryan@ryanmills.net   //
//                                      //
//**************************************//

first = 1;

function loadTemplate(arg1){
	popupTemplate = arg1;
}// End function loadTemplate()

function checkJava(){
	document.getElementById('java_error').removeChild(document.getElementById('java_error').firstChild);
}

function updateCart(id,amount){
	document.getElementById('cart_id').value = id;
	document.getElementById('cart_qty').value = amount;
	document.getElementById('action').value = 'cart_update_qty';
	document.getElementById('bot_form').submit();
}

function updateCartRemove(id){
	document.getElementById('cart_id').value = id;
	document.getElementById('cart_qty').value = 'x';
	document.getElementById('action').value = 'cart_update_qty';
	document.getElementById('bot_form').submit();
}

function addBotItem(type,item_sku,size,fabric,color){
	// old idea thanks to IE6 its shit
	skuString = size+'::'+fabric+'::'+color;
	if(type == 1){
		alert('Adding item Type: '+type+' Sku: '+item_sku+' Size: '+size+' Fabric: '+fabric+' Color: '+color);
		window.location = "?cart_add_item="+item_sku;
	}else if(type == 2){
		alert('Adding item Type: '+type+' Sku: '+item_sku+' Size: '+size+' Fabric: '+fabric+' Color: '+color);
		window.location = "?cart_add_item_type2="+item_sku+"&skuString="+skuString;
	}

}

function showPrice(item_id,fabric,color,item_sku){
		
	//alert('Item ID: '+item_id+' Fabric: '+fabric+' Color: '+color);
	xmlhttp=false;
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }// End try
	}// End try

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	
	//alert(xmlhttp);
	if(!xmlhttp){
		alert('Your browser does not support the required javascript. Please see the help section of this page for more info.');
	}else{
		
		function priceShowWait(){
			document.getElementById('price').innerHTML = 'Getting Price';
		}

		function getPrice() {

			if(xmlhttp.readyState==4){
				response  = xmlhttp.responseXML;
				//alert(xmlhttp.responseText);
				var price = response.getElementsByTagName("price")[0].childNodes[0].nodeValue;
				size = document.getElementById('sizeDropDown').value;
				skuString = size+'::'+fabric+'::'+color;
				addLink = "?cart_add_item_type2="+item_sku+"&skuString="+skuString;
				price = '<b>Total: $'+price+'</b><br><br><a class="java_button" href="'+addLink+'"><img src="images/pop_addtoshopingcart.gif" border="0"></a>';
				//alert(price);
				document.getElementById('price').innerHTML = price;
				
				
			}else{
				priceShowWait();	
			}
		}// End function onreadystatechange();
	
		xmlhttp.onreadystatechange = getPrice;
		xmlhttp.open("GET", "http://olivialuca.com/home/boutique/xml/price-xml.php?id="+item_id+"&fabric="+fabric+"&=color="+color,true);
		xmlhttp.send(null);
	}// End if
}

function selectColor(item_id,item_sku){
	if(document.getElementById('colorDropDown').value != 0){
		fabric = document.getElementById('fabricDropDown').value;
		color = document.getElementById('colorDropDown').value;
		showPrice(item_id,fabric,color,item_sku);
	 }
}

function getColor(id,sku,item_id,item_sku){
	xmlhttp=false;
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }// End try
	}// End try

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	
	//alert(xmlhttp);
	if(!xmlhttp){
		alert('Your browser does not support the required javascript. Please see the help section of this page for more info.');
	}else{
		
		function colorShowWait(){
			document.getElementById('colorFormHolder').innerHTML = 'Loading Color';
			document.getElementById('price').innerHTML = '';
		}

		function getColors() {

			if(xmlhttp.readyState==4){
				response  = xmlhttp.responseXML;
				//alert(xmlhttp.responseText);
				var item_opt3 = response.getElementsByTagName("opt3")[0].childNodes[0].nodeValue;
				
				var explode = new String();
				var explode = item_opt3;
				var loadMe = explode.split(',');
				var opt3_out = '<select id="colorDropDown" onchange="selectColor('+item_id+','+item_sku+')"><option value="0">-- Please Select A Color --</option>';
				var i=0;
				while(i < loadMe.length){
					var breakOut = loadMe[i].split('::');
					opt3_out = opt3_out+'<option value="'+breakOut[1]+'">'+breakOut[0]+'</option>';
					i++;
				}
				opt3_out = opt3_out+'</select>';
				//alert(opt3_out);
				document.getElementById('colorFormHolder').innerHTML = opt3_out;
				
				
			}else{
				colorShowWait();	
			}
		}// End function onreadystatechange();
	
		xmlhttp.onreadystatechange = getColors;
		xmlhttp.open("GET", "http://olivialuca.com/home/boutique/xml/color-xml.php?sku="+sku,true);
		xmlhttp.send(null);
	}// End if
}


function selectFabric(id,item_id,item_sku){
 if(document.getElementById('fabricDropDown').value != 0){
	sku = document.getElementById('fabricDropDown').value;
	//alert(sku);
	getColor(id,sku,item_id,item_sku); 
 }
}

function getFabric(id,item_id,item_sku){
	xmlhttp=false;
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }// End try
	}// End try

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	
	//alert(xmlhttp);
	if(!xmlhttp){
		alert('Your browser does not support the required javascript. Please see the help section of this page for more info.');
	}else{
		
		function fabricShowWait(){
			document.getElementById('fabricFormHolder').innerHTML = 'Loading Fabric';
			document.getElementById('colorFormHolder').innerHTML = '';
			document.getElementById('price').innerHTML = '';
		}

		function getFabrics() {

			if(xmlhttp.readyState==4){
				response  = xmlhttp.responseXML;
				//alert(xmlhttp.responseText);
				var item_opt2 = response.getElementsByTagName("opt2")[0].childNodes[0].nodeValue;
				
				var explode = new String();
				var explode = item_opt2;
				var loadMe = explode.split(',');
				var opt2_out = '<select id="fabricDropDown" onchange="selectFabric('+id+','+item_id+','+item_sku+')"><option value="0">-- Please Select A Fabric --</option>';
				var i=0;
				while(i < loadMe.length){
					var breakOut = loadMe[i].split('::');
					opt2_out = opt2_out+'<option value="'+breakOut[1]+'">'+breakOut[0]+'</option>';
					i++;
				}
				opt2_out = opt2_out+'</select>';
				//alert(opt2_out);
				document.getElementById('fabricFormHolder').innerHTML = opt2_out;
				
				
			}else{
				fabricShowWait();	
			}
		}// End function onreadystatechange();
	
		xmlhttp.onreadystatechange = getFabrics;
		xmlhttp.open("GET", "http://olivialuca.com/home/boutique/xml/fabric-xml.php?id="+id,true);
		xmlhttp.send(null);
	}// End if
}


function selectSize(id,item_id,item_sku){
 if(document.getElementById('sizeDropDown').value != 0){
	getFabric(id,item_id,item_sku); 
 }
}

function getSize(id,item_id,item_sku){
	xmlhttp=false;
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }// End try
	}// End try

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	
	//alert(xmlhttp);
	if(!xmlhttp){
		alert('Your browser does not support the required javascript. Please see the help section of this page for more info.');
	}else{
		
		function fabricShowWait(){
			document.getElementById('sizeFormHolder').innerHTML = 'Loading Sizes';
			document.getElementById('colorFormHolder').innerHTML = '';
			document.getElementById('price').innerHTML = '';
		}

		function getSizes() {

			if(xmlhttp.readyState==4){
				response  = xmlhttp.responseXML;
				
				var item_opt1 = response.getElementsByTagName("opt1")[0].childNodes[0].nodeValue;
				
				var explode = new String();
				var explode = item_opt1;
				var loadMe = explode.split(',');
				var opt1_out = '<select class="dropColors" id="sizeDropDown" onchange="selectSize('+id+','+item_id+','+item_sku+')"><option value="0">-- Please Select A Size --</option>';
				var i=0;
				while(i < loadMe.length){
					var breakOut = loadMe[i].split('::');
					opt1_out = opt1_out+'<option value="'+breakOut[1]+'">'+breakOut[0]+'</option>';
					i++;
				}
				opt1_out = opt1_out+'</select>';
				//output = holder.replace(/{opt1}/gi, opt1_out);
				//holder = output;
				document.getElementById('sizeFormHolder').innerHTML = opt1_out;
				
				
			}else{
				fabricShowWait();	
			}
		}// End function onreadystatechange();
	
		xmlhttp.onreadystatechange = getSizes;
		xmlhttp.open("GET", "http://olivialuca.com/home/boutique/xml/size-xml.php?id="+id,true);
		xmlhttp.send(null);
	}// End if
}



function displayItem(id,name,img,details,type,price,item_sku){
	
	if(first == 1){
		template = document.getElementById('viewer').innerHTML;
		first = 0;
	}// End if
	
	holder = new String(template);
	output = holder.replace(/{name}/gi, name);
	holder = output;
	output = holder.replace(/{details}/gi, details);
	holder = output;
	output = holder.replace(/{image}/gi, '<img src="../image_database/'+img+'"/>');
	holder = output;

	
	document.getElementById('viewer').innerHTML = output;
	addLink = '?cart_add_item='+item_sku;
	setPrice = '<b>Total: $'+price+'</b><br><br><a class="java_button" href="'+addLink+'"><img src="images/pop_addtoshopingcart.gif" border="0"></a>';
			
	document.getElementById('price').innerHTML = setPrice;
	document.getElementById('viewer').style.visibility = 'visible';
}// End function displayItem()




function getItemData(arg1,arg2){
	
	var xmlhttp=false;
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }// End try
	}// End try

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}// End try
	}// End if
	
	//alert(xmlhttp);
	if(!xmlhttp){
		alert('Your browser does not support the required javascript. Please see the help section of this page for more info.');
	}else{
		
		function showWait(){
			if(first == 1){
				template = document.getElementById('viewer').innerHTML;
				first = 0;
			}// End if
			
			holder = new String(template);
			output = holder.replace(/{name}/gi, 'Loading...');
			holder = output;
			output = holder.replace(/{details}/gi, '');
			holder = output;
			output = holder.replace(/{image}/gi, '');
			holder = output;
			
			document.getElementById('viewer').innerHTML = output;
			document.getElementById('viewer').style.visibility = 'visible';
		}

		function botXMLtoHTML() {

			if(xmlhttp.readyState==4){
				//alert(xmlhttp.responseText);
				response  = xmlhttp.responseXML;
				var item_id = response.getElementsByTagName("id")[0].childNodes[0].nodeValue;
				var item_name = response.getElementsByTagName("name")[0].childNodes[0].nodeValue;
				var item_img = response.getElementsByTagName("image")[0].childNodes[0].nodeValue;
				var item_details = response.getElementsByTagName("details")[0].childNodes[0].nodeValue;
				var item_type = response.getElementsByTagName("type")[0].childNodes[0].nodeValue;
				var item_sku = response.getElementsByTagName("sku")[0].childNodes[0].nodeValue;
			
				if(item_type == 1){
					var item_price = xmlhttp.responseXML.getElementsByTagName("price")[0].childNodes[0].nodeValue;
					displayItem(item_id,item_name,item_img,item_details,item_type,item_price,item_sku);
				}else{
					displayItem(item_id,item_name,item_img,item_details,item_type,item_sku);
					getSize(item_id,item_id,item_sku);
				}
				
			}else{
				showWait();	
			}
		}// End function onreadystatechange();
	
		xmlhttp.onreadystatechange = botXMLtoHTML;
		xmlhttp.open("GET", "http://olivialuca.com/home/boutique/xml/bot-xml.php?id="+arg1+"&type="+arg2,true);
		xmlhttp.send(null);
	}// End if
}// End function getItemData()



function hideBox(){
	document.getElementById('viewer').style.visibility = 'hidden';
}

function hideCart(){
	document.getElementById('cart').style.visibility = 'hidden';
}

function showCart(){
	hideBox();
	document.getElementById('cart').style.visibility = 'visible';
}




function showPhoto(arg){
	arg = displayImage;
	current = arg;
	
	if(setImage.width < setImage.height && setImage.width != 0){
		//alert('T 1');
		imageType = 3;
	}else if(setImage.width > setImage.height && setImage.width != 0){
		//alert('T 2');
		imageType = 2;
	}else if(setImage.width == 0){
		//alert('no width set');
	}
	
	if(arg == 1){
		moveLeft = total;
	}else{
		moveLeft = arg - 1;
	}// End if
	
	if(arg == total){
		moveRight = 1;
	}else{
		moveRight = arg+1;
	}// End if
	creatImage = setImage.src;
	
	
	if(current == 34){ // edit here to set last image image as link
		imageType = 4;
	}
		
		
		
	
	
	var type34 = '<table width="848" cellpadding="0" cellspacing="0" align="center" border="0"><tr><td colspan="3"><img src="images/l-top-spacer.png" height="75" width="848"></td></tr><tr><td><a href="javascript:void(1)" onClick="setPhoto('+moveLeft+')" class="button"><img class="button" border=0 src="images/l-l-button.png" height="316" width="193"></a></td><td><a href="http://olivialuca.blogspot.com"><img border="0" src=\"'+creatImage+'" height="316" width="466"></a></td><td><a href="javascript:void(1)" onClick="setPhoto('+moveRight+')" class="button"><img border=0 src="images/l-r-button.png" height="316" width="193"></a></td></tr><tr><td colspan="3"><img src="images/l-bottom-spacer.png" height="75" width="848"></td></tr></tr></table>';
	
	var typePort= '<table width="848" cellpadding="0" cellspacing="0" align="center" border="0"><tr><td><a href="javascript:void(1)" onClick="setPhoto('+moveLeft+')" class="button"><img src="images/p-l-button.png" border=0 width="268" height="466"></a></td><td><img src=\"'+creatImage+'" width="316" height="466"></td><td><a href="javascript:void(1)" onClick="setPhoto('+moveRight+')" class="button"><img border=0 src="images/p-r-button.png" width="268" height="466"></a></td></tr></table>';
	
	
	var typeLand = '<table width="848" cellpadding="0" cellspacing="0" align="center" border="0"><tr><td colspan="3"><img src="images/l-top-spacer.png" height="75" width="848"></td></tr><tr><td><a href="javascript:void(1)" onClick="setPhoto('+moveLeft+')" class="button"><img class="button" border=0 src="images/l-l-button.png" height="316" width="193"></a></td><td><img src=\"'+creatImage+'" height="316" width="466"></td><td><a href="javascript:void(1)" onClick="setPhoto('+moveRight+')" class="button"><img border=0 src="images/l-r-button.png" height="316" width="193"></a></td></tr><tr><td colspan="3"><img src="images/l-bottom-spacer.png" height="75" width="848"></td></tr></tr></table>';
	

	if(imageType === 2){
		document.getElementById('gallery').innerHTML = typeLand;
	}else if(imageType === 3){
		document.getElementById('gallery').innerHTML = typePort;
	}else if(imageType === 4){
		document.getElementById('gallery').innerHTML = type34;
	}
	
	document.getElementById('loader').innerHTML = '';

}

function setPhoto(arg){
	var creatImage = siteroot + arg+'.jpg?'+suffix;
	
	document.getElementById('loader').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="112" height="15"><param name="movie" value="gallery-loader.swf"><param name="quality" value="high"><embed src="gallery-loader.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="112" height="15"></embed></object>';
	displayImage = arg;
	need = 1;
	i=0; 
	
	while(i < loaded.length){
		if(loaded[i] == arg){
			need = 0;
		}
		i++;
	}
	if(need){
		setCount++;
		loaded[setCount] = arg;
		setImage = new Image();
		setImage.src = creatImage;
		setImage.onload = showPhoto;
	}else{
		setImage.src = creatImage;
		showPhoto(arg);
	}
		
}// End function setPhoto()






function autoMask(field, event, sMask) {
        //var sMask = "**?##?####";

        var KeyTyped = String.fromCharCode(getKeyCode(event));
        var targ = getTarget(event);
        keyCount = targ.value.length;

	if(keyCount == sMask.length)
	{
		return false;
	}
      if ((sMask.charAt(keyCount+1) != '#') && (sMask.charAt(keyCount+1) != 'A' ) )
      {
         field.value = field.value + KeyTyped + sMask.charAt(keyCount+1);
         return false;
      }

        if (sMask.charAt(keyCount) == '*')
                return true;

        if (sMask.charAt(keyCount) == KeyTyped)
        {
                return true;
        }

        if ((sMask.charAt(keyCount) == '#') && isNumeric(KeyTyped))
           return true;

        if ((sMask.charAt(keyCount) == 'A') && isAlpha(KeyTyped))
         return true;

      if ((sMask.charAt(keyCount+1) == '?') )
      {
         field.value = field.value + KeyTyped + sMask.charAt(keyCount+1);
         return true;
      }
      if (KeyTyped.charCodeAt(0) < 32) return true;
    return false;
}
 function getTarget(e) {
  // IE5
   if (e.srcElement) {
        return e.srcElement;
   }
    if (e.target) {
        return e.target;
   }
 }

  function getKeyCode(e) {
 //IE5
 if (e.srcElement) {
        return e.keyCode
 }
  // NC5
  if (e.target) {
   return e.which
  }
 }

 function isNumeric(c)
{
        var sNumbers = "01234567890";
        if (sNumbers.indexOf(c) == -1)
                return false;
        else return true;

}

function isAlpha(c)
{
        var lCode = c.charCodeAt(0);
        if (lCode >= 65 && lCode <= 122 )
          {
                return true;
         }
        else
        return false;
}

function isPunct(c)
{
        var lCode = c.charCodeAt(0);
        if (lCode >= 32 && lCode <= 47 )
          {
                return true;
         }
        else
        return false;

}

function checkout(){
	if(document.getElementById('setTotal').value != '$0.00'){
		if(document.getElementById('state').value != '0' && document.getElementById('state').options[document.getElementById('state').selectedIndex].text != ''){
			window.location = 'create_order.php';
		}else{
			alert('Please Select Your State');
		}	
	}else{
		alert('No Items In Shopping Bag');
	}
}


function copy_shipinfo(){
	document.getElementById('bfullname').value = document.getElementById('fullname').value;
	document.getElementById('baddress1').value = document.getElementById('address1').value;
	document.getElementById('baddress2').value = document.getElementById('address2').value;
	document.getElementById('bcity').value = document.getElementById('city').value;
	document.getElementById('bzip').value = document.getElementById('zip').value;
	document.getElementById('bdayphone').value = document.getElementById('dayphone').value;
	document.getElementById('bstate').options[document.getElementById('state').selectedIndex].selected = true;

}


function createOrder(){
	
	if(!document.getElementById('read').checked){
		alert('You must read and agree to the terms and condtions.');
		return false;
	}
	
	if(document.getElementById('fullname').value == ''){
		alert('You forgot to add your "Shipping Name"');
		return false;
	}
	
	if(document.getElementById('address1').value == ''){
		alert('You forgot to add your "Shipping Address"');
		return false;
	}
	
	if(document.getElementById('city').value == ''){
		alert('You forgot to add your "Shipping City"');
		return false;
	}
	
	if(document.getElementById('state').value == '0'){
		alert('You forgot to add your "Shipping State"');
		return false;
	}
	
	if(document.getElementById('zip').value == ''){
		alert('You forgot to add your "Shipping Zip Code"');
		return false;
	}
	

	if(document.getElementById('dayphone').value == ''){
		alert('You forgot to add your "Shipping Daytime Phone"');
		return false;
	}
	
	if(document.getElementById('dayphone').value.length > 13){
		alert('Incorrect format for "Shipping Daytime Phone"');
		return false;
	}
	
	if(document.getElementById('evephone').value == ''){
		alert('You forgot to add your "Shipping Evening Phone"');
		return false;
	}
	
	if(document.getElementById('evephone').value.length > 13){
		alert('Incorrect format for "Shipping Evening Phone"');
		return false;
	}
	
	if(document.getElementById('email').value == ''){
		alert('You forgot to add your "Email Address"');
		return false;
	}
	
	if(document.getElementById('bfullname').value == ''){
		alert('You forgot to add your "Billing Name"');
		return false;
	}
	
	if(document.getElementById('baddress1').value == ''){
		alert('You forgot to add your "Billing Address"');
		return false;
	}
	
	if(document.getElementById('bcity').value == ''){
		alert('You forgot to add your "Billing City"');
		return false;
	}
	
	if(document.getElementById('bstate').value == '0'){
		alert('You forgot to add your "Billing State"');
		return false;
	}
	
	if(document.getElementById('bzip').value == ''){
		alert('You forgot to add your "Billing Zip Code"');
		return false;
	}
	
	if(document.getElementById('bdayphone').value == ''){
		alert('You forgot to add your "Billing Daytime Phone"');
		return false;
	}
	
	if(document.getElementById('eventdate').value == ''){
		alert('You forgot to add your "Event Date"');
		return false;
	}
	
	if(document.getElementById('bdayphone').value.length > 13){
		alert('Incorrect format for "Billing Daytime Phone"');
		return false;
	}
	
	if(document.getElementById('multi_ordery').checked == true && document.getElementById('event').value == ''){
		alert('You forgot to add your "Multi-person Name/Event"');
		return false;
	}
	
	document.getElementById('showbState').value = document.getElementById('bstate').options[document.getElementById('bstate').selectedIndex].text;
	document.getElementById('showState').value = document.getElementById('state').options[document.getElementById('state').selectedIndex].text;

	document.getElementById('mainForm').submit();

}



function setState(){
	document.getElementById('bstate').options[document.getElementById('state').selectedIndex].selected = true;
}