var Pyra={
	initProduct:function(){
		var okToGo=false;
		var opsLen=$('.productOptions').length;
		$('.productOptions select').change(function(){
			var sel=$(this).attr('name').substr(-2,1);
			for(var i=0;i<opsLen;i++){
				if(sel==i||sel>i){
					continue;
				}else{
					$("select[name='productOption["+i+"]']").get(0).selectedIndex=0;
				}
			}
			if(sel==opsLen-1){
				var fm=$(this).get(0).form;
				var ops={id:$('#product_id').val()};
				for(var i=0;i<opsLen;i++){
					ops['po['+i+']']=fm.elements["productOption["+i+"]"].value;
				}
				$.get('xml/getProductOption.php',ops,
					function(data){
						data.documentElement.firstChild.nodeValue;
						okToGo=true;
					}
				);
			}
		});
		$('#pForm').submit(function(){
			if(okToGo){
				return true;
			}else{
				alert('Please choose all options');
				return false;
			}
		});
	}
};