/* javascript function to update form field
 *  field		form field that is being counted
 *  count		form field that will show characters left
 *  maxchars 	maximum number of characters
*/
function characterCount(field, count, maxchars) {
  var realchars = field.value.replace(/\t|\r|\n|\r\n/g,'');
  var excesschars = realchars.length - maxchars;
  if (excesschars > 0) {
		field.value = field.value.substring(0, maxchars);
		alert("Error:\n\n- You are only allowed to enter up to"+maxchars+" characters.");
	} else {
		count.value = maxchars - realchars.length;
	}
}


function show_p(p_id){
	if(p_info[p_id] && image_array[p_id]){
		document.getElementById('show_p_image').innerHTML='<img src="' + image_array[p_id].m + '" />';
		document.getElementById('p_name').innerHTML=p_info[p_id].products_name;
		document.getElementById('p_op').innerHTML=p_info[p_id].op;
		document.getElementById('p_price').innerHTML='Price:'+p_info[p_id].products_price;
		document.getElementById('p_bott').innerHTML='<input type="hidden" value="' + p_id + '" name="products_id">';
		document.getElementById("to_cart").src="includes/templates/classic/buttons/english/button_in_cart.gif";
		}else{
			document.getElementById('show_p_image').innerHTML='<img src="' + image_array[main_p].m + '" />';
			document.getElementById('p_name').innerHTML=(''!=p_info[main_p].main_title ? p_info[main_p].main_title:p_info[main_p].products_name);
			document.getElementById('p_op').innerHTML='';
			document.getElementById('p_price').innerHTML='';
			document.getElementById('p_bott').innerHTML='';
			document.getElementById("to_cart").src="includes/templates/classic/buttons/english/button_in_flas.gif";
			}
	}
function smb(){
	if(document.getElementById('p_bott').innerHTML==''){
		alert('Please select... ...');
		return false;
		}else{
			return true;
			}
	 
	}
	






function get_next_op(get_url,get_op_id){
	   var get_url_value='';
	   var next_op='';
	   document.getElementById('p_name').innerHTML=(''!=p_info[main_p].main_title ? p_info[main_p].main_title:p_info[main_p].products_name);
	   document.getElementById('p_bott').innerHTML='';
	   document.getElementById("to_cart").src="includes/templates/classic/buttons/english/button_in_flas.gif";
	   for(var i=get_op_id+1; i<s_op.length;i++){
		   if(document.getElementById('op_'+s_op[i])){document.getElementById('div_'+s_op[i]).innerHTML='';}
		   }
		for(var i=0; i<s_op.length;i++){
			if(document.getElementById('op_'+s_op[i])){
				get_url_value +=(''!=get_url_value ? '|':'')+s_op_num[i]+'_'+document.getElementById('op_'+s_op[i]).value;
				}else{					
					get_url_value +='/next/'+s_op_num[i];
					next_op=s_op[i];
					break;
					}
			}
			if(''!=get_url_value){
				//alert(next_op);
				document.getElementById('div_'+next_op).innerHTML='<img src="images/041.gif" />';
				op_get_ajax(get_url + '/ajax/1/op_value/'+get_url_value,next_op);				
				}
	}


function get_images(color_value,op_value){

	if('2'==color_value){
		if(0!=op_value){
			document.getElementById('show_p_image').innerHTML='<img src="' + image_array[color_to_img["ov_"+op_value]].m + '" />';
			}else{
				document.getElementById('show_p_image').innerHTML='<img src="' + image_array[main_p].m + '" />';
				}
		
		}
			
			
	}

function op_get_ajax(get_url,show_id){
	var oajax = new ajax();
	oajax.method='GET';
	oajax.url =get_url;
	oajax.callback = function(o){	
		//out_value=o.responseText;	
		document.getElementById('div_'+show_id).innerHTML=o.responseText;
	}
	
	oajax.send();
	}




function ajax(){
	var ajaxobj = false;
	var cloneobj = this;
	
	try{ajaxobj = new ActiveXObject("MSXML2.XMLHTTP");} catch(e){}
	try{ajaxobj = new ActiveXObject("Microsoft.XMLHTTP");} catch(e){}
	try{ajaxobj = new XMLHttpRequest();} catch(e){}
	
	if(!ajaxobj) return false;
	this.url;
	this.method = "POST";
	this.async = true;
	this.content;
	this.callback = function(o){return;}
	this.send = function(){
		if(!this.method || !this.url || !this.async) return false;
		ajaxobj.open(this.method,this.url,this.async);
		if(this.method == "POST") ajaxobj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		
		ajaxobj.onreadystatechange = function(){
			if(ajaxobj.readyState == 4){
				if(ajaxobj.status == 200){
					cloneobj.callback(ajaxobj);
					}
				}
			}
		if(this.method == "POST"){
			ajaxobj.send(this.content);
			}else{
			ajaxobj.send(null);
			}
		}
	}


	


