// Get base url
	url = document.location.href;
	xend = url.lastIndexOf("/") + 1;
	var base_url = url.substring(0, xend);
	//alert(url);

	var div_name= new Array; 
	var form_name = new Array;
	var div_indicator = new Array; 
	var form_name1="";
	var no_of_divs = "";
	var div_name_content = "";
	var url_next = "";
	var empty_form = "";

function validate_new(url)
	{ 

		 var flag=0;
		 if(document.frm_vofferu.check_flag.value != null)
		 {
		  flag=document.frm_vofferu.check_flag.value;	 
		 }

           
		 if(flag==1)
		 {
				alert("Duplicate User Name....... Please re enter.");
				document.frm_vofferu.username.focus();
				return false;
		 }

		 if(flag==2)
		 {
				alert("Duplicate Email ....... Please re enter.");
				document.frm_vofferu.Email.focus();
				return false;
		 }

		 if(flag==3)
		 {
				alert("Duplicate User Name and Email....... Please re enter.");
				document.frm_vofferu.username.focus();
				return false;
		 }

         if (document.frm_vofferu.username.value=="")
		   {
				alert("Please Enter User Name.");
				document.frm_vofferu.username.focus();
				return false;
		   }

//$$$$$$$$$$$$$$$$$$$$ Email $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


  	    if (document.frm_vofferu.Email.value=="")
		   {
				alert("Please Enter Email.");
				document.frm_vofferu.Email.focus();
				return false;
			}
		else
		    {
				var str=document.frm_vofferu.Email.value;
				var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
				if (!filter.test(str))
				{
				alert("Please enter valid email address.");
				document.frm_vofferu.Email.focus();
				return false;
				}
			}

  	    if (document.frm_vofferu.check_flag.value)
		   {
			    var check = document.frm_vofferu.check_flag.value;
				
				if(check==1  || check==3 )
				{
					alert(document.frm_vofferu.check_msg.value);
					document.frm_vofferu.username.focus();
					return false;
				}
				else if(check==2)
				{
					alert(document.frm_vofferu.check_msg.value);
					document.frm_vofferu.Email.focus();
					return false;
				}
				
			}

		  if (document.frm_vofferu.Password.value=="")
		   {
				alert("Please Enter Password.");
				document.frm_vofferu.Password.focus();
				return false;
			} 	

		  if (document.frm_vofferu.FirstName.value=="")
		   {
				alert("Please Enter First Name.");
				document.frm_vofferu.FirstName.focus();
				return false;
			} 	

		  if (document.frm_vofferu.LastName.value=="")
		   {
				alert("Please Enter Last Name.");
				document.frm_vofferu.LastName.focus();
				return false;
			} 	


		  if (document.frm_vofferu.Title.value=="")
		   {
				alert("Please Select Title.");
				document.frm_vofferu.Title.focus();
				return false;
			} 	

		  if (document.frm_vofferu.Address1.value=="")
		   {
				alert("Please Enter Address1.");
				document.frm_vofferu.Address1.focus();
				return false;
			} 	

		  if (document.frm_vofferu.Address2.value=="")
		   {
				alert("Please Enter Address2.");
				document.frm_vofferu.Address2.focus();
				return false;
			} 	

		  if (document.frm_vofferu.City.value=="")
		   {
				alert("Please Enter City.");
				document.frm_vofferu.City.focus();
				return false;
			} 	

		  if (document.frm_vofferu.State.value=="")
		   {
				alert("Please Enter State.");
				document.frm_vofferu.State.focus();
				return false;
			} 	


		  if (document.frm_vofferu.rh_country.value=="")
		   {
				alert("Please Enter Country.");
				document.frm_vofferu.rh_country.focus();
				return false;
			} 	

//$$$$$$$$$$$$$$$$$$$$ Post Code $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$4

		  if (document.frm_vofferu.PostCode.value=="")
		   {
				alert("Please Enter Post Code.");
				document.frm_vofferu.PostCode.focus();
				return false;
			} 	
		   else
		   {
					
					var postcode = document.frm_vofferu.PostCode.value;
					var len = postcode.length;
					if(len<6 || len>8 || postcode.indexOf(" ")== -1)
					{

						alert("Your Post Code appears to be in-correct");
						document.frm_vofferu.PostCode.focus();
						return false;
					}
					else
					{
						
					var count = 0 ;
					var str = postcode.split(" ");
					var begin=str[0];
					var last=str[1];
					if(last.length==3 && (begin.length== 2 || begin.length== 3 || begin.length== 4))
					{
					validchars1="1234567890";
					validchars2="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
					validchars3="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
					if(((validchars1.indexOf(last.charAt(0))<0)||(validchars3.indexOf(last.charAt(1))<0)||(validchars2.indexOf(last.charAt(2)))<0) )
					{
						count+=0;
					}
					else 
					{
						count+=1;
					}
					
					
					if(begin.length==4)
					{
					 if(((validchars2.indexOf(begin.charAt(0))<0)||(validchars2.indexOf(begin.charAt(1))<0)||(validchars3.indexOf(begin.charAt(2)))<0)||(validchars3.indexOf(begin.charAt(3))<0))
						{			 
							count+=0;
						 }
						else 
						{
						count+=1;
						}
					}
					
					if(begin.length==3)
					{
						if(((validchars2.indexOf(begin.charAt(0))<0)||(validchars3.indexOf(begin.charAt(1))<0)||(validchars1.indexOf(begin.charAt(2)))<0))
						{			 
							count+=0;
						 }
						else 
						{
							count+=1;
						}
						
						
					}
					
					else if(begin.length==2)
						{
							if(((validchars2.indexOf(begin.charAt(0))<0)||(validchars1.indexOf(begin.charAt(1)))<0))
							{			 
								count+=0;
							 }
							else 
							{
							count+=1;
							}
							
						 }
					
					if(count!=2)
						{
							 alert("Your Post Code appears to be in-correct");
							 document.frm_vofferu.PostCode.focus();
							 return false;
						}
					 }
					else
						{
							alert("Your Post Code appears to be in-correct");
							document.frm_vofferu.PostCode.focus();
							return false;
						}
					
				   }
   
			}

		if (document.frm_vofferu.Gender.value=="")
		   {
				alert("Please Select Gender.");
				document.frm_vofferu.Gender.focus();
				return false;
			} 	

  	    if (document.frm_vofferu.Year.value=="-Select-")
		   {
				alert("Please Select Year.");
				document.frm_vofferu.Year.focus();
				return false;
			}


		if (document.frm_vofferu.Month.value=="")
		   {
				alert("Please Select Month.");
				document.frm_vofferu.Month.focus();
				return false;
			}

		if (document.frm_vofferu.Day.value=="-Select-")
		   {
				alert("Please Select Day.");
				document.frm_vofferu.Day.focus();
				return false;
			}


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Phone Number %%%%%%%%%%%%%%%%%%%%%%%%%%%%5

		 if(document.frm_vofferu.HomePhone.value=="")
		   {
				alert("Please Enter HomePhone Number.");
				document.frm_vofferu.HomePhone.focus();
				return false;
			}
		  else if(isNaN(document.frm_vofferu.HomePhone.value))
			
			{
				 alert("Please enter home phone in number ");
				 document.frm_vofferu.HomePhone.focus();
				 return false;
			}
			
		  else 	
			 {
				 var str_value=document.frm_vofferu.HomePhone.value;
				 str=document.frm_vofferu.HomePhone.value;
				 str=str.length;
				 var i=0;
				 var flage=0;
				 $f_2=0;
			 while(i < 2)
			  {
				// alert (" sfsdfs "+ str_value.charAt(i));
				 if(i==0 && str_value.charAt(i)==0)
				 {
					$f_2=1;
					// break;
				 }
				if($f_2==1 && i==1 && (str_value.charAt(i)==7  || str_value.charAt(i)==8 || str_value.charAt(i)==9))
				 {
					//alert ("vcxvcxjklvcxvckvlcjklllc  vkxcklvxcklj cvlkc ") ;
				   	flage=1;
					break;
				 }
 
				i++;
			  }
			  
			  if(flage==1 || str!=11)
			   {
				 alert("Your telephone number is invalid");
                 document.frm_vofferu.HomePhone.focus();
			     return false;
 
			   }
         }
 



//******************Mobile phone **************************

      if(document.frm_vofferu.MobilePhone.value=="")
		 {
			 alert("Please enter mobile phone");
			 document.frm_vofferu.MobilePhone.focus();
			 return false;
		 }
	 
	  else if(isNaN(document.frm_vofferu.MobilePhone.value))
	    {
			 alert("Please enter mobile Phone in number ");
			 document.frm_vofferu.MobilePhone.focus();
			 return false;
		}
	  else 	
	     {
			 //alert(" This is value of mobile Phone  " + document.frm_vofferu.MobilePhone.value);
			 var str_value=document.frm_vofferu.MobilePhone.value;
			 str=document.frm_vofferu.MobilePhone.value;
             str=str.length;
             //alert("fdfsdfjkkdfjjkdfdk  "+str);
             var i=0;
			 var flage=0;
			 while(i < 2)
			  {
				// alert (" sfsdfs "+ str_value.charAt(i));
				 if(i==0 && str_value.charAt(i)!=0)
				 {
					flage=1;
					break;
				 }
				else if(flage==0 && i==1 && str_value.charAt(i)!=7)
				 {
				   	flage=1;
					break;
				 }
 
				i++;
			  }
			  
			  if(flage==1 || str!=11)
			   {
				 alert("Start from 07  and the totol digits should be 11");
                 document.frm_vofferu.MobilePhone.focus();
			     return false;
 
			   }
         }

	if (document.frm_vofferu.Annual_income.value=="")
		   {
				alert("Please Select Annual Income.");
				document.frm_vofferu.Annual_income.focus();
				return false;
			}

		if (document.frm_vofferu.Homeowner.value=="")
		   {
				alert("Please Select Home owner.");
				document.frm_vofferu.Homeowner.focus();
				return false;
			}

		if (document.frm_vofferu.Occupation.value=="")
		   {
				alert("Please Select Occupation.");
				document.frm_vofferu.Occupation.focus();
				return false;
			}

		if (document.frm_vofferu.MaritalStatus.value=="")
		   {
				alert("Please Select Marital Status.");
				document.frm_vofferu.MaritalStatus.focus();
				return false;
			}

		if (document.frm_vofferu.PeopleLiving.value=="")
		   {
				alert("Please Enter PeopleLiving.");
				document.frm_vofferu.PeopleLiving.focus();
				return false;
		   }
		   
		else if(isNaN(document.frm_vofferu.PeopleLiving.value))
		   {
				alert("Please Enter the value in number");
				document.frm_vofferu.PeopleLiving.focus();
				return false;
		   }

		if (document.frm_vofferu.UnderEighteen.value=="")
		   {
				alert("Please Enter Under Eighteen.");
				document.frm_vofferu.UnderEighteen.focus();
				return false;
			}
		else if(isNaN(document.frm_vofferu.UnderEighteen.value))
		   {
				alert("Please Enter the value in number");
				document.frm_vofferu.UnderEighteen.focus();
				return false;
		   }

			showUser(url);
			
	}
	
