function search_change(value)
{
document.location.href='?c='+value;
}


//////////////// check id  
  function check_id()
  {
  var user_id='';
  var user_id2=document.form1.user_id.value;
  
  for(var i=0;i<document.form1.user_id.value.length;i++)
  { 
   user_id2=user_id2.replace(" ",""); 
  }
  for(var i=0;i<user_id2.length;i++)
  { 
    if(user_id2.charCodeAt(i)<10000)
    user_id=user_id+user_id2.charAt(i);
  }
   document.form1.user_id.value=""+user_id+"";
  // alert("testing: "+user_id);
   document.getElementById("uid").src="user_verification.php?uid="+user_id+"";
  }
  
  function reset_id()
  {
   document.form1.user_id.value="";
   document.form1.user_id.focus();
  } 
  
  function set_id(value)
  {
   document.form1.user_id.value=""+value+"";
  } 
//////////////// check id   


//////////////// check phone  
  function check_phone()
  {
  var contact_tel='';
  var contact_tel2=document.form1.contact_tel.value;
  for(var i=0;i<document.form1.contact_tel.value.length;i++)
  {
   contact_tel2=contact_tel2.replace(" ","");
  }
  for(var i=0;i<contact_tel2.length;i++)
  { 
    if(contact_tel2.charCodeAt(i)<10000)
    contact_tel=contact_tel+contact_tel2.charAt(i);
  }
   document.form1.contact_tel.value=""+contact_tel+"";
   document.getElementById("tel").src="phone_verification.php?tel="+contact_tel+"";
  }

  function phone_reset_id()
  {
   document.form1.contact_tel.value="";
   document.form1.contact_tel.focus();
  } 
//////////////// check phone   

  
  function change_code(value)
  {
   document.form1.verify_code1.value=""+value+"";
   //alert(document.form1.verify_code1.value);
  } 
  
  function change_code2(value)
  {
   document.form1.verify_code2.value=""+value+"";
   //alert(document.form1.verify_code2.value);
  } 
  
  function change_dir(value)
  {
   document.form0.cat_dir.value=""+value+"";
  } 
  





  function checka(){
	if (document.form1.ass_name.value == ""){
			alert("Please fill your Organization Name!");
			document.form1.ass_name.focus();
			return false;
	}

	if (document.form1.contact_name.value == ""){
			alert("Please fill your First Name!");
			document.form1.contact_name.focus();
			return false;
	}
	
	if (document.form1.contact_name1.value == ""){
			alert("Please fill your Last Name!");
			document.form1.contact_name1.focus();
			return false;
	}
	
	if (document.form1.contact_position.value == ""){
			alert("Please fill your Position!");
			document.form1.contact_position.focus();
			return false;
	}
	
	if (document.form1.contact_email.value == ""){
		alert("Please fill in the E-mail Address");
		document.form1.contact_email.focus();
		return false;
    }else {
		var emailStr=document.form1.contact_email.value;
		//alert(emailStr);
		var emailPat=/[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; 
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
 			alert("E-mail Address must include ( @ and . )");
		    document.form1.contact_email.focus();
 			return false;
		}
	}
	
	
	var str=document.form1.contact_tel.value;
	str1=str.replace(' ',"");
	str2=str1.replace('-',"");
	str3=str2.replace('+',"");
	str4=str3.replace('.',"");
	str5=str4.replace(' ',"");
	str6=str5.replace('(',"");
	str7=str6.replace(')',"");
	if (str7 == "" || isNaN(str7)==true){
		alert("Please fill your valid Telephone Number!");
		document.form1.contact_tel.focus();
		return false;
    }
	
	
	if (document.form1.ci_form.value == ""){
			//alert("Please upload your CI Form!");
			//document.form1.ci_form.focus();
			//return false;
	}
	
	
	
		if (document.form1.verify_code1.value != document.form1.verify_code2.value) {
 			alert("The Verification Code is invalid!");
 			return false;
		}
	

}



  function checke(){
	if (document.form1.sat.value == ""){
			alert("Please fill your title!");
			document.form1.sat.focus();
			return false;
	}

	if (document.form1.name1.value == ""){
			alert("Please fill your First Name!");
			document.form1.name1.focus();
			return false;
	}
	
	if (document.form1.name2.value == ""){
			alert("Please fill your Last Name!");
			document.form1.name2.focus();
			return false;
	}
	
	var str=document.form1.tel.value;
	str1=str.replace(' ',"");
	str2=str1.replace('-',"");
	str3=str2.replace('+',"");
	str4=str3.replace('.',"");
	str5=str4.replace(' ',"");
	str6=str5.replace('(',"");
	str7=str6.replace(')',"");
	if (str7 == "" || isNaN(str7)==true){
		alert("Please fill your valid Telephone Number!");
		document.form1.tel.focus();
		return false;
    }
	
		var str=document.form1.tel2.value;
	str1=str.replace(' ',"");
	str2=str1.replace('-',"");
	str3=str2.replace('+',"");
	str4=str3.replace('.',"");
	str5=str4.replace(' ',"");
	str6=str5.replace('(',"");
	str7=str6.replace(')',"");
	if (str7 == "" || isNaN(str7)==true){
		alert("Please fill your valid Mobile Phone Number!");
		document.form1.tel2.focus();
		return false;
    }
	
	
	if (document.form1.email.value == ""){
		alert("Please fill in the E-mail Address");
		document.form1.email.focus();
		return false;
    }else {
		var emailStr=document.form1.email.value;
		//alert(emailStr);
		var emailPat=/[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; 
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
 			alert("E-mail Address must include ( @ and . )");
		    document.form1.email.focus();
 			return false;
		}
	}
	
	if (document.form1.amount_opt_value.value <1){
			alert("Please select the Event Cost!");
			return false;
	}
	
var test_status=true;	
for (i=1; i<=1; i++) {
	if (document.getElementById('money_type'+i).checked==true){
		test_status=false;
    }
}
	
if(test_status)
{
alert("Please select the Payment Method !");
return false;
}
else
{
return true;
}
	
}





