function isEmailAddr(email)
{
	var result = false
  	var theStr = new String(email)
  	var index = theStr.indexOf("@");
 	if (index > 0)
  	{
    	var pindex = theStr.indexOf(".",index);
    	if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
 	}
  return result;
}
function mobilecheck(){
	brandname=document.frmcontact.selectbrand.value;
	
	
	selectprob=document.frmcontact.selectprob.value;
	name=document.frmcontact.name.value;
	email=document.frmcontact.email.value;
	mobile=document.frmcontact.mobile.value;
	City=document.frmcontact.City.value;
	//alert(City);
	if(brandname=="Select your Brand *"){
				msg="* Please select your brand.";
		document.getElementById("selectbrand").className="error_textfield";
		document.getElementById("mandatory").innerHTML=msg;
		return false;
		}else if(selectprob=="Choose your Problem *"){
			msg="* Please select your problem.";
			document.getElementById("selectbrand").className="textfield";
			document.getElementById("selectprob").className="error_textfield";
			document.getElementById("mandatory").innerHTML=msg;
			return false;
			}else if(name=="Your Name *" || name==""){
			document.getElementById("selectprob").className="textfield";
			document.getElementById("name").className="error_textfield";
			msg="* Please enter your name.";
			document.getElementById("mandatory").innerHTML=msg;
			return false;
			}else if(email=="Email *" || email==""){
			document.getElementById("name").className="textfield";
			document.getElementById("email").className="error_textfield";
				msg="* Please enter your email.";
			document.getElementById("mandatory").innerHTML=msg;
			return false;
			}else  if(!isEmailAddr(email))
			{
			document.getElementById("name").className="textfield";
			document.getElementById("email").className="error_textfield";
			msg="* Please enter a valid email address.";
				document.getElementById("mandatory").innerHTML=msg;
				return false;
			}else if(mobile=="Mobile No.*" || mobile==""){
			document.getElementById("email").className="textfield";
			document.getElementById("mobile").className="error_textfield";
			msg="* Please enter your mobile number.";
			document.getElementById("mandatory").innerHTML=msg;
			return false;
			}else if(isNaN(mobile)){
			document.getElementById("email").className="textfield";
			document.getElementById("mobile").className="error_textfield";
			msg="* Mobile number should contain only numbers.";
			document.getElementById("mandatory").innerHTML=msg;
			return false;
			}else if(City=="City *" || City==""){
			document.getElementById("mobile").className="textfield";
			document.getElementById("City").className="error_textfield";
			msg="* Please select your city.";
			document.getElementById("mandatory").innerHTML=msg;
			return false;
			}else{
				
				return true;
				}
	/*if(mandatory==""){
	return true;
	}else{
			return false;
		}*/
}
	