function check_record(url)	
{
	
msg=confirm("Do You Want To Delete This Record!!!!!!");
var val="";

if (msg==true)
	{
	showUser(url);
	return true;
	}
	return false;
}
	
	
	
	
	
function check_option(url)
{
var i=0;
var k=1;
var name=" ";
var ob = document.frm_vofferu.s_cat_id;
var len=document.frm_vofferu.s_cat_id.length;
var sel_url="";

while (i != len)
	{
	if (ob.options[i].selected==true)
		{
		name=ob.options[i].value;
		sel_url = sel_url + name +"--"; 
		count=k;
		k++;
		}
	i++;
	}

	//alert(sel_url);
	
	url= url + "~count=" + count + "~sel_url=" + sel_url; 
	showUser(url);
}
function check_comment(url)
{
	if(document.frm_vofferu.desc.value=="")
	{
		alert("Please Enter Comments !!!!");
		document.frm_vofferu.desc.focus();
		return false;
	}
	else
	{
		showUser(url);
	}
}

function showUser(url)
{ 

	//alert("ORI = "+url);
	var url1 = url.split('&');
	var url2 = url1[0].split('=');
		
	if(url2[0] == 'no_of_divs')
		no_of_divs = url2[1];
			
	var i=1;
	var j=0;
		
  	var url_run = new	Array();
	while(i <= no_of_divs)
	{
		j=i-1;
		url_links = url1[i].split("##");
		//alert(url_links[1]);
		url_run[j] = url_links[1].replace(/~/g, '&');
	
		i++;
	}
	// alert("URLS=>>" + url_run);
	var url_values1 = "";
	var url_values = "";
	var j=0;
	var i =0;
	
	
	while(i < no_of_divs) 
	{
		//alert(url_run);
		//alert("loop"+i);
		
		url_values1 = url_run[i].split('?');	
		url_values = url_values1[1].split('&');	
		//alert(url_values);
		
		length1 = url_values.length;
		j = 0;
		while(j < length1) 
		{
			url_val = url_values[j].split('=');
			if(j == 0)
			{
				div_indicator[i] = 'Empty';	
				
							form_name[i] = 'Empty';	
						}
						
						if(url_val[0] == 'div')
							div_name[i] = url_val[1];
							
						if(url_val[0] == 'div_indicator')
							{
								div_indicator[i] = url_val[1];	
							}
						if(url_val[0] == 'form')
							form_name[i] = url_val[1];	
						
						if(url_val[0] == 'url_next')
							url_next = url_val[1];	
							
						if(url_val[0] == 'empty_form')
							empty_form = url_val[1];	
						
						j++;
						
					}
		
	/*	
		alert("Div Name == " + div_name[i]);
		alert("Form Name == " + form_name[i]);
		alert("Div Indicator== " + div_indicator[i]);*/
		
		if(div_indicator[i] != 'Empty')
			{
				document.getElementById(div_indicator[i]).innerHTML= "<img src='images/indicator.gif'>";
				
			}
		i++;
		
	}
		
	
	//alert("Processing  begins...........");
	
	var j=0;
	var i =0;
		
	while(i < no_of_divs) 
	{
		div_name_content= "";
		div_name_content = div_name[i];
		
		url = url_run[i];
		
		//alert(url);
		url = generate_url(url,form_name[i]);
		
		//alert("hello"+url);
		//pause(1000);
		http_request(url);
						
		
		
			
		if(div_indicator[i] != 'Empty')
			document.getElementById(div_indicator[i]).innerHTML= "";
		
		//alert("Over");
		//pause(1000);
		
		i++;
	}
		
			
	
  }
	


