

function showPropertyDetail1(section,ev)
{
	if(section=='propInfo'){		//--login		
		document.getElementById('docContainer1').style.display="none";
		document.getElementById('propInfoContainer1').style.display="";
		document.getElementById('propTab1').className="active";
		document.getElementById('docTab1').className="deactive";
		
		parent.window.document.getElementById('TB_iframeContent').style.height="250px";
		parent.window.document.getElementById('TB_iframeContent').style.width="573px";
		
	}else{
		document.getElementById('docContainer1').style.display="";
		document.getElementById('propInfoContainer1').style.display="none";
		parent.window.document.getElementById('TB_iframeContent').style.height="470px";
		parent.window.document.getElementById('TB_iframeContent').style.width="573px";
	}
}


function showAlertPopup_index(event)
{
  var rad_val='allAssetType';
  var isLoggedIn=0;
  if(parent.document.getElementById('loggedIn'))
	isLoggedIn=parent.document.getElementById('loggedIn').value;
	
 //alert(isLoggedIn);
  if(isLoggedIn==1){
	openPopupAlert('1');
  }else{
	 
	tb_show("",SITE_PATH_SSL+"component/alertLoginBox.inc.php?flag=index&height=370&width=560&TB_iframe=true","");	

  }
}


function showAlertPopup(event)
{
	
	var userId = document.getElementById('userId').value;	
	var firstName = document.getElementById('firstName').value;
	var height='360';
	var width='553';
	if(userId!="")	 //---- if user logged-in
	{  
	countAlertwithoutthickbox();		
	}
	else if(userId=="")	 //---- if user not logged-in
	{		
      var param=getparamsAlert();	
	  var paramstr="";
		if(event==true)
		{	var height='370';
			width='500';
	 	 param+="&noResult=true";       
      	 paramstr = getparams().split("|");	
		 paramstr[1] = paramstr[1].replace(/\"/g, 'doubleComma');		
		 paramstr[1] = paramstr[1].replace(/\'/g, 'astorp');	
		 paramstr[1] = paramstr[1].replace(/\,/g, 'singleComma');	
		 paramstr=paramstr[1];
		}
		else if(event=='signup')
		{
        height='480';
		param+="&changeHeight=true";
		}
		
		tb_show("",SITE_PATH_SSL+"component/alertLoginBox.inc.php?"+param+"&paramLists="+paramstr+"&height="+height+"&width="+width+"&TB_iframe=true","");
		//tb_show("",SITE_PATH_SSL+"component/alertLoginBox.inc_new.php?"+param+"&height=480&width=590&TB_iframe=true","");
	}
}

function validateLoginAlert(evt)
{	
	
	if(evt!=undefined)
	{
	  var evt = (evt) ? evt : event
	  var charCode = (evt.which) ? evt.which : evt.keyCode
	  
	  if (charCode != 13)
	   {
		   return false ;
       }
	
    }
	
    var MasterString="Sorry, we cannot complete your request. Kindly provide us the missing or incorrect information enclosed below.\n\n";
    var flag=false;
    var visitor="";

    if (document.alertform.loginemail1.value=='') 
    {    
		  visitor +=  "\n- Please enter valid email address.";
		  document.getElementById('loginemail1').style.backgroundColor='#F9F3C1';
    }
    else
    {
		  document.getElementById('loginemail1').style.backgroundColor='';
    }

    if(document.alertform.loginpassword1.value==""){   visitor +=  "\n- Please enter password."; 
	    document.getElementById('loginpassword1').style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.getElementById('loginpassword1').style.backgroundColor='';
    }
        
    if(visitor!="")
    {
      MasterString=MasterString + visitor;
      flag=true;
    }
    if(flag==true)
    {
      alert(MasterString);
      return false;
    }
	else
	{
		checkUserExistsAlert();
	}
}


function checkUserExistsAlert()
{
	var email  = document.alertform.loginemail1.value;
	var pwd    = document.alertform.loginpassword1.value;	
	var flag   = document.alertform.flag.value;
	var path;
	path=AJAX_PATH ;
	var sendparam='';
	sendparam = "action=checkuserexists&useremail="+email+"&userpwd="+pwd;
	$.ajax({
		 type: "POST",
		 url: path+"ajax/emailalert_ajaxNew.php",
		 async: true,
		 global: false,
		 data: sendparam,
		 success: function(result)
		 {
		 		  var res = result.split("|");
                                  res[0]=res[0].replace(/^\s+|\s+$/g, '');  
        	
		  if(res[0]=="ERROR")
			{
				alert(res[1]);	
				document.getElementById('loginemail1').style.backgroundColor='#F9F3C1';
				document.getElementById('loginpassword1').style.backgroundColor='#F9F3C1';
				//$("#loginerr1").show();
				//$("#loginerr1").html(res[1]);
			}
			else if(flag=='index' && res[0] !="ERROR")
            {
				if(res[3]>=20)
				{
					window.open('create-max-alert.php','alert','width=400,height=160,scrollbars=yes,screenX=150'); 
				}
				else
				{
					window.parent.location=SITE_PATH+"index.php?alertFlag=1";
					return ;
				}
            }
            else
			{
			  if(res[3]>=20)
			  {
				window.parent.location=document.getElementById('failUrl').value;

			  }
			  else
			  {
			 
				createAlertAlert(res[1]); //---- firstname
			  }
			}
		 }

	});	
}


function createAlertAlert(firstname)
{
	var paramsList = document.getElementById('params').value;
	paramsList += "&action=savealerts";
	$.ajax({
		 type: "POST",
		 url: AJAX_PATH+"ajax/emailalert_ajax.php",
		 async: true,
		 global: false,
		 data: paramsList,
		 success: function(result){
			var alertresp= result.split("|");
			window.parent.location=document.getElementById('successUrl').value;
		}
	});	
}

function openSuccessALert()
{

	var  alertSuccessUrl='';
	var alertUrl=document.getElementById('alertSuccessUrl').value;
	if(alertUrl.search("-alert-confirmed-2")!=-1)
	{
		alertSuccessUrl=alertUrl.replace("-alert-confirmed-2","");
	}
	else if(alertUrl.search("-alert-confirmed-1")!=-1)
	{
		alertSuccessUrl=alertUrl.replace("-alert-confirmed-2","");
	}
	else if(alertUrl.search("-alert-fail")!=-1)
	{
		alertSuccessUrl=alertUrl.replace("-alert-fail","");
	}
	
	var param=getparamsAlert();	 

	
	parent.document.getElementById('alertSuccess').innerHTML='<iframe name="FRAME1" src="'+SITE_PATH+'component/auction-search-alert-confirmed-1.php?'+param+'&alertSuccessUrl='+alertSuccessUrl+'" width="380" height="130" frameborder="0" scrolling="no"></iframe>';
	parent.document.getElementById('alertSuccess').style.left=263+'px';
	parent.document.getElementById('alertSuccess').style.top=190+'px';
	
	parent.document.getElementById('alertSuccess').style.display='block';
}

function getCoordinates(e)
{
	if (typeof window.event != "undefined")
	{
		 xcoord=event.clientX;
		 ycoord=event.clientY;
	}
	else
	{
		xcoord=e.pageX;
		ycoord=e.pageY;
	}	
	var x = xcoord - 10+"px";
	var y = ycoord+"px";
	return x+"|"+y;
}

function closediv(divid)
{
	$("#"+divid).hide();
}


function validateSignupALert(evt)
{
	if(evt!=undefined)
	{
		var evt = (evt) ? evt : event
		var charCode = (evt.which) ? evt.which : evt.keyCode
		if (charCode != 13)
		{
			return false ;
		}	
    }

    var MasterString="Sorry, we cannot complete your request. Kindly provide us the missing or incorrect information enclosed below.\n\n";
    var flag=false;
    var visitor="";

    if (document.alertform.firstName12.value=='') 
    {    
		visitor +=  "\n- Please enter firstname .";
		document.getElementById('firstName12').style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.getElementById('firstName12').style.backgroundColor='';
    }

	if (document.alertform.lastName1.value=='') 
    {    
		  visitor +=  "\n- Please enter last name .";
		  document.getElementById('lastName1').style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.getElementById('lastName1').style.backgroundColor='';
    }	

	if (document.alertform.email11.value=='') 
    {    
		visitor +=  "\n- Please enter  email address.";
		document.getElementById('email11').style.backgroundColor='#F9F3C1';
    }
	else if(!IsEmailAddress_Popup(document.alertform.email11.value,''))
	{
		visitor +=  "\n- Please enter valid email address.";
		document.getElementById('email11').style.backgroundColor='#F9F3C1';
	}
    else
    {
		document.getElementById('email11').style.backgroundColor='';
    }

    if(document.alertform.password11.value=="")
	{  
		visitor +=  "\n- Please enter password."; 
	    document.getElementById('password11').style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.getElementById('password11').style.backgroundColor='';
    }

	if(document.alertform.password11.value!="")
	{
		if(document.alertform.password11.value.length < 8)
		{
			visitor +=  "\n- Please should be min. 8 characters long."; 
		    document.getElementById('password11').style.backgroundColor='#F9F3C1';
		}
	    else
		{
			document.getElementById('password11').style.backgroundColor='';
	    }
	}

	if(document.alertform.imagecode1.value=="")
	{  
		visitor +=  "\n- Please enter verification code."; 
	    document.getElementById('imagecode1').style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.getElementById('imagecode1').style.backgroundColor='';
    }
        
    if(visitor!="")
    {
      MasterString=MasterString + visitor;
      flag=true;
    }
    if(flag==true)
    {
     alert(MasterString);
      return false;
    }
	else
	{
		verifysignUpAlert();
	}
}


function validateSignupALertOnCreate(alertform)
{
    var MasterString="Sorry, we cannot complete your request. Kindly provide us the missing or incorrect information enclosed below.\n\n";
    var flag=false;
    var visitor="";
  

    if (document.alertform.firstName12.value=='') 
    {
		visitor +=  "\n- Please enter firstname .";
		
		document.alertform.firstName12.style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.alertform.firstName12.style.backgroundColor='';
    }

	if (document.alertform.lastName1.value=='') 
    {    
		visitor +=  "\n- Please enter last name .";
		document.alertform.lastName1.style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.alertform.lastName1.style.backgroundColor='';
    }	
	
	if (document.alertform.email11.value=='') 
    {    
		visitor +=  "\n- Please enter  email address.";
		document.alertform.email11.style.backgroundColor='#F9F3C1';
    }
	else if(!IsEmailAddress_Popup(document.alertform.email11.value,''))
	{
		visitor +=  "\n- Please enter valid email address.";
		document.alertform.email11.style.backgroundColor='#F9F3C1';
	}
    else
    {
		document.alertform.email11.style.backgroundColor='';
    }

    if(document.alertform.password11.value=="")
	{  
		visitor +=  "\n- Please enter password."; 
	    document.alertform.password11.style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.alertform.password11.style.backgroundColor='';
    }

	if(document.alertform.password11.value!="")
	{
		if(document.alertform.password11.value.length < 8)
		{
			visitor +=  "\n- Password should be min. 8 characters long."; 
			document.alertform.password11.style.backgroundColor='#F9F3C1';
		}
	    else
		{
			document.alertform.password11.style.backgroundColor='';
	    }
	}
  
	/*if(document.alertform.zipPostalCode.value=="")
	{
	    visitor +=  "\n- Please enter zip code."; 
	    document.alertform.zipPostalCode.style.backgroundColor='#F9F3C1';
    }
	else if(isNaN(document.alertform.zipPostalCode.value)==true || document.alertform.zipPostalCode.length>5)
	{
       visitor +=  "\n- Please enter valid zip code."; 
	    document.alertform.zipPostalCode.style.backgroundColor='#F9F3C1';
	}
    else
    {
		document.alertform.zipPostalCode.style.backgroundColor='';
    } */


	if(document.alertform.imagecode1.value=="")
	{  
		visitor +=  "\n- Please enter verification code."; 	
		
		document.alertform.imagecode1.style.backgroundColor='#F9F3C1';
    }
    else
    {
		document.alertform.imagecode1.style.backgroundColor='';
    }
        
    if(visitor!="")
    {
		MasterString=MasterString + visitor;
		flag=true;
    }
    if(flag==true)
    {
		alert(MasterString);
		return false;
    }
	else
	{
		verifysignUpAlert();
	}
}

//function for Email Checking on popup
//Browser checking
var isNav, isIE;
if(parseInt(navigator.appVersion)>=4)
   {
   if(navigator.appName=="Netscape") {
      isNav=true;
   }
   else {
      isIE=true;
      var ieall="all.";
    var sty=".style";
    }
   }
     
function IsEmailAddress_Popup(objEmail,strErrorMesg) {
        var blnIsEmailAddress = true; 
  var blnObjectPrm=false;
  var i=0;  
  var strEmail='';
  var objThis;

  if (isIE)
    blnObjectPrm = (typeof(objEmail)=='object'?true:false) ; 

  if (blnObjectPrm) {
    objThis = objEmail;
    strEmail=objEmail.value;
  }
  else {
    if (objEmail.substring(0,8)=='document') {
      objThis =eval(objEmail); 
      strEmail=objThis.value;
      blnObjectPrm = true; 
    }
    else
      strEmail=objEmail;
  }

  
//blnIsEmailAddress=(strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!=-1);
blnIsEmailAddress=(strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.([A-Za-z]{2,4})$/)!=-1);
  if (!blnIsEmailAddress && strErrorMesg!='') {
    //alert(strErrorMesg);
    if (blnObjectPrm) {
      //objThis.select();
      objThis.focus();    
    }
  }
  return blnIsEmailAddress;
}


function verifysignUpAlert()
{
	
    
	var firstName = document.alertform.firstName12.value; 
	var lastName  = document.alertform.lastName1.value;	
	var email1 = document.alertform.email11.value;
	var password1  = document.alertform.password11.value;	
	var imagecode = document.alertform.imagecode1.value;
	var flag   = document.alertform.flag.value;
	
	var path;
	path=SITE_PATH_SSL
	var sendparam='';
	sendparam = "action=verifysignup&firstName="+firstName+"&lastName="+lastName+"&email1="+email1+
	"&password1="+password1+"&imagecode="+imagecode;
	
	$.ajax({
		 type: "POST",
		 url: path+"ajax/emailalert_ajaxNew.php",
		 async: true,
		 global: false,
		 data: sendparam,
		 success: function(result){
		
			 
		   var res = result.split("|");
	
		

		   if(flag=='index' && res[0] =="ERROR")
		   {
				
				$("#signuperr1").show();
				$("#signuperr1").html(res[1]);
				
			}
			else if(res[0]=="ERROR")
			{
				
				//parent.window.document.getElementById('TB_iframeContent').style.height="490px";
				//parent.window.document.getElementById('TB_iframeContent').style.width="553px";
				$("#signuperr1").show();
				$("#signuperr1").html(res[1]);
				alert(res[1]);
				
			}
			else
			{
				if(flag=="index")
				{
					window.parent.location=SITE_PATH+"index.php?alertFlag=1";
					return ;
				}
				else
				{ 
					createAlertAlert(firstName);
				}  
			}
		 }
	});
}

function get_radio_value(id)
{
	var rad_val='';
	for (var i=1; i <= 6; i++)
   {
	   if(document.getElementById(id+i))
	   {
		   if(document.getElementById(id+i).checked)
		  {
			rad_val = document.getElementById(id+i).value;
			break;
		  }
	   }
	  
   }
   if(document.getElementById(id))
   {
	   rad_val=document.getElementById(id).value;
   }
   if(rad_val=='')
   {
		rad_val='allAssetType';
   }
   return rad_val;
}



function getparamsAlert()
{
	var params="";	
	var paramstr="";
	///------common------//
	
	
	
	var auctionType=$("#auctionType").attr("value");
	{
		auctionType=get_radio_value('auctionType');
		params="auctionType="+auctionType;
		var aType='Any Type';
		if(auctionType=='residential') aType='Residential';
		else if(auctionType=='commercial') aType='Commercial';
		else if(auctionType=='notes') aType='Notes';
		else if(auctionType=='land') aType='Land';
		else if(auctionType=='allAssetType') aType='Any Type';
		paramstr=aType.toUpperCase();
	}
	
	var propertyState=$("#auctionState").attr("value");
	if(propertyState!=undefined && propertyState!=''){
		params+="&propertyState="+propertyState;
		paramstr+=" , "+propertyState;
	}
	//alert(propertyState);	
	
	
	var propertyCounty=$("#countyName").attr("value");
    if(propertyCounty!=undefined && propertyCounty!=''){
	    params+="&propertyCounty="+propertyCounty;
		paramstr+=" , "+propertyCounty;
    }

	
	var cityVal=$("#cityName").attr("value");
	if(cityVal!=undefined && cityVal!=''){
		params+="&cityVal="+cityVal;
		paramstr+=" , "+cityVal;
	}

	///------residential ------//

	var propertyZip=$("#propertyZip").attr("value");
	if(propertyZip!=undefined && propertyZip!=''){
		params+="&propertyZip="+propertyZip;
		paramstr+=" , "+propertyZip;
	}

	var assetsWithin=$("#srchdist").attr("value");
	if(assetsWithin!=undefined && assetsWithin!='Location' && assetsWithin!=''){
		params+="&assetsWithin="+assetsWithin;
		
		if($('#srchdist option:selected').text()!='Location')
			paramstr+=" , Assets Within "+$('#srchdist option:selected').text();
	}

	var propertyAddress=$("#propertyAddress").attr("value");
	if(propertyAddress!=undefined && propertyAddress!='' && propertyAddress!='Enter Address'){
		params+="&propertyAddress="+propertyAddress;
		paramstr+=" , Address "+propertyAddress;
	}
///////////////////////////////
 
	var minbed=$("span#minbed").html();
	if(minbed!=undefined && minbed!='')
	{
		params+="&minbed="+minbed;
		paramstr+=" ,Bed from "+minbed;
	
	}
 	
	
	var maxbed=$("span#maxbed").html();
	if(maxbed!=undefined && maxbed!=''){
		params+="&maxbed="+maxbed;
		paramstr+=" to "+maxbed;
		
	}
	
	

	var minbath=$("span#minbath").html();
	if(minbath!=undefined && minbath!=''){
		params+="&minbath="+minbath;
		paramstr+=" bath from  "+minbath;
	
	}
	
	
    var maxbath=$("span#maxbath").html();
	if(maxbath!=undefined && maxbath!='')
	{
		params+="&maxbath="+maxbath;
		paramstr+=" to "+maxbath;
	}
	
////////////////////////////////////
	var hiddenMinPrice=$("#minPrice").attr("value");
	
	if(hiddenMinPrice!=undefined && hiddenMinPrice!=''  && hiddenMinPrice!='Min'){
		params+="&hiddenMinPrice="+hiddenMinPrice;
		paramstr+=" , Previously Valued from $"+hiddenMinPrice;
	}

	var hiddenMaxPrice=$("#maxPrice").attr("value");
	if(hiddenMaxPrice!=undefined  && hiddenMaxPrice!=''  && hiddenMaxPrice!='Max'){
		params+="&hiddenMaxPrice="+hiddenMaxPrice;
		paramstr+="-"+hiddenMaxPrice;
	}

	

	var area=$("#area").attr("value");
	if(area!=undefined && area!=''){
		params+="&area="+area;
		paramstr+=" -"+area;
		paramstr+=" sq. ft.";
	}

	var minYearBuilt=$("#YearBuilt").attr("value");
	var yrbuilt=0;
	if(minYearBuilt!=undefined && minYearBuilt!='' && minYearBuilt!='Min Yr'){
		params+="&YearBuilt="+minYearBuilt;
		paramstr+=" , "+minYearBuilt;
		yrbuilt=1;
	}


	if(auctionType=='residential') 
	{	if(minYearBuilt!="" &&  yrbuilt==1)
		{
			paramstr+=" year built";
		}
	}



	if(auctionType=='residential') 
	{
		var proptotal=Array();
		var jj=0;
		var pt = document.getElementsByName('propertyType[]');
	
		for(var i=0; i < pt.length; i++){
			if(pt[i].checked){
				proptotal[jj]=pt[i].value;
				jj++;
			}
		}
	  
		var propertyType=proptotal.join(",");			
		if(propertyType!="")
		{
			params+="&propertyType="+propertyType; 
			paramstr+=" , Property Type "+propertyType;
		}
		
	}
	else if(auctionType=='commercial')
	{
		
		var proptotal=Array();
		var proptotalTxt=Array();
		var jj=0;
		var pt = document.getElementsByName('propertyType[]');
	
		for(var i=0; i < pt.length; i++)
		{
			if(pt[i].checked)
			{
				proptotal[jj]=pt[i].value;
				
				proptotalTxt[jj]=document.getElementById('propertyType'+pt[i].value).value;		<!--don't change this line-->
				
				jj++;
			}
		}
	  
		var propertyType=proptotal.join(",");	
		var propertyTypeTxt=proptotalTxt.join(",");	
	
		if(propertyType!="")
		{
			params+="&propertyType="+propertyType; 
			paramstr+=" , Property Type "+propertyTypeTxt;
		}		
	}
        else if(auctionType=='notes')
	{
		
		var proptotal=Array();
		var proptotalTxt=Array();
		var jj=0;
		var pt = document.getElementsByName('propertyType[]');
	
		for(var i=0; i < pt.length; i++)
		{
			if(pt[i].checked)
			{
				proptotal[jj]=pt[i].value;
				
				proptotalTxt[jj]=document.getElementById('propertyType'+pt[i].value).value;		<!--don't change this line-->
				
				jj++;
			}
		}
	  
		var propertyType=proptotal.join(",");	
		var propertyTypeTxt=proptotalTxt.join(",");	
	
		if(propertyType!="")
		{
			params+="&propertyType="+propertyType; 
			paramstr+=" , Property Type "+propertyTypeTxt;
		}		
	}
		
	var venueCode=$("#venueCode").attr("value");
	if(venueCode!=undefined && venueCode!=''){
		params+="&venueCode="+venueCode;
		paramstr+=" , Venue Code "+venueCode;
	}

	var propertyID=$("#propertyID").attr("value");
	if(propertyID!=undefined && propertyID!=''){
		params+="&propertyID="+propertyID;
		paramstr+=" , Property Id "+propertyID;
	}

	var country=$("#country").attr("value");	
	country = 'US';
	if(country!=undefined && country!=''){
		params+="&country="+country;
		//paramstr+=" , "+country;
	}
	
	

	///------notes------//

	var geoRegion=$("#geoRegion").attr("value");
	if(geoRegion!=undefined){
	   params+="&geoRegion="+geoRegion;
	   paramstr+=" , Geo Region "+$('#geoRegion option:selected').text(); 
	}

	var loanStatus=$("#loanStatus").attr("value");
	if(loanStatus!=undefined){
	   params+="&loanStatus="+loanStatus;
	   paramstr+=" , Loan Status "+$('#loanStatus option:selected').text();
	}
		
		
	
	
	var collateralTypetotal=Array();
	var collateralTypeTxt=Array();
	var jj=0;
	var pt = document.getElementsByName('collateralType[]');
	//alert( pt.length) ;
	
	for(var i=0; i < pt.length; i++)
	{
		if(pt[i].checked)
		{
			collateralTypetotal[jj]=pt[i].value;
			collateralTypeTxt[jj]=document.getElementById('collateralType'+ pt[i].value ).value;
			
			jj++;
		}
	}
  
	var collateralType=collateralTypetotal.join(",");	
	var collateralTypeTxt=collateralTypeTxt.join(",");	

	if(collateralType!="")
	{
		params+="&collateralType="+collateralType; 
		paramstr+=" , Collateral Type "+collateralTypeTxt;
	}
	

	var txt = paramstr;
	var arry = txt.split(',');
	for (var i=0; i<arry.length; i++) {
        if (arry[i] == '  ')  {
            arry.splice(i, 1);
        }
	}
	for (var i=0; i<arry.length; i++) {
        if (arry[i] == '  ')  {
            arry.splice(i, 1);
        }
	}
	
	paramstr = String(arry);
	
	//alert(params+"|"+paramstr)  ;
	return params+"|"+paramstr;
}


function myalertpage()
{
	//$('#alertSuccess').hide();
	var alertId = opener.document.getElementById('alertId').value;	
	
	var filename = SITE_PATH+'emailPage.php?setting_id='+alertId;
	window.location=filename;
	//window.open(filename,'w1','scrollbars=yes');
}

function editalertdiv()
{
	//$('#alertSuccess').hide();
	var alertId='';
	if(document.getElementById('alertId'))
	{
		alertId = document.getElementById('alertId').value;	
	}
	else
	{
		alertId = opener.document.getElementById('alertId').value;	
	}
	//window.open(SITE_PATH+'create-email-alert.php?setting_id='+alertId,'alert','width=600, height=219, scrollbars=yes');
	var alertGlobalFlag="";
	if(document.getElementById("alertGlobalFlag"))
	{
	  alertGlobalFlag="&alertGlobalFlag="+document.getElementById("alertGlobalFlag").value ;
	    
	}
	var filename = SITE_PATH+'create-email-alert.php?setting_id='+alertId+alertGlobalFlag;
	
	//alert(filename)
	window.open(filename,'w2','scrollbars=yes');
}


function countAlertwithoutthickbox()
{
	var sendparam='';
	sendparam = "action=countAlert";
	if(document.getElementById('loddivcont'))
	{
		document.getElementById('loddivcont').style.display='none';
	}
	SITE_URL=SITE_PATH.replace("https","http");
	$.ajax({
		 type: "POST",
		 url: SITE_PATH+"ajax/emailalert_ajax.php",
		 async: true,
		 global: false,
		 //timeout: 30000,
		 data: sendparam,
		 success: function(result){
		   var res = result.split("|");
			if(res[0]=="ERROR")
			{
				
				$("#loginerr1").show();
			}
			else
			{
				
			   	document.getElementById('saveAlertCount').value=res[1];  
				var userId = document.getElementById('userId').value;
				
				var firstName = document.getElementById('firstName').value;
				if(res[1]>=20 )
				{
					window.open(SITE_PATH+'create-max-alert.php','alert','width=400,height=160,scrollbars=yes,screenX=150'); 
				}
				else
				{
					createAlertAlertwithouthickbox(firstName);
				}
			}		   
		 }
	});
}

function countAlert()
{
	var sendparam='';
	sendparam = "action=countAlert";
	parent.document.getElementById('loddivcont').style.display='none';
	$.ajax({
		 type: "POST",
		 url: SITE_PATH+"ajax/emailalert_ajax.php",
		 async: true,
		 global: false,
		 //timeout: 30000,
		 data: sendparam,
		 success: function(result){
		   var res = result.split("|");
			if(res[0]=="ERROR")
			{
				$("#loginerr1").show();
			}
			else
			{
			   	window.parent.document.getElementById('saveAlertCount').value=res[1];  
				var userId = window.parent.document.getElementById('userId').value;
				var firstName = window.parent.document.getElementById('firstName').value;
				if(res[1]>=20 )
				{
					window.open(SITE_PATH+'create-max-alert.php','alert','width=400,height=160,scrollbars=yes,screenX=150'); 
				}
				else
				{
					createAlertAlertwithouthickbox(firstName);
				}
			}
		 }
	});
}
function createAlertAlertwithouthickbox(firstname)
{	


/*var paramsArr = getparamsAlert().split("|");
	var paramsList = paramsArr[0];	
	
	var  alertSuccessUrl=(document.getElementById('alertSuccessUrl').value).replace("-alert-confirmed-2","");
	alertSuccessUrl=alertSuccessUrl.replace("-alert-fail","");
	paramsList += "&action=savealerts";*/


	var paramsArr = getparamsAlert().split("|");
	var paramsList = paramsArr[0];	
	var  alertSuccessUrl='';
	var alertUrl=document.getElementById('alertSuccessUrl').value;
	
	if(alertUrl.search("-alert-confirmed-2")!=-1)
	{
		alertSuccessUrl=alertUrl.replace("-alert-confirmed-2","");
	}
	else if(alertUrl.search("-alert-confirmed-1")!=-1)
	{
		alertSuccessUrl=alertUrl.replace("-alert-confirmed-2","");
	}
	else if(alertUrl.search("-alert-fail")!=-1)
	{
		alertSuccessUrl=alertUrl.replace("-alert-fail","");
	}
	if(alertSuccessUrl!="") alertUrl=alertSuccessUrl;
	paramsList += "&action=savealerts";
	
	$.ajax({
		 type: "POST",
		 url: SITE_PATH+"ajax/emailalert_ajax.php",
		 async: true,
		 global: false,
		 data: paramsList,
		 success: function(result)
		 {			
			var param=getparamsAlert();	 
			var alertresp= result.split("|");
			document.getElementById('alertSuccess').innerHTML='<iframe name="FRAME1" src="'+SITE_PATH+'component/auction-search-alert-confirmed-1.php?'+param+'&alertSuccessUrl='+alertUrl+'"width="380" height="130" frameborder="0" scrolling="no"></iframe>';
			document.getElementById('alertSuccess').style.left=263+'px';
			document.getElementById('alertSuccess').style.top=190+'px';
			document.getElementById('alertSuccess').style.display='';
			if(document.getElementById('alertId'))
			document.getElementById('alertId').value=alertresp[0];
			document.getElementById('saveAlertCount').value=1+parseInt(document.getElementById('saveAlertCount').value);
			document.getElementById('alertName').value=alertresp[1];
		 }
	});	
}


function closealertSuccess(){
	parent.document.getElementById('alertSuccess').style.display="none";
	parent.document.getElementById('alertSuccess').innerHTML="";
}