function otherbrand()
{
	//document.getElementById("name").style.display="";
	
brandname=document.frmcontact.selectbrand.value;
		if(brandname=="Other"){
			document.getElementById("othertxt").style.display="none";
			document.getElementById("other").style.display=""
		}else{
			document.getElementById("othertxt").style.display="";
			document.getElementById("other").style.display="none"
			}
	}
 function AddItem()
   {
	   
var selectObj = document.getElementById("selectsubprob");
	var selectParentNode = selectObj.parentNode;
	var newSelectObj = selectObj.cloneNode(false); // Make a shallow copy
	selectParentNode.replaceChild(newSelectObj, selectObj);
	

	    var opt = document.createElement("option");
 		var opt1 = document.createElement("option");
		var opt2 = document.createElement("option");
		var opt3 = document.createElement("option");
		var opt4 = document.createElement("option");
		var opt5 = document.createElement("option");
		var opt6 = document.createElement("option");
		var opt7 = document.createElement("option");
	   brandname=document.frmcontact.selectprob.value;
	   if(brandname=="Power"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Does Not Switch ON ";
        opt.value = "Does Not Switch ON ";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Does Not Switch OFF";
        opt1.value = "Does Not Switch OFF";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "Contact Service ";
        opt2.value = "Contact Service ";
		document.getElementById("selectsubprob").options.add(opt3);
        opt3.text = "Boot Failure";
        opt3.value = "Boot Failure";
		   }
		   if(brandname=="Network"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "No Calls Out ";
        opt.value = "No Calls Out ";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Drops Calls ";
        opt1.value = "Drops Calls ";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "No Service ";
        opt2.value = "No Service ";
		document.getElementById("selectsubprob").options.add(opt3);
        opt3.text = "Bad transmission ";
        opt3.value = "Bad transmission ";
		document.getElementById("selectsubprob").options.add(opt4);
        opt4.text = "No Service with all network";
        opt4.value = "No Service with all network";
		   }
		   if(brandname=="No Bluetooth"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Drops Bluetooth connection";
        opt.value = "Drops Bluetooth connection";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Data not received";
        opt1.value = "Data not received";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "Device not search";
        opt2.value = "Device not search";
		//document.getElementById("selectsubprob").options.add(opt3);
       ///opt3.text = "Bad transmission ";
       // opt3.value = "Bad transmission ";
		//document.getElementById("selectsubprob").options.add(opt4);
       // opt4.text = "No Service with all network";
        //opt4.value = "No Service with all network";
		   }
		   if(brandname=="No USB Cable"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Not Connect";
        opt.value = "Not Connect";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Drops USB Cable";
        opt1.value = "Drops USB Cable";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "No WLAN Connection ";
        opt2.value = "No WLAN Connection ";
		document.getElementById("selectsubprob").options.add(opt3);
        opt3.text = "Drops WLAN";
        opt3.value = "Drops WLAN";
		//document.getElementById("selectsubprob").options.add(opt4);
        //opt4.text = "No Service with all network";
       // opt4.value = "No Service with all network";
		   }
		    if(brandname=="Audio"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Drops Video output ";
        opt.value = "Drops Video output ";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "No outgoing Audio ";
        opt1.value = "No outgoing Audio ";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "Poor outgoing Audio ";
        opt2.value = "Poor outgoing Audio ";
		document.getElementById("selectsubprob").options.add(opt3);
        opt3.text = "No incoming Audio ";
        opt3.value = "No incoming Audio ";
		document.getElementById("selectsubprob").options.add(opt4);
        opt4.text = "Poor incoming Audio ";
        opt4.value = "Poor incoming Audio ";
		document.getElementById("selectsubprob").options.add(opt5);
        opt5.text = "Application Audio ";
        opt5.value = "Application Audio ";
		document.getElementById("selectsubprob").options.add(opt6);
        opt6.text = "Ringing Tone Issue ";
        opt6.value = "Ringing Tone Issue ";
		document.getElementById("selectsubprob").options.add(opt7);
        opt7.text = "Vibra Issue ";
        opt7.value = "Vibra Issue ";
		   }
		    if(brandname=="Cosmetics"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Pannel broken";
        opt.value = "Pannel broken";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Extra accesory required";
        opt1.value = "Extra accesory required";
		
		   }
		   
		     if(brandname=="Display"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Backlight Issue ";
        opt.value = "Backlight Issue ";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Blank Display ";
        opt1.value = "Blank Display ";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "Bad Pixel ";
        opt2.value = "Bad Pixel ";
		document.getElementById("selectsubprob").options.add(opt3);
        opt3.text = "Flickering ";
        opt3.value = "Flickering ";
		document.getElementById("selectsubprob").options.add(opt4);
        opt4.text = "Mechanically Broken ";
        opt4.value = "Mechanically Broken ";
		   }
		   
		    if(brandname=="Camera"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Bad Image ";
        opt.value = "Bad Image ";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Error Message ";
        opt1.value = "Error Message ";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "No Functionality ";
        opt2.value = "No Functionality ";
		
		//document.getElementById("selectsubprob").options.add(opt4);
        //opt4.text = "No Service with all network";
       // opt4.value = "No Service with all network";
		   }
		    if(brandname=="Keypad"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Mechanically Broken ";
        opt.value = "Mechanically Broken ";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Key(s) donot work";
        opt1.value = "Key(s) donot work";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "Backlight Issue ";
        opt2.value = "Backlight Issue ";
		
		//document.getElementById("selectsubprob").options.add(opt4);
        //opt4.text = "No Service with all network";
       // opt4.value = "No Service with all network";
		   }
		   if(brandname=="SIM"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Insert SIM card ";
        opt.value = "Insert SIM card ";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Pin Code ";
        opt1.value = "Pin Code ";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "SIM card rejected ";
        opt2.value = "SIM card rejected ";
		document.getElementById("selectsubprob").options.add(opt3);
        opt3.text = "Invalid SIM card ";
        opt3.value = "Invalid SIM card ";
		//document.getElementById("selectsubprob").options.add(opt4);
        //opt4.text = "No Service with all network";
       // opt4.value = "No Service with all network";
		   }
		    if(brandname=="Battery"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "No Charging ";
        opt.value = "No Charging ";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "low battery Capacity/battery";
        opt1.value = "low battery Capacity/battery";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "drains fast ";
        opt2.value = "drains fast ";
		document.getElementById("selectsubprob").options.add(opt3);
        opt3.text = "Battery overheating";
        opt3.value = "Battery overheating";
		document.getElementById("selectsubprob").options.add(opt4);
        opt4.text = "Does not stop charging ";
        opt4.value = "Does not stop charging ";
		document.getElementById("selectsubprob").options.add(opt5);
        opt5.text = "Back up battery ";
        opt5.value = "Back up battery ";
		
		   }
		     if(brandname=="Applications"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "Phone Locks Up (hang)";
        opt.value = "Phone Locks Up (hang)";
        document.getElementById("selectsubprob").options.add(opt1);
        opt1.text = "Phone restarts/reboots ";
        opt1.value = "Phone restarts/reboots ";
		document.getElementById("selectsubprob").options.add(opt2);
        opt2.text = "Application crashes ";
        opt2.value = "Application crashes ";
		
		   }
		     if(brandname=="Memory card"){
		    // Add an Option object to Drop Down/List Box
        document.getElementById("selectsubprob").options.add(opt);
        // Assign text and value to Option object
     	opt.text = "MMC rejected/invalid";
        opt.value = "MMC rejected/invalid";
        
		   }  
        // Create an Option object        
       
		
       


    }