function GetXmlHttpObject()
		{
			var xmlHttp=null;
			try
			{
				 // Firefox, Opera 8.0+, Safari
				 xmlHttp=new XMLHttpRequest();
			}
			catch(e)
			 {
			 //Internet Explorer
				 try
				  {
				  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				  }
				 catch (e)
				  {
				  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				  }
			  }
			 return xmlHttp;
		} 


function generate_url(url, form_name1)
	{
	var len = "";	
	
	//alert("before form");
	
	if(form_name1 != "Empty")
		  {
			len=document.frm_vofferu.elements.length;
			 
			 //alert("999-"+len);
			 var i=0;
			  var value="";
			  while(i!=len)
				{
					if(document.frm_vofferu.elements[i].type == "checkbox")
						{
							if(document.frm_vofferu.elements[i].checked == true)
								{
									value= value + "&" + document.frm_vofferu.elements[i].name + "=" + document.frm_vofferu.elements[i].value;
								}
						}
					else if(document.frm_vofferu.elements[i].type == "radio")
					{
					if(document.frm_vofferu.elements[i].checked == true)
						{
						value= value + "&" + document.frm_vofferu.elements[i].name + "=" + document.frm_vofferu.elements[i].value;
						}
					}

						else
						{
					value= value + "&" + document.frm_vofferu.elements[i].name + "=" + document.frm_vofferu.elements[i].value;
						}
						
					
					
					i++;
				}
			url=url + value;
			//alert(url);
		  }
	
//alert("after loop " + url);
	return url;
	}
	

