 var eduindex=0;
 var combo=0;
 var proindex=0;
 var procombo=0;
function fadeOutMessage(msg,width,height,colourhex)
{
    jQuery("#wrapper").css("position","relative");
    
        var poswidth=(jQuery("#wrapper").width()/2)-(width/2);        
        document.write('<div id="msg" style="padding-top:25px;width:'+ width + 'px;height:' + height + 'px;position:absolute;background-color:#'+ colourhex + ';left:'+ poswidth +'px;top:20%;border:4px solid #c0c0c0;z-index:600;text-align:center;font-size:20px;color:#D45916;">'+msg+'</div>');
            jQuery(document).ready(function(){
        jQuery().bind("mousemove",function(){            
             jQuery("#msg").fadeOut(4000);           
        });   
    })
}


function citypopup()
{    
   
    var a='';
	var b='';
	jQuery(function() {			
		jQuery("#dialog").dialog({
			bgiframe: true,
			autoOpen: false,
			width:220,
			height: 250,
			position:[597,100],		     
			buttons: {
				'Ok': function() {				
				  
				    
				   // document.isform.submit();
				   var country='';
			var a=jQuery("#catcountry").val();				
			
			var city=jQuery("#dialog").find(".ac_input").val();
			var temp = new Array();
			temp =city.split(',');

			
			jQuery.ajax({
				type: "GET",
				url:window.location.protocol + "//" + window.location.host +"/index/checkcity",
				data: "city=" + city+"&country="+a, 
				cache: false,                
				success: function(resulta)
				{
				   
					if(resulta=='1')
					{						      
						
											
						if(resulta==true)
						{
						        jQuery(this).dialog('close');
							                                                                                                                
						       document.location.href=window.location.protocol + "//" + window.location.host +"/business/buscategorysearch?country="+a+"&city="+temp[0]+"&scountry="+temp[1]+"&category="+jQuery("#selcategory").val()+"&x=36";
											      
						} 
					}else{
						result=false;			
						jQuery(".ac_input").css("border","1px solid #ff0000");
						jQuery("#error").css('display','inline').css("color","red");
						
								
					}					       
				}                
			});
				},
				Cancel: function() {
					jQuery(this).dialog('close');
				}
			},
			open: function() {
			jQuery("#myselectbox_container").css('display','none');
			jQuery("#create-user").focus();
			jQuery("#ui-dialog-title-dialog").html("&nbsp;Near which city?");
			jQuery("#ui-dialog-title-dialog").css("color","#000000");
			jQuery("#ui-dialog-title-dialog").css("text-align","center");
			
			}


		});
		
		
		jQuery('.category-list a').click(function(e) {			
			//jQuery.scrollTo(jQuery(".category-box"));
			jQuery('#dialog').dialog('open');
			var width = 214;
			var heigth = 200;
			//e.pageX-(width/2)+"px";
			a=e.pageX-(width+70)+"px";
			b=e.pageY-(heigth/2)+"px"; 
			
			jQuery("#selcategory").val(jQuery(this).text());
			//jQuery("#dialog").parent("div").css("top",a);
			//jQuery("#dialog").parent("div").css("left",b);
			//alert(a);
			jQuery('#dialog').parent("div").css({left:a,top:b});
			//alert(a);
			//alert(a);
		})
		.hover(
			function(){ 
				jQuery(this).addClass("ui-state-hover"); 
			},
			function(){ 
				jQuery(this).removeClass("ui-state-hover"); 
			}
		).mousedown(function(){
			jQuery(this).addClass("ui-state-active"); 
		})
		.mouseup(function(){
				jQuery(this).removeClass("ui-state-active");
		});

	});    
    
}