function checkd1(){
//  && document.getElementById("donate_type2").checked==false
	if (document.getElementById("donate_type1").checked==false){
		alert("Please select the donation option!");
		return false;
    }

}

function checkd2(value){
var test_status=true;

if(document.getElementById("ass_select").value=="")
test_status=true;
else
test_status=false;

if(test_status)
{
alert("Please select the beneficiary organization !");
return false;
}
else
{
return true;
}
}


function checkd3a(){
if (document.getElementById('item_des1').checked==true){
	if (document.getElementById('item_element11').value == ""){
			alert("Please fill the Item Name!");
			return false;
	}

	if (document.getElementById('item_element12').value == ""){
			alert("Please fill the estimated price!");
			return false;
	}
	
	if (document.getElementById('item_element13').value == ""){
			alert("Please fill the Description!");
			return false;
	}
}	

if (document.getElementById('item_des2').checked==true){
	if (document.getElementById('item_element21').value == ""){
			alert("Please fill the Message!");
			return false;
	}
}
	
}

function checkd3b(){
var test_status=true;
	if (document.getElementById('money_value').value <1 && isNaN(document.getElementById('money_value'))==true){
		    alert("Please fill the Donation Amount which is equal to or larger than HK$ 100!");
			return false;
	}

for (i=1; i<=1; i++) {
	if (document.getElementById('money_type'+i).checked==true){
		test_status=false;
    }
}

if(test_status)
{
alert("Please select the Payment Method !");
return false;
}
else
{
return true;
}
}


function checkdt(){

if (document.getElementById('dt_message').value == ""){
			alert("Please fill the Donation Time Details!");
			return false;
}


var test_status=true;

if(document.getElementById("ass_select").value=="")
test_status=true;
else
test_status=false;

if(test_status)
{
alert("Please select the beneficiary organization !");
return false;
}
else
{
return true;
}
}

























////////////ambiente ///////////////////////////////////////////////////////////////////////////////////////////
function GetXmlHttpObject()
{
var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
return ajaxRequest;
}