function http_request(url)
	{
	xmlHttp=GetXmlHttpObject()
	
		if (xmlHttp==null)
		 {
			 alert("Browser does not support HTTP Request")
			 return
		 }
	
		
		xmlHttp.onreadystatechange=stateChanged
	
		
		xmlHttp.open("GET",url,true)
		
		xmlHttp.send(null)
		
	}
	


function stateChanged() 
	{ 
	//alert("Respose=" + div_name_content);
	 if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		 var check=xmlHttp.responseText 
			
			//alert(check);
			
			
			var new_check = check.split('~~~~');
			//alert("sdsdsdsdsdsdsdsd");
			//alert(new_check[0]);
			//alert(new_check[1]);
			if(check == 1)
				{
					//alert("welocme in");

					window.location.href = "index.php";
					
				}
			else if(new_check[0] == 777)
				{
					//alert("helloooooooooooooooooooooooooooooooo");
					alert(new_check[1]);
					
					var url_now  = url_next + "?" + new_check[1];
					
					alert("rohit"+url_now);
					//window.open(url_now);
				}
			else if(new_check[0] == 1001)
				{
					//alert("helloooooooooooooooooooooooooooooooo");
					
					window.location.href = new_check[1];
				}
			else if(new_check[0] == 45)
				{
					alert("Sorry Duplicate entry");
					document.frm_vofferu.sh_upper_limit.focus();
					
				}			
			else
				{
					//alert("Respose6776=" + div_name_content);
					document.getElementById(div_name_content).innerHTML= xmlHttp.responseText; 
					//pause(1000);
					
						if(empty_form == 'Yes')
						{
		//				alert("tyytyt");
						len=document.frm_vofferu.elements.length;
								 var i=0;
								  var value="";
								  while(i!=len)
									{
									
										//if(document.frm_vofferu.elements[i].type == 'textbox')
											//document.frm_vofferu.elements[i].value = "";
										i++;
									}
						}
				}
		} 
	}	