function destroyedu(id)
{
	jQuery("#adduniv").css("display","inline");
    jQuery('#clredu'+id).remove();
    jQuery('#edu'+(id+1)).remove();
    if(id==(eduindex-1)) eduindex--;
	combo--;
	
    if(combo==0) eduindex=0;
    
}
function initialedutext(eindex,tcombo)
{
    eduindex=eindex;
    combo=tcombo;   
}
function addedudetails()
{                                                                 
    if(combo<2)
    {
	if(eduindex==0)
	{
	    jQuery("#edu"+eduindex).after('<ul class="edu" id="edu'+ (eduindex+1)+ '"><li class="university"><label>University</label><div class="txt"><input type="text" class="txt" name="university[]" size="30" value=""/></div><p><strong>e.g.</strong> NYU, UCI, etc</p></li><li class="class"><div class="years"><label>Class</label><select id="univerclass'+ (eduindex+1)+ '" class="years select2" name="universityclass[]"><option value="">Year</option><option value="2012">2012</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option></select></div></li><li class="degree"><label>Degree</label><div class="txt"><input type="text" class="txt" value="" name="degree[]" /></div><p><strong>e.g.</strong> Bachelor of Science, Master etc.</p></li><li class="degree2"><label>Concentration</label><div class="txt"><input type="text" class="txt" value="" name="concentration[]"/></div><p><strong>e.g.</strong> Finance, Software Eng. etc</p></li></ul> <ul class="edu" id="clredu'+eduindex+'"><li style="width:100%"><a class="bt-clear" onclick="return destroyedu(' + eduindex + ');">Remove</a></li></ul>');
	     repSelects('univerclass'+ (eduindex+1));
	}else{
	    jQuery("#clredu"+(eduindex-1)).after('<ul class="edu" id="edu'+ (eduindex+1)+ '"><li class="university"><label>University</label><div class="txt"><input type="text" class="txt" name="university[]" size="30" value=""/></div><p><strong>e.g.</strong> NYU, UCI, etc</p></li><li class="class"><div class="years"><label>Class</label><select id="univerclass'+ (eduindex+1)+ '" class="years select2" name="universityclass[]"><option value="">Year</option><option value="2012">2012</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option></select></div></li><li class="degree"><label>Degree</label><div class="txt"><input type="text" class="txt" value="" name="degree[]" /></div><p><strong>e.g.</strong> Bachelor of Science, Master etc.</p></li><li class="degree2"><label>Concentration</label><div class="txt"><input type="text" class="txt" value="" name="concentration[]"/></div><p><strong>e.g.</strong> Finance, Software Eng. etc</p></li></ul> <ul class="edu" id="clredu'+eduindex+'"><li style="width:100%"> <a class="bt-clear" onclick="return destroyedu(' + eduindex + ');">Remove</a></li></ul>');
	    repSelects('univerclass'+ (eduindex+1));
	    jQuery("#adduniv").css("display","none");
	
	}
	combo++;
	eduindex++;
    }
    jQuery("#optionsDiv8").find("ul").css("height","230px");
	jQuery("#optionsDiv8").find("ul").css("overflow-y","scroll");
	jQuery("#optionsDiv9").find("ul").css("height","230px");
	jQuery("#optionsDiv9").find("ul").css("overflow-y","scroll");
}
function destroypro(id)
{
	jQuery("#addpro").css("display","inline");
    jQuery('#clrpro'+id).remove();
    jQuery('#pro'+(id+1)).remove();
    if(id==(proindex-1)) proindex--;
	procombo--;
	
    if(procombo==0) proindex=0;
    
}
function initialprotext(eindex,tcombo)
{
    proindex=eindex;
    procombo=tcombo;   
}
function addanotherprofession()
{          
    
    if(procombo<2)
    {
	if(proindex==0)
	{
	    jQuery("#pro"+proindex).after('<ul class="edu" id="pro'+ (proindex+1)+ '"><li class="employer"><label>Previous Employer</label><div class="txt"><input type="text" class="txt" name="employee[]" value="" /></div></li><li class="occupation"><label>Occupation</label><div class="txt"><input type="text" class="txt" name="occupation[]" value="" /></div></li><li class="position"><label>Position</label><div class="txt"><input type="text" class="txt" name="position[]" value="" /></div></li></ul><ul id="clrpro'+proindex+'"  class="edu"><li style="width:100%"><a class="bt-clear" onclick="return destroypro(' + proindex + ');">Remove</a></li></ul>');
	    
	}else{
	    jQuery("#clrpro"+(proindex-1)).after('<ul class="edu" id="pro'+ (proindex+1)+ '"><li class="employer"><label>Previous Employer</label><div class="txt"><input type="text" class="txt" name="employee[]" value="" /></div></li><li class="occupation"><label>Occupation</label><div class="txt"><input type="text" class="txt" name="occupation[]" value="" /></div></li><li class="position"><label>Position</label><div class="txt"><input type="text" class="txt" name="position[]" value="" /></div></li></ul><ul id="clrpro'+proindex+'" class="edu"><li style="width:100%"><a class="bt-clear" onclick="return destroypro(' + proindex + ');">Remove</a></li></ul>');
	    jQuery("#addpro").css("display","none");
	}
	procombo++;
	proindex++;
    }
}
jQuery(document).ready(function(){
   jQuery("#myselectbox_input").bind("change",function(){
	alert('zdcszd');
	 jQuery.ajax({
                type: "GET",
                url: "../register/searchcity",
                data: "id=" + jQuery("#country").val(),
                cache: false,                
                success: function(result){
                    var citydata=result.split("\n");              
		    jQuery("#dialog p").html('<input class="dialogcity" type="text" id="'+ jQuery("#country").val() + 'searchfield" name="city"  />');
		    jQuery("#"+ jQuery("#country").val() + "city").autocomplete(citydata);  
                }                
                });   
    });   
    
});
 
   function next(){
    
    jQuery("#current").removeClass("next active");
    jQuery("#current").addClass("next");
   }
   function nact(){
    
    jQuery("#current").removeClass("next");
    jQuery("#current").addClass("next active");
   }
 jQuery(document).ready(function(){
   jQuery("#key").bind("blur",function(){
        if(jQuery('#key').val().replace(/\s/g,'')=="" )
	{
	    jQuery('#key').val("Enter Keywords");
	    jQuery('#key').css('color','#000000');	            
    
	}
	});   
    });   
    