function photochange(value, value2, value3)
{
//alert(value);
if(value>0)
{
ajaxRequest=GetXmlHttpObject();
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('photo_album'+value2);
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	//var materials = document.getElementById('cat').value;
	var queryString = "?status=q&op="+value+"&id="+value2;
	ajaxRequest.open("GET", "photo_player2.php" + queryString, true);
	ajaxRequest.send(null); 
}
else
{
document.getElementById('photo_album'+value2).innerHTML = '';
}

if(value>0)
{
ajaxRequest2=GetXmlHttpObject();
	// Create a function that will receive data sent from the server
	ajaxRequest2.onreadystatechange = function(){
		if(ajaxRequest2.readyState == 4){
			var ajaxDisplay2 = document.getElementById('photo_old'+value2);
			ajaxDisplay2.innerHTML = ajaxRequest2.responseText;
			
			for(var i=1;i<=4;i++)
			{
			if(i==value3)
			document.getElementById('btn_'+value2+'_'+value3).style.backgroundColor="#cccccc";
			else
			document.getElementById('btn_'+value2+'_'+i).style.backgroundColor="#ffffff";
            }
			
		}
	}
	
	//var materials = document.getElementById('cat').value;
	var queryString2 = "?status=q&op="+value+"&id="+value2;
	ajaxRequest2.open("GET", "photo_player1a.php" + queryString, true);
	ajaxRequest2.send(null); 
}
else
{
document.getElementById('photo_old'+value2).innerHTML = '';
}

if(value>0)
{
ajaxRequest3=GetXmlHttpObject();
	// Create a function that will receive data sent from the server
	ajaxRequest3.onreadystatechange = function(){
		if(ajaxRequest3.readyState == 4){
			var ajaxDisplay3 = document.getElementById('photo_new'+value2);
			ajaxDisplay3.innerHTML = ajaxRequest3.responseText;
		}
	}
	
	//var materials = document.getElementById('cat').value;
	var queryString3 = "?status=q&op="+value+"&id="+value2;
	ajaxRequest3.open("GET", "photo_player1b.php" + queryString, true);
	ajaxRequest3.send(null); 
}
else
{
document.getElementById('photo_new'+value2).innerHTML = '';
}

}





function changePhoto(value, value2, width, height)
{
document.getElementById('imgShow'+value2).href="./collection/portfolio/large/"+value;
document.getElementById('imgShow'+value2).title="./collection/portfolio/large/"+value;
document.getElementById('imgShow'+value2).width=width;
document.getElementById('imgShow'+value2).height=height;
document.getElementById('photo_new'+value2).innerHTML = '<img src="./collection/portfolio/'+value+'" height="227" width="306" class="productborder2" border="0">';
}

function changePhoto0(value, value1, value2, width, height)
{
//alert(value+value2+width+height);
document.getElementById('imgShow'+value1+value2).href="./collection/portfolio/large/"+value;
document.getElementById('imgShow'+value1+value2).title="./collection/portfolio/large/"+value;
document.getElementById('imgShow'+value1+value2).width=width;
document.getElementById('imgShow'+value1+value2).height=height;
}


function changePhoto2(value, value2, width, height, des)
{
//alert(value2);
//alert(value+value2+width+height);
document.getElementById('imgShow'+value2).href="./collection/property/large/"+value;
document.getElementById('imgShow'+value2).title="./collection/property/large/"+value;
document.getElementById('imgShow'+value2).width=width;
document.getElementById('imgShow'+value2).height=height;
document.getElementById('photo_des'+value2).innerHTML=des;
document.getElementById('photo_new'+value2).innerHTML = '<img src="./collection/property/'+value+'" height="227" width="306" class="productborder2" border="0">';
}







function check(){
var test_status=true;
if (document.getElementById('post_name').value == ""){
			alert("Please input your Name!");
			test_status=false;
			return false;
}

if (document.getElementById('comment').value == ""){
			alert("Please input the Message!");
			test_status=false;
			return false;
}
//if(test_status)
//return post_confirm("Comment");

}


function checkrating(){
var test_status=true;
if (document.getElementById('rate_name').value == ""){
			alert("Please input your Name!");
			test_status=false;
			return false;
}

//if(test_status)
//return post_confirm("Rating");
}


function checkrant(){
var test_status=true;
if (document.getElementById('rant_owner').value == ""){
			alert("Please input your Name!");
			test_status=false;
			return false;
}

if (document.getElementById('rant_title').value == ""){
			alert("Please input the Rant Topic!");
			test_status=false;
			return false;
}

if (document.getElementById('comment').value == ""){
			alert("Please input the Rant!");
			test_status=false;
			return false;
}

//if(test_status)
//return post_confirm("Rant");

}