function pause(millisecondi)
	{
		var now = new Date();
		var exitTime = now.getTime() + millisecondi;
	
		while(true)
		{
			now = new Date();
			if(now.getTime() > exitTime) return;
		}
	}
	
function gift_check()
	{
	if (document.frm_vofferu.gift_title.value=="")	
		{
		alert("Please Enter Gift Title!!!!!!");
		document.frm_vofferu.gift_title.focus();
		return false;
		}
		if (document.frm_vofferu.subject.value=="")	
		{
		alert("Please Enter Gift Subject!!!!!!");
		document.frm_vofferu.subject.focus();
		return false;
		}
		if (document.frm_vofferu.description.value=="")	
		{
		alert("Please Enter Gift Description!!!!!!");
		document.frm_vofferu.description.focus();
		return false;
		}
		if (isNaN(document.frm_vofferu.referal.value))	
		{
		alert("Please Enter Correct Gift Referals!!!!!!");
		document.frm_vofferu.referal.focus();
		return false;
		}
		if (document.frm_vofferu.status.value==0)	
		{
		alert("Please Enter Correct Status !!!!!!!");
		document.frm_vofferu.status.focus();
		return false;
		}
		return true;
	}


function comptitions_check()
{
	if (document.frm_vofferu.camp_title.value=="")	
	{
		alert("Please Enter Comptitions Title!!!!!!");
		document.frm_vofferu.camp_title.focus();
		return false;
		}
	if (document.frm_vofferu.subject.value=="")	
		{
		alert("Please Enter Comptitions Subject!!!!!!");
		document.frm_vofferu.subject.focus();
		return false;
		}
	if (document.frm_vofferu.description.value=="")	
		{
		alert("Please Enter Comptitions Description!!!!!!");
		document.frm_vofferu.description.focus();
		return false;
		}
	if (document.frm_vofferu.status.value==0)	
		{
		alert("Please Enter Correct Status !!!!!!");
		document.frm_vofferu.status.focus();
		return false;
		}
	return true;
}