jQuery(document).ready(function(){
   jQuery("#key").bind("focus",function(){
        //alert(jQuery('#key').val());
        if(jQuery('#key').val().replace(/\s/g,'')=="EnterKeywords")
	{
	    jQuery('#key').val(" ");
	    jQuery('#key').css('color','#000000');
	}
        });   
    });   
 
 
 jQuery(document).ready(function(){
   jQuery("#email").bind("blur",function(){
       if(jQuery.trim(jQuery('#email').val())=='')
	jQuery('#email').val("Enter Email Id");
	jQuery('#email').css('color','#000000');	            
                });   
    });   
 jQuery(document).ready(function(){
   jQuery("#email").bind("focus",function(){
	jQuery('#email').val(" ");
	jQuery('#email').css('color','#000000');	            
                });   
    });
 function autotexthide(id,txt)
 {  
 //jQuery("#"+id).css('color','#A0A0A0');
 jQuery(document).ready(function(){
   jQuery("#"+id).bind("blur",function(){ 
      if(isBlank(jQuery("#"+id).val()))
      {	
	jQuery("#"+id).val(jQuery.trim(txt));
	jQuery("#"+id).css('color','#888888');
	//jQuery("#"+id).css('color','#A0A0A0');
	//jQuery("#"+id).css('color','#000000');
        } 
     });	 
    });

  jQuery(document).ready(function(){
     jQuery("#"+id).bind("focus",function(){
        if(jQuery("#"+id).val()==txt)
	{
		jQuery("#"+id).val(" ");
		jQuery("#"+id).css('color','#000000');
	}	            
               }); 
    });
 }
  function trim(str)
  {
    if(!str || typeof str != 'string')
        return null;

    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
  }
  function  forgotpass()
  {
    jQuery.ajax({
	type: "GET",
	url: "login/renewpass",
	data: "id=" + jQuery("#forgotpass").val(),
	cache: false,                
	success: function(result){
	    var citydata=result.split("\n");              
	    jQuery("#dialog p").html('<input class="dialogcity" type="text" id="'+ jQuery("#country").val() + 'searchfield" name="city"  />');
	    jQuery("#"+ jQuery("#country").val() + "city").autocomplete(citydata);  
	}
    });   
  }  
  