function checkcontact(){
var test_status=true;
if (document.getElementById('name').value == ""){
			alert("Please input your Name!");
			test_status=false;
			return false;
}



	if (document.getElementById('email').value == ""){
		alert("Please input your E-mail Address");
		document.getElementById('email').focus();
		test_status=false;
		return false;
    }else {
		var emailStr=document.getElementById('email').value;
		//alert(emailStr);
		var emailPat=/[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; 
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
 			alert("E-mail Address must include ( @ and . )");
		    document.getElementById('email').focus();
			test_status=false;
 			return false;
		}
	}


	var str=document.getElementById('phone').value;
	str1=str.replace(' ',"");
	str2=str1.replace('-',"");
	str3=str2.replace('+',"");
	str4=str3.replace('.',"");
	str5=str4.replace(' ',"");
	str6=str5.replace('(',"");
	str7=str6.replace(')',"");
	if (str7 == "" || isNaN(str7)==true){
		alert("Please fill your valid Phone Number!");
		document.getElementById('phone').focus();
		return false;
    }



if (document.getElementById('message').value == ""){
			alert("Please input the Message");
			test_status=false;
			return false;
}

//if(test_status)
//return post_confirm("Enquiry");

}




function checkcontact2(){
var test_status=true;




	if (document.getElementById('email').value == ""){
		alert("Please input your E-mail Address");
		document.getElementById('email').focus();
		test_status=false;
		return false;
    }else {
		var emailStr=document.getElementById('email').value;
		//alert(emailStr);
		var emailPat=/[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; 
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
 			alert("E-mail Address must include ( @ and . )");
		    document.getElementById('email').focus();
			test_status=false;
 			return false;
		}
	}


if (document.getElementById('subject').value == ""){
			alert("Please input Subject!");
			test_status=false;
			return false;
}



if (document.getElementById('message').value == ""){
			alert("Please input the Text");
			test_status=false;
			return false;
}

//if(test_status)
//return post_confirm("Feedback");

}









function check1(){
var num=document.getElementById('shape_num').value;
//alert(num);
var test_status=true;
for (i=1; i<=num; i++) {
	if (document.getElementById('selected_shape'+i).checked==true){
		test_status=false;
    }
}

	
if (test_status){
			alert("Please select the shoe shape!");
			return false;
}

if (document.getElementById('size_type').value == ""){
			alert("Please select the standard of shoe size!");
			return false;
}

if (document.getElementById('size_value').value == ""){
			alert("Please select the size of shoe!");
			return false;
}

}






function check3(){
if (document.getElementById('back_status').value == "0"){
///////////////////////////////////////////////////////////////////////////////////////////
if (document.getElementById('selected_materials1').value == ""){
			alert("Please select the material!");
			return false;
}
var num=document.getElementById('materials_color_num1').value;
var test_status=true;
for (i=1; i<=num; i++) {
	if (document.getElementById('materials_color1'+i).checked==true){
		test_status=false;
    }
}

if (test_status){
			alert("Please select the material color!");
			return false;
}
///////////////////////////////////////////////////////////////////////////////////////////



/*
var test_status2=true;
for (i=1; i<=3; i++) {
	if (document.getElementById('heel_style1'+i).checked==true){
		test_status2=false;
    }
}
if (test_status2){
			alert("Please select the heel shpae!");
			return false;
}
*/
///////////////////////////////////////////////////////////////////////////////////////////
if (document.getElementById('heel_style13').checked==true){

if (document.getElementById('selected_materials2').value == ""){
			alert("Please select the material!");
			return false;
}

var num=document.getElementById('materials_color_num2').value;
var test_status3=true;
for (i=1; i<=10; i++) {
	if (document.getElementById('materials_color2'+i).checked==true){
		test_status3=false;
    }
}

if (test_status3){
			alert("Please select the material color!");
			return false;
}
}
///////////////////////////////////////////////////////////////////////////////////////////



///////////////////////////////////////////////////////////////////////////////////////////
var test_status5=true;
if(document.getElementById('platform_style2').checked==true){
/*
for (i=1; i<=3; i++) {
	if (document.getElementById('heel_style2'+i).checked==true){
		test_status5=false;
    }
}
if (test_status5){
			alert("Please select the heel shpae!");
			return false;
}
*/
}
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
if (document.getElementById('heel_style23').checked==true){

if (document.getElementById('selected_materials3').value == ""){
			alert("Please select the material!");
			return false;
}

var num=document.getElementById('materials_color_num3').value;
var test_status4=true;
for (i=1; i<=10; i++) {
	if (document.getElementById('materials_color3'+i).checked==true){
		test_status4=false;
    }
}

if (test_status4){
			alert("Please select the material color!");
			return false;
}
}
///////////////////////////////////////////////////////////////////////////////////////////
}
}