function campaign_check()

	{
	if(document.frm_vofferu.camp_title.value=="")
		{
		alert("Please Enter The Campaign Title");
		document.frm_vofferu.camp_title.focus();
		return false;
		}
		if(document.frm_vofferu.subject.value=="")
		{
		alert("Please Enter The Campaign Subject");
		document.frm_vofferu.subject.focus();
		return false
		}
		
		if(document.frm_vofferu.description.value=="")
		{
		alert("Please Enter the Campaign Description");
		document.frm_vofferu.description.focus();
		return false;
		}
		
		if(document.frm_vofferu.url.value=="")
		{
		alert("Please Enter the Campaign URL");
		document.frm_vofferu.url.focus();
		return false;
		}
		
		if(document.frm_vofferu.status.value==0)
		{
			alert("Please Select the Campaign Status");
			document.frm_vofferu.status.focus();
		   return false;
		}

		return true;
}




function category_check()
{
//var len=document.frm_vofferu.elements.length;
//var i =0;
//
//while (i < len)
//	{
//	if (i==1 && i==4)
//		{
//		if (document.frm_vofferu.elements[i].value=="")
//			{
//			alert ("Please Enter " + document.frm_vofferu.elements[i].name + "!!!!!!!");
//			document.frm_vofferu.elements[i].focus()
//			return false;
//			}
//		}
//	i++;
//	}
	if (document.frm_vofferu.cat_name.value=="")
		{
		alert ("Please Enter Category Name!!!!!");
		document.frm_vofferu.cat_name.focus();
		return false;
		}
	if (document.frm_vofferu.desc.value=="")
		{
		alert ("Please Enter Category Description!!!!!");
		document.frm_vofferu.desc.focus();
		return false;
		}
	return true;
}

function shopping_check(url)
{
	if (document.frm_vofferu.sh_lower_limit.value==0 || isNaN(document.frm_vofferu.sh_lower_limit.value))
		{
		alert ("Lower Limit Should Be Numaric !!!!!!!");
		document.frm_vofferu.sh_lower_limit.focus();
		return false;
		}
	if (document.frm_vofferu.sh_upper_limit.value==0 || isNaN(document.frm_vofferu.sh_upper_limit.value))
		{
		alert ("Upper Limit Should Be Numaric !!!!!!!");
		document.frm_vofferu.sh_upper_limit.focus();
		return false;
		}
	if (document.frm_vofferu.sh_cost.value==0 || isNaN(document.frm_vofferu.sh_cost.value))
		{
		alert ("Shopping Cost Should Be Numaric !!!!!!!");
		document.frm_vofferu.sh_cost.focus();
		return false;
		}
	showUser(url);
}


function product_validation()
{
	if (document.products_form.rh_category.value=="middle.php?mid=20")
		{
			alert ("Please Select Correct Category !!!!!!");
			document.products_form.rh_category.focus();
			return false;
		}
	if (document.products_form.sub_rh_category.value=="middle.php?mid=20")
		{
			alert ("Please Select Correct Sub Category !!!!!!");
			document.products_form.sub_rh_category.focus();
			return false;
		}
	if (document.products_form.product_name.value=="")
		{
			alert ("Please Enter Product Name !!!!!!");
			document.products_form.product_name.focus();
			return false;
		}
	if (document.products_form.price.value==0 || isNaN(document.products_form.price.value))
		{
		alert ("Product Price Should Be Numaric !!!!!!!");
		document.products_form.price.focus();
		return false;
		}
	if (document.products_form.points.value==0 || isNaN(document.products_form.points.value))
		{
		alert ("Product Points Should Be Numaric !!!!!!!");
		document.products_form.points.focus();
		return false;
		}
	if (document.products_form.product_des.value=="")
		{
			alert ("Please Enter Product Description !!!!!!");
			document.products_form.product_des.focus();
			return false;
		}
	if (document.products_form.status.value==0)
		{
			alert ("Please Select Correct Product Status!!!!!!");
			document.products_form.status.focus();
			return false;
		}
		
	return true;
}