jQuery(document).ready(function(){
    image1 = new Image();
    //image1.src = "../images/a.jpg";
//image2 = new Image();
//image2.src = "../images/menu05.gif";
});
function isBlank(A){
	
	if (typeof(A)=="undefined") return false;
	if (A==null) return false;
 	return A.replace(/\s+/g,"").length==0;
}
function validemail(A)
{
	if(A.search(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+$/)==-1)
		return false;
	else
		return true;		
}
function toggle(obj1,obj2) {
	
// jQuery("#id1").append(html);
    var el1 = document.getElementById(obj1);
    var el2 = document.getElementById(obj2);
    el2.style.display = 'none';
    if ( el1.style.display != 'none' ) {
            el1.style.display = 'none';
                                }
    else {
            el1.style.display = '';
         }
}
function validateagain(){
  //  alert("ok");
  var result2= true;
    if(document.step3.cfn.value==""){
	    document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error23').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error23').style.display ="none";
	}
    if(document.step3.cln.value==""){
	   document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error24').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error24').style.display ="none";
	}
    if(document.step3.staddress.value==""){
	   document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error25').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error25').style.display ="none";
	}
    if(document.step3.city.value==""){
	    document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error26').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error26').style.display ="none";
	}
    if(document.step3.zip.value==""){
	   document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error27').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error27').style.display ="none";
	}
    if(jQuery('#lb12').val().match(/^\d{5}$/) == null){
	   document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error28').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error28').style.display ="none";
	}
    if(document.step3.cno.value==""){
	    document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error29').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error29').style.display ="none";
	}
    if(jQuery('#lb13').val().match(/^\d{13,16}$/) == null){
	    document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error30').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error30').style.display ="none";
	}
    if(document.step3.sc.value==""){
	    document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error31').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error31').style.display ="none";
	}
    if(document.step3.cardtype.value==0){
	   document.getElementById('errormsg6').style.display ="block";
	    document.getElementById('error32').style.display ="block";
	    result2 = false;
    }
    else{
	    document.getElementById('error32').style.display ="none";
	}
    var qty=jQuery('#qty').val();
    document.step3.hqty.value=qty;
    var email=document.step3.email.value;
    var fname=document.step3.cfn.value;
    var lname=document.step3.cln.value;
    var staddress=document.step3.staddress.value;
    var city=document.step3.city.value;
    var state=document.step3.state.value;
    var zip=document.step3.zip.value;
    var cno=document.step3.cno.value;
    var year=document.step3.year.value;
    var month=document.step3.month.value;
    if(result2==true){
	document.getElementById('cancelp').style.display ="none";
	document.getElementById('loader').style.display ="block";
	jQuery.ajax({
		type: "post",
		url:window.location.protocol + "//" + window.location.host +"/deal/checkcard",
		data: "email="+email+"&fname="+fname+"&lname="+lname+"&street="+staddress+"&city="+city+"&state="+state+"&zip="+zip+"&cno="+cno+"&year="+year+"&month="+month,
		//alert(data);
		cache: false,                
		success: function(resultn){
			var resulta=resultn.split('+++');
			var resultb=resulta[1].split('+');
			if(resultb[1]!=0){
				document.step3.pid.value=resultb[0];
				document.step3.ppid.value=resultb[1];
				document.step3.spid.value=resultb[2];
				document.step3.submit();
			}
			else{
				document.getElementById('errormsg4').style.display ="block";
				document.getElementById('error33').style.display ="block";
				window.scrollTo(0,0);
				document.getElementById('cancelp').style.display ="block";
				document.getElementById('loader').style.display ="none";
				result2 = false;
				
			}
		}
	});
    }
    else{
	    jQuery.scrollTo("#main-wrapper");
	    return false;
    }
}
function validatecard(){
    var qty=jQuery('#qty').val();
    document.step4.hqty.value=qty;
    var f=0;
    if(document.step4.card.length>1){
	for(var i=0;i<document.step4.card.length;i++){
	    if(document.step4.card[i].checked==true)
		{
		    f=1;
		    break;
		}
	}
    }
    else{
	if(document.step4.card.checked==true)
	    f=1;
    }
    if(f==1)
	return true;
    else{
	alert("Please select a card type");
	return false;
    }
}
function addcardvalidate()
    {
	var r=1;
	if(document.addcard.cfn.value==""){
	    document.getElementById('msg').innerHTML="Please enter first name";
	    document.addcard.cfn.focus();
	    r=0;
	    return false;
	}
	if(document.addcard.cln.value==""){
	    document.getElementById('msg').innerHTML="Please enter last name";
	    document.addcard.cln.focus();
	    r=0;
	    return false;
	}
	if(document.addcard.staddress.value==""){
	    document.getElementById('msg').innerHTML="Please enter address";
	    document.addcard.staddress.focus();
	    r=0;
	    return false;
	}
	if(document.addcard.city.value==""){
	    document.getElementById('msg').innerHTML="Please enter city";
	    document.addcard.city.focus();
	    r=0;
	    return false;
	}
	if(document.addcard.zip.value==""){
	    document.getElementById('msg').innerHTML="Please enter zip";
	    document.addcard.zip.focus();
	    r=0;
	    return false;
	}
	if(jQuery('#pin').val().match(/^\d{5}$/) == null){
	    document.getElementById('msg').innerHTML="Please enter a valid zip code";
	    document.addcard.zip.focus();
	    r=0;
	    return false;
	}
	if(document.addcard.cno.value==""){
	    document.getElementById('msg').innerHTML="Please enter card number";
	    document.addcard.cno.focus();
	    r=0;
	    return false;
	}
	if(jQuery('#cardno').val().match(/^\d{13,16}$/) == null){
	    document.getElementById('msg').innerHTML="Please enter a valid card number";
	    document.addcard.cno.focus();
	    r=0;
	    return false;
	}
	if(document.addcard.sc.value==""){
		document.getElementById('msg').innerHTML="Please enter security code";
		document.addcard.sc.focus();
		r=0;
		return false;
	}
	if(document.addcard.cardtype.value==0){
	    document.getElementById('msg').innerHTML="Please select card type";
	    document.addcard.cardtype.focus();
	    r=0;
	    return false;
	}
	/*if(document.addcard.city.value!=""){
	    var country='USA';
	    // alert(country);
	    var city1=document.addcard.city.value ;
	    var st=document.addcard.state.value ;
	    var city= city1+", "+st ;
	    //alert(city);
	    jQuery.ajax({
		type: "GET",
		url:window.location.protocol + "//" + window.location.host +"/index/checkcity",
		data: "city=" + city+"&country="+country,
		cache: false,                
		success: function(result){
		    if(result==0)                   
			{                      
			    jQuery("#msg").html("Sorry, but we do not recognize that city.");
			    document.addcard.city.focus();
			    r=0;
			    return false;
			}
		}
	    });
	}*/
	var fname=document.addcard.cfn.value;
	var lname=document.addcard.cln.value;
	var staddress=document.addcard.staddress.value;
	var city=document.addcard.city.value;
	var state=document.addcard.state.value;
	var zip=document.addcard.zip.value;
	var cno=document.addcard.cno.value;
	var year=document.addcard.year.value;
	var month=document.addcard.month.value;
	var pid=document.addcard.pid.value;
	if(r==1){
	    document.getElementById('loader').style.display ="block";
	    if(pid!=''){
		jQuery.ajax({
			type: "post",
			url:window.location.protocol + "//" + window.location.host +"/deal/addcardnew",
			data: "pid="+pid+"&fname="+fname+"&lname="+lname+"&street="+staddress+"&city="+city+"&state="+state+"&zip="+zip+"&cno="+cno+"&year="+year+"&month="+month,
			//alert(data);
			cache: false,                
			success: function(result){
				//alert(result);
				var resulta=result.split('+++');
				//alert(resulta[1]);
				if(resulta[1]!=0){
					document.addcard.ppid.value=resulta[1];
					document.addcard.submit();
				}
				else{
					document.getElementById('loader').style.display ="none";
					jQuery("#msg").html("Billing information is invalid.Please check and try again.");
					document.addcard.cno.focus();
					return false;
				}
			}
		});
	    }
	    else{
		var email=document.addcard.email.value;
		jQuery.ajax({
		    type: "post",
		    url:window.location.protocol + "//" + window.location.host +"/deal/checkcard",
		    data: "email="+email+"&fname="+fname+"&lname="+lname+"&street="+staddress+"&city="+city+"&state="+state+"&zip="+zip+"&cno="+cno+"&year="+year+"&month="+month,
		    //alert(data);
		    cache: false,                
		    success: function(resultn){
			    var resulta=resultn.split('+++');
			    //alert(resulta[1]);
			    var resultb=resulta[1].split('+');
			    if(resultb[1]!=0){
				    document.addcard.pid.value=resultb[0];
				    document.addcard.ppid.value=resultb[1];
				    document.addcard.spid.value=resultb[2];
				    document.addcard.submit();
			    }
			    else{
				    document.getElementById('loader').style.display ="none";
				    jQuery("#msg").html("Billing information is invalid.Please check and try again.");
				    document.addcard.cno.focus();
				    return false;
			    }
		    }
		});
	    }
	}
    }