function check4(){
if (document.getElementById('back_status').value == "0"){

var num1=document.getElementById('edge_num').value;
var test_status1=false;
for (i=1; i<=num1; i++) {
	if (document.getElementById('edge_style'+i).checked==true){
		test_status1=true;
    }
}
if (test_status1){
///////////////////////////////////////////////////////////////////////////////////////////
if (document.getElementById('selected_materials4').value == ""){
			alert("Please select the material4!");
			return false;
}
var num2=document.getElementById('materials_color_num4').value;
var test_status2=true;
for (i=1; i<=10; i++) {
	if (document.getElementById('materials_color4'+i).checked==true){
		test_status2=false;
    }
}

if (test_status2){
			alert("Please select the material color!");
			return false;
}
///////////////////////////////////////////////////////////////////////////////////////////
}

/*
if (test_status1 && document.getElementById('edge_style1').checked!=true){
///////////////////////////////////////////////////////////////////////////////////////////
var test_status2a=true;
for (i=1; i<=10; i++) {
	if (document.getElementById('materials_colorb4'+i).checked==true){
		test_status2a=false;
    }
}

if (test_status2a){
			alert("Please select the material color!");
			return false;
}
///////////////////////////////////////////////////////////////////////////////////////////
}
*/


var num3=document.getElementById('acc_num').value;
var test_status3=false;
for (i=1; i<=3; i++) {
	if (document.getElementById('acc_style'+i).checked==true){
		test_status3=true;
    }
}
if (test_status3){
///////////////////////////////////////////////////////////////////////////////////////////
if (document.getElementById('selected_materials5').value == ""){
			alert("Please select the material!");
			return false;
}
var num4=document.getElementById('materials_color_num5').value;
var test_status4=true;
for (i=1; i<=10; i++) {
	if (document.getElementById('materials_color5'+i).checked==true){
		test_status4=false;
    }
}

if (test_status4){
			alert("Please select the material color!");
			return false;
}
///////////////////////////////////////////////////////////////////////////////////////////
}
}
}


  function check5(){
	if (document.form_step5.name.value == ""){
			alert("Please fill your First Name!");
			document.form_step5.name.focus();
			return false;
	}
	
	if (document.form_step5.name1.value == ""){
			alert("Please fill your Last Name!");
			document.form_step5.name1.focus();
			return false;
	}

	if (document.form_step5.address.value == ""){
			alert("Please fill your address!");
			document.form_step5.address.focus();
			return false;
	}
	
	if (document.form_step5.city.value == ""){
			alert("Please fill your city!");
			document.form_step5.city.focus();
			return false;
	}
	
	if (document.form_step5.city.value == ""){
			alert("Please fill your city!");
			document.form_step5.city.focus();
			return false;
	}
	
	if (document.form_step5.country.value == ""){
			alert("Please select your country!");
			document.form_step5.country.focus();
			return false;
	}
	
	if (document.form_step5.country_code.value == ""){
			alert("Please select your country code!");
			document.form_step5.country_code.focus();
			return false;
	}
	
	if (document.form_step5.email.value == ""){
		alert("Please fill in the E-mail Address");
		document.form_step5.email.focus();
		return false;
    }else {
		var emailStr=document.form_step5.email.value;
		//alert(emailStr);
		var emailPat=/[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; 
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
 			alert("E-mail Address must include ( @ and . )");
		    document.form_step5.email.focus();
 			return false;
		}
	}

}


function calculation(value){
if(value<1)
{
value=1;
document.getElementById('quantity').value =1;
}
document.getElementById('cost').innerHTML =(document.getElementById('unit_cost').value)*value;

}

function selectedexternal(){
if (document.getElementById('heel_style23').checked==true){
document.getElementById('colorchart3').style.visibility='visible';
}
}

function post_confirm(value)
{
var r=confirm("Are you sure to submit the "+value+"?");
return r;
}

function empty_confirm()
{
var r=confirm("Are you sure to empty the cart?");
return r;
}
////////////ambiente ///////////////////////////////////////////////////////////////////////////////////////////













