

function addMoreFields(myDiv,textBox) {
	
	var ni = document.getElementById(myDiv);
	var numi = document.getElementById(textBox);
	var num = (document.getElementById(textBox).value -1)+ 2;
	numi.value = num;
		
	var newdiv = document.createElement('div');
	
	var divIdName = myDiv+num;
	
	newdiv.setAttribute('id',divIdName);	
	
	output  = '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="centeralign"><tr><td height="30" valign="top" width="22%">';
	output += '<select name="selChannel['+num+']" id="selChannel['+num+']"><option value="Retailer">Retailer</option><option value="DSA">DSA</option><option value="Reseller">Reseller</option><option value="MLM">MLM</option><option value="Distributor">Distributor</option><option value="C & F">C & F</option><option value="Dealer">Dealer</option><option value="Agent">Agent</option></select>';	
	output += '</td><td height="30" valign="top" width="22%">';
	output += '<select name="selChannelInvRange['+num+']" id="selChannelInvRange['+num+']"><option value="17">Rs. 1 Cr. and above</option><option value="15">Rs. 50lac - Rs. 1 Cr.</option><option value="13">Rs. 30lac - Rs. 50lac</option><option value="11">Rs. 20lac - Rs. 30lac</option><option value="9">Rs. 10lac - Rs. 20lac</option><option value="7">Rs. 5lac - Rs. 10lac</option><option value="5">Rs. 2lac - Rs.5lac</option><option value="3">Rs. 50,000 - Rs. 2lac</option><option value="1">Rs. 10,000 - Rs. 50,000</option></select>';
	output += '<td height="30" valign="top" width="26%">';
	output += '<input name="txtTPMargin['+num+']" id="txtTPMargin['+num+']" type="text" class="common" size="30" />';
	output += '</td><td height="30" valign="top" width="24%">';
	output += '<input name="txtTPAreaReq['+num+']" id="txtTPAreaReq['+num+']" type="text" class="common" size="30" />';
	output += '</td><td height="30" valign="top" width="6%">&nbsp;';
	output += '</td></tr></table>';
	
	newdiv.innerHTML = output;
    ni.appendChild(newdiv);
	
}//End of Function



function hidediv(divName) {

	if(divName!=""){
		divId =document.getElementById(divName);
		divId.style.display="none";
		return true;
	}
}//End of Function


function showdiv(divName) {	

	if(divName!=""){			
		divId =document.getElementById(divName);
		divId.style.display="block";
		return true;
	}
}//End of Function
	

function showdiv_clearvalue(divName) {	
	
	if(divName=='divFranchisor'){			
		divId =document.getElementById(divName);
		document.getElementById('franchisorName').value="";
		document.getElementById('franchisorAddress').value="";
		document.getElementById('franchisorEmail').value="";
		document.getElementById('franchisorPhoneCode').value="";
		document.getElementById('franchisorPhone').value="";
		document.getElementById('franchisorDetails').value="";
		divId.style.display="block";
		return true;
	}else 	
	
	if(divName=='divFranchise'){
		divId =document.getElementById(divName);
		document.getElementById('franchiseName').value="";
		document.getElementById('franchiseAddress').value="";
		document.getElementById('franchiseEmail').value="";
		document.getElementById('franchisePhoneCode').value="";
		document.getElementById('franchisePhone').value="";
		document.getElementById('franchiseDetails').value="";
		divId.style.display="block";
		return true;
	}else
	if(divName=='divFranchisorHome'){			
		divId =document.getElementById(divName);
		document.getElementById('franchisorName').value="";
		document.getElementById('franchisorAddress').value="";
		document.getElementById('franchisorEmail').value="";
		document.getElementById('franchisorPhoneCode').value="";
		document.getElementById('franchisorPhone').value="";
		document.getElementById('franchisorDetails').value="";
		divId.style.display="block";
		return true;
	}else 
	if(divName=='divFranchiseHome'){
		divId =document.getElementById(divName);
		document.getElementById('franchiseName').value="";
		document.getElementById('franchiseAddress').value="";
		document.getElementById('franchiseEmail').value="";
		document.getElementById('franchisePhoneCode').value="";
		document.getElementById('franchisePhone').value="";
		document.getElementById('franchiseDetails').value="";
		divId.style.display="block";
		return true;
	}
	
}//End of Function


function emailValidation(value1){
 
	if (document.getElementById(value1).value!="") {
		return checkemail(value1)
	}else{
		return true
	}
}//Email Validation

function checkemail(value1){
	
	var str=document.getElementById(value1).value;
	
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(str)){
		
		return true;
	
	}else{
	
		alert("Please Enter valid email address");	
		document.getElementById(value1).value="";
		value1.focus();					 
		return false;
	}

}//End of Email Validation


function myPopUpWin(mylink,wname,usrw,usrh,iw,ih) {

	
	var iMyWidth;
	var iMyHeight;
	
	iMyWidth = (window.screen.width/2) - (iw);
	iMyHeight = (window.screen.height/2) - (ih);

	var mywin = window.open(mylink,wname,"status=no,width=" + usrw + ",height=" + usrh + ",resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
	
	mywin.focus();
}//End Popup Window Function