function setting_check()
{
	if (document.frm_vofferu.variable.value=="")
		{
		alert ("Please Enter Variable Name!!!!!");
		document.frm_vofferu.variable.focus();
		return false;
		}
	if (document.frm_vofferu.desc.value=="")
		{
		alert ("Please Enter Description!!!!!");
		document.frm_vofferu.desc.focus();
		return false;
		}
	if (document.frm_vofferu.value.value==0 || isNaN(document.frm_vofferu.value.value))
		{
		alert ("Values Should Be Numaric !!!!!!!");
		document.frm_vofferu.value.focus();
		return false;
		}
	return true;
}

function assign_value()
{
	if(document.frm_vofferu.check.checked==true)
	{
		document.frm_vofferu.f_name.value=document.frm_vofferu.first_name.value;
		document.frm_vofferu.l_name.value=document.frm_vofferu.last_name.value;
		
		document.frm_vofferu.c_name.value=document.frm_vofferu.com_name.value;
		document.frm_vofferu.address1.value=document.frm_vofferu.add1.value;
		
		document.frm_vofferu.address2.value=document.frm_vofferu.add2.value;
		document.frm_vofferu.postcode.value=document.frm_vofferu.pcode.value;
		
		document.frm_vofferu.cty.value=document.frm_vofferu.city.value;
		document.frm_vofferu.ste.value=document.frm_vofferu.state.value;
		
		document.frm_vofferu.ctry.value=document.frm_vofferu.rh_country.value;
		
	}
	else if(document.frm_vofferu.check.checked==false)
	{
		document.frm_vofferu.f_name.value="";
		document.frm_vofferu.l_name.value="";
		
		document.frm_vofferu.c_name.value="";
		document.frm_vofferu.address1.value="";
		
		document.frm_vofferu.address2.value="";
		document.frm_vofferu.postcode.value="";
		
		document.frm_vofferu.cty.value="";
		document.frm_vofferu.ste.value="";
		
		document.frm_vofferu.ctry.value="";
	}
}
function count_check(url)
{
	var len=document.frm_vofferu.elements.length;
	var i =0;
	var count=0;
	while (i < len)
	{
		if (document.frm_vofferu.elements[i].checked==true)
		{
			count++;
		}
		i++;
	}
	url= url + "~count_total=" + count;
	showUser(url);
}

function check_enter(url, no_of_checks, no_of_campaigns)
{
		var total_checks = total_no_of_checks(no_of_checks);
		
		if (no_of_campaigns==0)
			alert ("Sorry No Campaigns in Competitions!!!!");
		else if(total_checks >= no_of_checks)
			showUser(url);
		else
		{
			alert("At Least " + no_of_checks + " Campaigns Are Necessary");
			return false;
		}
}


function total_no_of_checks(no_of_checks)
{
	var len=document.frm_vofferu.elements.length;
	var i =0;
	var count=0;
	
	var no_of_checks=0;
	while (i < len)
	{
		if (document.frm_vofferu.elements[i].checked==true)
		{
			count++;
		}
		i++;
		no_of_checks = count;
	}
	return no_of_checks;
}


function check_refer(url)
{
	var len=document.frm_vofferu.elements.length - 4;
	var i=0;
	var flag=0;	
	while (i < len)
	{	
		if (document.frm_vofferu.elements[i].value=="")
			{
				alert ("Please Enter " + document.frm_vofferu.elements[i].name);	
				document.frm_vofferu.elements[i].focus();
				return false;
			}
		else if (document.frm_vofferu.elements[i].value!="" && document.frm_vofferu.elements[i + 1].value=="")
			{
			alert ("Please Enter " + document.frm_vofferu.elements[i + 1].name);
			document.frm_vofferu.elements[i + 1].focus();
			return false;
			}
		else if (document.frm_vofferu.elements[i].value!="" && document.frm_vofferu.elements[i + 1].value!="")
			{
			showUser(url);
			return true;
			}
	i++;
	}
}