function editcardvalidate()
    {
	if(document.editcard.fname.value==""){
		document.getElementById('msg').innerHTML="Please enter first name";
		document.editcard.fname.focus();
		return false;
	}
	if(document.editcard.lname.value==""){
		document.getElementById('msg').innerHTML="Please enter last name";
		document.editcard.lname.focus();
		return false;
	}
	if(document.editcard.staddress.value==""){
		document.getElementById('msg').innerHTML="Please enter street address";
		document.editcard.staddress.focus();
		return false;
	}
	if(document.editcard.city.value==""){
		document.getElementById('msg').innerHTML="Please enter city";
		document.editcard.city.focus();
		return false;
	}
	if(document.editcard.zip.value==""){
		document.getElementById('msg').innerHTML="Please enter Zip Code";
		document.editcard.zip.focus();
		return false;
	}
	if(jQuery('#pin').val().match(/^\d{5}$/) == null){
		document.getElementById('msg').innerHTML="Please enter a valid zip code";
		document.editcard.zip.focus();
		return false;
	}
	if(document.editcard.city.value!=""){
	    var country='USA';
	    // alert(country);
	    var city1=document.editcard.city.value ;
	    var st=document.editcard.state.value ;
	    var city= city1+", "+st ;
	    //alert(city);
	    jQuery.ajax({
		type: "GET",
		url:window.location.protocol + "//" + window.location.host +"/index/checkcity",
		data: "city=" + city+"&country="+country,
		cache: false,                
		success: function(result){
		    if(result==0)                   
			{                      
			    jQuery("#msg").html("Sorry, but we do not recognize that city.");
			    document.editcard.city.focus();
			    return false;
			
			}
		    else
			{
			    document.editcard.submit();
			}
		}
	    });
	}
    }