function otherproblem(){
	

	
	
	
	brandname=document.frmcontact.selectprob.value;
	
	if(brandname=="Choose your Problem *"){
		document.getElementById("selectsubprob").style.display="none";
		document.getElementById("other_p").style.display="none";
					document.getElementById("otherp").style.display="";		
		}else if(brandname=="Other"){
			document.getElementById("otherp").style.display="none";
			document.getElementById("selectsubprob").style.display="none";
			document.getElementById("other_p").style.display=""
			
			}
		
		else{
			
					document.getElementById("selectsubprob").style.display="";
					AddItem();
					document.getElementById("otherp").style.display="none";
					document.getElementById("other_p").style.display="none";
			}
			
			
			
		/*if(brandname=="Other"){
			document.getElementById("otherp").style.display="none";
			document.getElementById("other_p").style.display=""
		}else{
			document.getElementById("otherp").style.display="";
			document.getElementById("other_p").style.display="none"
			}*/
	}
function revertcontactfield(fieldname)
{
	if(fieldname=="name")
	{
		if(document.frmcontact.name.value=="")
		{
			document.frmcontact.name.value="Your Name *";
			return false;
		}
	}
		
	if(fieldname=="address")
	{
		if(document.frmcontact.address.value=="")
		{
			document.frmcontact.address.value="Street Address";
			return false;
		}
	}
			

	if(fieldname=="email")
	{
		if(document.frmcontact.email.value=="")
		{
			document.frmcontact.email.value="Email *";
			return false;
		}
	}
	if(fieldname=="mobile")
	{
		if(document.frmcontact.mobile.value=="")
		{
			document.frmcontact.mobile.value="Mobile No.*";
			return false;
		}
	}
	
		if(fieldname=="other")
	{
		if(document.frmcontact.other.value=="")
		{
			document.frmcontact.other.value="Other";
			return false;
		}
	}
	
		if(fieldname=="other_p")
	{
		if(document.frmcontact.other_p.value=="")
		{
			document.frmcontact.other_p.value="Other";
			return false;
		}
	}
	
	return true;
}

function refreshcontactfield(value,fieldname)
{
	
	if((fieldname=="name") && (value=="Your Name *"))
	{
		document.frmcontact.name.value="";
		return false;	
	}
	
	
	
	if((fieldname=="address") && (value=="Street Address"))
	{
		document.frmcontact.address.value="";
		return false;	
	}
		if((fieldname=="other") && (value=="Other"))
	{
		document.frmcontact.other.value="";
		return false;	
	}

		if((fieldname=="other_p") && (value=="Other"))
	{
		document.frmcontact.other_p.value="";
		return false;	
	}
	
	if((fieldname=="email") && (value=="Email *"))
	{
		document.frmcontact.email.value="";
		return false;	
	}
	
	if((fieldname=="mobile") && (value=="Mobile No.*"))
	{
		document.frmcontact.mobile.value="";
		return false;	
	}
	
	
	return true;
	
}