/* --------------------------------- added by shiv ---------------------------------------- */
function CreateCouponValidation(cost_per_print, trial)
{	
	var flag=true;
	var flag_monthly_budget=true;
	var flag_cost_per_print=true;
	var msg= document.getElementById('msg');
	msg.innerHTML='<p style="padding-top: 5px; margin:0px; font-size: 15px; font-weight: bold;">The following fields are required:</p>';

	if(document.frm_coupon.discount_summary.value=="")
	{
		msg.innerHTML+="Coupon Summary<br />";
		flag=false;
    	}
	if(document.frm_coupon.percent_discount.value=="")
	{
		msg.innerHTML+="Discount<br />";
		flag=false;
    	}

    	if(document.frm_coupon.percent_discount.value!="")
	{
		if(document.frm_coupon.percent_discount.value.match(/^[-+]?\d{1,4}(\.\d{1,2})?$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Discount<br />";
		flag=false;
		}
    	}

    	if(document.frm_coupon.description.value=="")
	{
		msg.innerHTML+="Coupon Fine Print<br />";
		flag=false;
    	}
	if(document.frm_coupon.description.value.length >500)
	{
		msg.innerHTML+="Coupon Fine Print should be less then 500 character <br />";
		flag=false;
    	}
	
    	if(document.frm_coupon.ex_mm.value=="")
	{
		msg.innerHTML+="Fine Print Expiration Month<br />";
		flag=false;
    	}
    	if(document.frm_coupon.ex_dd.value=="")
	{
		msg.innerHTML+="Fine Print Expiration Day<br />";
		flag=false;
    	}
    	if(document.frm_coupon.ex_yy.value=="")
	{
		msg.innerHTML+="Fine Print Expiration Year<br />";
		flag=false;
    	}
	//--------
    	if(document.frm_coupon.ex_mm.value!="")
	{
		if(document.frm_coupon.ex_mm.value.match(/^\d{1,2}$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Month<br />";
		flag=false;
		}
		else 
		{
			if(document.frm_coupon.ex_mm.value>12)
			{
				msg.innerHTML+="Please make sure to provide a valid Month<br />";
				flag=false;
			}
		}
    	}
    	if(document.frm_coupon.ex_dd.value!="")
	{
		if(document.frm_coupon.ex_dd.value.match(/^\d{1,2}$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Day<br />";
		flag=false;
		}
		else 
		{
			if(document.frm_coupon.ex_dd.value>31)
			{
				msg.innerHTML+="Please make sure to provide a valid Day<br />";
				flag=false;
			}
		}
    	}
    if(document.frm_coupon.ex_yy.value!="")
	{
		if(document.frm_coupon.ex_yy.value.match(/^\d{4}$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Year<br />";
		flag=false;
		}
    }
	//end----------------


	if(document.frm_coupon.monthly_budget.value=="")
	{
		msg.innerHTML+="Monthly Budget<br />";
		flag_monthly_budget=false;
		flag=false;
    }
    if(document.frm_coupon.cost_per_print.value=="")
	{
		msg.innerHTML+="Bid Price<br />";
		flag_cost_per_print=false;
		flag=false;
    }
		
    if(document.getElementById('rad_img').value=="")
	{
		msg.innerHTML+="Photo<br />";
		flag=false;
	}
	
	if(document.frm_coupon.monthly_budget.value!="")
	{
		if(document.frm_coupon.monthly_budget.value.match(/^[-+]?\d{1,4}(\.\d{1,2})?$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Monthly Budget<br />";
		flag_monthly_budget=false;
		flag=false;
		}
    }

    if(document.frm_coupon.cost_per_print.value!="")
	{
		if(document.frm_coupon.cost_per_print.value.match(/^[-+]?\d{1,4}(\.\d{1,2})?$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Bid Price<br />";
		flag_cost_per_print=false;
		flag=false;
		}
    }
		
	if((flag_monthly_budget==true) && (document.frm_coupon.monthly_budget.value < cost_per_print) && (trial==0))
	{
		msg.innerHTML+="Please provide a higher monthly budget<br />";
		flag=false;
	}

	if((flag_monthly_budget==true) && (document.frm_coupon.cost_per_print.value < cost_per_print) && (trial==0))
	{
		msg.innerHTML+="Please provide a higher bid price<br />";
		flag=false;
	}

	
	if(flag==false)
		return false;
}

function EditCouponValidation(cost_per_print, trial)
{	
	var flag=true;
	var flag_monthly_budget=true;
	var flag_cost_per_print=true;
	var msg= document.getElementById('msg');
	msg.innerHTML='<p style="padding-top: 5px; margin:0px; font-size: 15px; font-weight: bold;">The following fields are required:</p>';

	if(document.frm_coupon.discount_summary.value=="")
	{
		msg.innerHTML+="Coupon Summary<br />";
		flag=false;
    	}
	if(document.frm_coupon.percent_discount.value=="")
	{
		msg.innerHTML+="Discount<br />";
		flag=false;
    	}

    	if(document.frm_coupon.percent_discount.value!="")
	{
		if(document.frm_coupon.percent_discount.value.match(/^[-+]?\d{1,4}(\.\d{1,2})?$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Discount<br />";
		flag=false;
		}
    	}

    	if(document.frm_coupon.description.value=="")
	{
		msg.innerHTML+="Coupon Fine Print<br />";
		flag=false;
    	}
	if(document.frm_coupon.description.value.length > 500)
	{
		msg.innerHTML+="Coupon Fine Print should be less then 500 character <br />";
		flag=false;
    	}
		
    	if(document.frm_coupon.ex_mm.value=="")
	{
		msg.innerHTML+="Fine Print Expiration Month<br />";
		flag=false;
    	}
    	if(document.frm_coupon.ex_dd.value=="")
	{
		msg.innerHTML+="Fine Print Expiration Day<br />";
		flag=false;
    	}
    	if(document.frm_coupon.ex_yy.value=="")
	{
		msg.innerHTML+="Fine Print Expiration Year<br />";
		flag=false;
    	}
	//--------
    	if(document.frm_coupon.ex_mm.value!="")
		{
			if(document.frm_coupon.ex_mm.value.match(/^\d{1,2}$/) == null){
			msg.innerHTML+="Please make sure to provide a valid Month<br />";
			flag=false;
		}
		else 
		{
			if(document.frm_coupon.ex_mm.value>12)
			{
				msg.innerHTML+="Please make sure to provide a valid Month<br />";
				flag=false;
			}
		}
    	}
    	if(document.frm_coupon.ex_dd.value!="")
		{
			if(document.frm_coupon.ex_dd.value.match(/^\d{1,2}$/) == null){
			msg.innerHTML+="Please make sure to provide a valid Day<br />";
			flag=false;
			}
			else 
			{
				if(document.frm_coupon.ex_dd.value>31)
				{
					msg.innerHTML+="Please make sure to provide a valid Day<br />";
					flag=false;
				}
			}
    	}
    if(document.frm_coupon.ex_yy.value!="")
	{
		if(document.frm_coupon.ex_yy.value.match(/^\d{4}$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Year<br />";
		flag=false;
		}
    }
	//end----------------


	if(document.frm_coupon.monthly_budget.value=="")
	{
		msg.innerHTML+="Monthly Budget<br />";
		flag_monthly_budget=false;
		flag=false;
    }
    if(document.frm_coupon.cost_per_print.value=="")
	{
		msg.innerHTML+="Bid Price<br />";
		flag_cost_per_print=false;
		flag=false;
    }
		
    if(document.getElementById('rad_img').value=="" && document.getElementById('old_img').value=="")
	{
		msg.innerHTML+="Photo<br />";
		flag=false;
	}
	
	if(document.frm_coupon.monthly_budget.value!="")
	{
		if(document.frm_coupon.monthly_budget.value.match(/^[-+]?\d{1,4}(\.\d{1,2})?$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Monthly Budget<br />";
		flag_monthly_budget=false;
		flag=false;
		}
    }

    if(document.frm_coupon.cost_per_print.value!="")
	{
		if(document.frm_coupon.cost_per_print.value.match(/^[-+]?\d{1,4}(\.\d{1,2})?$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Bid Price<br />";
		flag_cost_per_print=false;
		flag=false;
		}
    }
		
	if((flag_monthly_budget==true) && (document.frm_coupon.monthly_budget.value < cost_per_print) && (trial==0))
	{
		msg.innerHTML+="Please provide a higher monthly budget<br />";
		flag=false;
	}

	if((flag_monthly_budget==true) && (document.frm_coupon.cost_per_print.value < cost_per_print) && (trial==0))
	{
		msg.innerHTML+="Please provide a higher bid price<br />";
		flag=false;
	}
	if(flag==false)
		return false;
}
function ContactUsValidation()
{	
	var flag=true;
	var msg= document.getElementById('msgcontact');
	msg.innerHTML='<p style="padding-top: 5px; margin:0px; font-size: 15px; font-weight: bold;">The following fields are required:</p>';
	if(document.frm_contactus.business_name.value=="")
	{
		msg.innerHTML+="Business Name<br />";
		flag=false;
    }
	if(document.frm_contactus.location_name.value=="")
	{
		msg.innerHTML+="Loaction<br />";
		flag=false;
    }
	if(document.frm_contactus.contact_number.value=="")
	{
		msg.innerHTML+="Contact Number<br />";
		flag=false;
    }
	if(document.frm_contactus.contact_number.value!="")
	{

		if(document.frm_contactus.contact_number.value.match(/^\d{7,14}$/) == null){
		msg.innerHTML+="Please make sure to provide a valid contact number (without dashes or spaces)<br />";
		flag=false;
		}
    }
	if(document.frm_contactus.email2.value=="")
	{
		msg.innerHTML+="Email Address<br />";
		flag=false;
    }
	if(document.frm_contactus.email2.value!="")
	{
		if(document.frm_contactus.email2.value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Email Address<br />";
		flag=false;
		}
    }
	
	/*if(document.frm_contactus.website.value!="")
	{
		if(document.frm_contactus.website.value.match(/http://|)(www\.)?([^\.]+)\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/) == null){
		msg.innerHTML+="Please make sure to provide a valid web site<br />";
		flag=false;
		}
    }*/
	if(flag==false)
	{
		document.getElementById('msgcontact').style.display="block";
	}
	else
	{	
		document.getElementById('msgcontact').style.display="none";
		onSuccess();
	}
	return false;	
	
}
function EmailValidation()
{
	var flag=true;
	var msg = document.getElementById('msg');
	
	if(document.frm_email.email.value=="")
	{
		msg.innerHTML='<p style="margin:0px; font-size: 15px; font-weight: bold;">The following fields are required:</p>';
		msg.innerHTML+="Email Address<br />";
		flag=false;
    	}
	if(document.frm_email.email.value!="")
	{
		if(document.frm_email.email.value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,5})+$/) == null){
		msg.innerHTML+="Please make sure to provide a valid Email Address<br />";
		flag=false;
		}
    	}

	if(flag==false)
	{
		document.getElementById('msg').style.display="block";
		return false;
	}
}

