/************************************************************************************
 * File Name	: productAlerts.js
 * Purpose		: All javascript function for price fall alert page.
 * Created On	: 17 Augest 2009
 * Created By	: Vijay Topadebuwa
 * Updated By	: 
 ***********************************************************************************/
function fnsubmit(flag)
{
	var frmObj = document.pricedroup;
	if(frmObj.chkPrice[1].checked == true)
	{
		if(flag==1 || flag==2)
		{
			if(frmObj.txtmaxPriceless.value=="")
			{		
				frmObj.txtmaxPriceless.focus();
				document.getElementById("error").style.display="";
				document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Enter Price alert value</label>';
				return false;
			}else
			{
				var chstring = chkstr(frmObj.txtmaxPriceless.value);
				if(!chstring)
				{
					document.getElementById("error").style.display="";
					document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Enter valid Price alert value</label>';
					frmObj.txtmaxPriceless.focus();
					return false;	
				}

				if(!parseInt(frmObj.txtmaxPriceless.value))
				{
					document.getElementById("error").style.display="";
					document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Enter valid Price alert value</label>';
					frmObj.txtmaxPriceless.focus();
					return false;	
				}
				var pricestr = frmObj.txtmaxPriceless.value;
				var newprice1 = pricestr.split(",");
				if(newprice1[1]!="" && newprice1[1]!=undefined)
				{
					if(newprice1[1].length>2)	
					{
						document.getElementById("error").style.display="";
						document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;You cant enter a price alert with more than 2 digits after comma.</label>';
						frmObj.txtmaxPriceless.focus();
						return false;
					}
				}
				
				var str = frmObj.txtmaxPriceless.value;
				str = str.replace(",",".");
				var prod_val = parseFloat(frmObj.hdnprice.value);
				if(parseFloat(str)>= prod_val)
				{
					document.getElementById("error").style.display="";
					document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Price alert cannot be equal or higher then actual price</label>';
					frmObj.txtmaxPriceless.focus();
					return false;
				}else
				{
					document.getElementById("error").style.display="";
					document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error checked"></label>';				
				}
			}
		}
	}else 	if(frmObj.chkPrice[2].checked == true)
	{
		if(frmObj.txtmaxPricedrop.value=="")	{		
			document.getElementById("error").style.display="none";
			frmObj.txtmaxPricedrop.focus();
			document.getElementById("error1").style.display="";
			document.getElementById("error1").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Enter Price alert in %</label>';
			return false;
		}else{
			
			if(!parseInt(frmObj.txtmaxPricedrop.value)){
				document.getElementById("error1").style.display="";
				document.getElementById("error1").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Enter Price alert in %</label>';
				frmObj.txtmaxPricedrop.focus();
				return false;	
			}else if(frmObj.txtmaxPricedrop.value>100){				
				document.getElementById("error1").style.display="";
				document.getElementById("error1").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Enter Price alert in %</label>';
				frmObj.txtmaxPricedrop.focus();
				return false;						
			}else if(parseInt(frmObj.txtmaxPricedrop.value)==0){				
				frmObj.txtmaxPricedrop.focus();
				document.getElementById("error1").style.display="";
				document.getElementById("error1").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;The minimum price drop percentage is 1%.</label>';				
				return false;						
			}else
			{
				document.getElementById("error1").style.display="";
				document.getElementById("error1").innerHTML	 = 	'<label generated="true" class="error checked"></label>';								
			}
		}
	}
	if(frmObj.txtalertname.value!="")
	{		
		if(trim(frmObj.txtalertname.value)=="")
		{					
			document.getElementById("error").style.display="none";
			document.getElementById("error1").style.display="none";
			document.getElementById("error2").style.display="";
			//document.getElementById("error2").innerHTML	 = 	'Enter valid alert name';
			document.getElementById("error2").style.display="";
			document.getElementById("error2").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Enter valid alert name</label>';
			frmObj.txtalertname.focus();
			return false;
		}else
		{
			if(flag =="1")
			{
				document.getElementById("error2").style.display="";
				document.getElementById("error2").innerHTML	 = 	'<label generated="true" class="error checked"></label>';				
			}
		}	
	}else
	{
		document.getElementById("error2").style.display="";
		document.getElementById("error2").innerHTML	 = "";
	}

	if(flag==2){
		frmObj.page_action.value="SetPriceDroupAlert";
		frmObj.submit();
	}

}
//function for redirect product price fall alert to login page
function fncheck(path)
{
	//tb_show(null,'ajaxLogin.php?keepThis=true&TB_iframe=true&height=600&width=850&modal=true','');
	//window.parent.tb_remove();
	document.getElementById("txtalertname").focus();
	window.parent.tb_show(null,path+'ajaxLogin.php?keepThis=true&loginflag=1&TB_iframe=true&height=600&width=850&modal=true','');
}

//function for redirect product price fall alert to confirm page
function fnconfirm(path,flag)
{
	window.parent.tb_show(null,path+'price_fall_confirm.php?keepThis=true&logflag='+flag+'&TB_iframe=true&height=255&width=700&modal=true','');
}

//function for validating product stock page validation
function fnValidate(flag)
{

	var frmObj = document.frmstockalert;
	if(frmObj.txtalertname.value!="")
	{	
		if(trim(frmObj.txtalertname.value)=="")
		{					
			document.getElementById("error2").style.display="";
			document.getElementById("error2").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;Enter valid alert name</label>';
			frmObj.txtalertname.focus();
			return false;
		}else
		{
			if(flag =="1")
			{
				document.getElementById("error2").style.display="";
				document.getElementById("error2").innerHTML	 = 	'<label generated="true" class="error checked"></label>';				
			}
		}
	}else
	{
		document.getElementById("error2").style.display="";
		document.getElementById("error2").innerHTML	 = "";
	}

	if(flag=="2")
	{
		frmObj.page_action.value="ProductStockAlert";
		frmObj.submit();
	}
}

function fnStockalert(path)
{
	document.getElementById("txtalertname").focus();
	window.parent.tb_show(null,path+'ajaxLogin.php?keepThis=true&loginflag=2&TB_iframe=true&height=600&width=850&modal=true','');
}

//function for redirect product stock alert confirm page
function fnconfirmStock(path,flag)
{
	window.parent.tb_show(null,path+'stock_confirm.php?keepThis=true&logflag='+flag+'&TB_iframe=true&height=255&width=700&modal=true','');
}

function setSliderVal()
{
	if(document.getElementById("specialoff"))
	{
		//document.getElementById("specialoff").innerHTML=document.getElementById("per_specialoff").value;
		if(document.getElementById("per_specialoff").value!=100)
			document.getElementById("specialoff").innerHTML="At least - "+document.getElementById("per_specialoff").value+"%";
		else
			document.getElementById("specialoff").innerHTML="All the special offers";

		if(document.getElementById("per_specialoff").value>0 && document.getElementById("per_specialoff").value<31)
		{
			document.getElementById("specialofferflag").style.backgroundColor="#00FF00";
			document.getElementById("specialofferflag").innerHTML="High";
		}
		else if(document.getElementById("per_specialoff").value>30 && document.getElementById("per_specialoff").value<61)
		{
			document.getElementById("specialofferflag").style.backgroundColor="#FFCC00";
			document.getElementById("specialofferflag").innerHTML="Average";
		}
		else if(document.getElementById("per_specialoff").value>61 && document.getElementById("per_specialoff").value<96)
		{
			document.getElementById("specialofferflag").style.backgroundColor="#FF0000";
			document.getElementById("specialofferflag").innerHTML="Low";
		}
	}

	if(document.getElementById("per_pricedrop"))
	{
		if(document.getElementById("per_pricedrop").value!=100)
			document.getElementById("pricedropspan").innerHTML=document.getElementById("per_pricedrop").value+"%";
		else
			document.getElementById("pricedropspan").innerHTML="All the prices dropping";

		if(document.getElementById("per_pricedrop").value>0 && document.getElementById("per_pricedrop").value<31)
		{
			document.getElementById("pricedroupflag").style.backgroundColor="#00FF00";
			document.getElementById("pricedroupflag").innerHTML="High";
		}
		else if(document.getElementById("per_pricedrop").value>30 && document.getElementById("per_pricedrop").value<61)
		{
			document.getElementById("pricedroupflag").style.backgroundColor="#FFCC00";
			document.getElementById("pricedroupflag").innerHTML="Average";
		}
		else if(document.getElementById("per_pricedrop").value>61 && document.getElementById("per_pricedrop").value<96)
		{
			document.getElementById("pricedroupflag").style.backgroundColor="#FF0000";
			document.getElementById("pricedroupflag").innerHTML="Low";
		}
	}

	if(document.getElementById("per_newprod"))
	{		
		//document.getElementById("productalertdays").innerHTML=document.getElementById("per_newprod").value
		;
		if(document.getElementById("per_newprod").value!=7)
			document.getElementById("productalertdays").innerHTML="Less than "+document.getElementById("per_newprod").value+"days";
		else
			document.getElementById("productalertdays").innerHTML="All the new products";

		if(document.getElementById("per_newprod").value>0 && document.getElementById("per_newprod").value<2)
		{
			document.getElementById("newproductflag").style.backgroundColor="#FF0000";
			document.getElementById("newproductflag").innerHTML="Low";
		}
		else if(document.getElementById("per_newprod").value>1 && document.getElementById("per_newprod").value<7)
		{
			document.getElementById("newproductflag").style.backgroundColor="#FFCC00";
			document.getElementById("newproductflag").innerHTML="Average";
		}
		else if(document.getElementById("per_newprod").value>6 && document.getElementById("per_newprod").value<8)
		{
			document.getElementById("newproductflag").style.backgroundColor="#00FF00";
			document.getElementById("newproductflag").innerHTML="High";
		}
	}

	/*if(document.getElementById("pricedrop"))
		document.getElementById("pricedrop").innerHTML=document.getElementById("per_pricedrop").value;
	if(document.getElementById("newprod"))
		document.getElementById("newprod").innerHTML=document.getElementById("per_newprod").value;*/
	
}

function fnsearch_alert(flag)
{	
	var frmObj = document.frmsearchalert;
	if(frmObj.txtmaxPrice.value!="" )
	{
		
			/*document.getElementById("error").style.display="";
			document.getElementById("error").innerHTML	 = 	'Enter valid Price';
			frmObj.txtmaxPriceless.focus();
			return false;		*/
			var pricestr = frmObj.txtmaxPrice.value;				
			var commacount = (pricestr.split(",").length - 1);			//count number of occurance of commas
			var newprice1 = pricestr.split(",");
			if(newprice1[1]!="" && newprice1[1]!=undefined) 
			{
				if(newprice1[1].length>2)	
				{
					document.getElementById("error").style.display="";
					document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;You cant enter a price alert with more than 2 digits after comma.</label>';
					frmObj.txtmaxPrice.focus();
					return false;
				}else if(commacount!=1 && commacount!=0)
				{
					document.getElementById("error").style.display="";
					document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error unchecked">&nbsp;You cant enter a price alert with more than 1 comma.</label>';
					frmObj.txtmaxPrice.focus();
					return false;
				}
				else
				{
					document.getElementById("error").style.display="";
					document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error checked"></label>';		
				}
			}else
			{
				document.getElementById("error").style.display="";
				document.getElementById("error").innerHTML	 = 	'<label generated="true" class="error checked"></label>';		
			}
	}else
	{
		document.getElementById("error").style.display="";
		document.getElementById("error").innerHTML	 = "";
	}

	if(frmObj.txtalertname.value!="")
	{	
		if(trim(frmObj.txtalertname.value)=="")
		{					
			document.getElementById("error2").style.display="";
			document.getElementById("error2").innerHTML	 = 	'Enter valid alert name';
			frmObj.txtalertname.focus();
			return false;
		}	
	}
	
	if(document.getElementById("set_for_flag").value!='1' || document.getElementById("set_for_flag").value!='2' || document.getElementById("set_for_flag").value!='3' )
	{
		if(document.getElementById("chkSpecialOffer") && document.getElementById("chkSpecialOffer") && document.getElementById("chkSpecialOffer"))
		{
			if(frmObj.chkSpecialOffer.checked == false && frmObj.chkPriceDrop.checked == false && frmObj.chknewproduct.checked == false)
			{
				document.getElementById("errchkspecial").style.display="";
				document.getElementById("errchkspecial").innerHTML = "You must select at least one checkbox";

				document.getElementById("errpricedrop").style.display="";
				document.getElementById("errpricedrop").innerHTML = "You must select at least one checkbox";

				document.getElementById("errnewproduct").style.display="";
				document.getElementById("errnewproduct").innerHTML = "You must select at least one checkbox";
				return false;
			}
		}
	}

	if(flag==1)
	{
		frmObj.page_action.value="ProductSearchAlert";
		frmObj.submit();
	}
}

function fnsearch(path,flag)
{
	document.getElementById("txtalertname").focus();
	window.parent.tb_show(null,path+'ajaxLogin.php?keepThis=true&loginflag=3&TB_iframe=true&height=600&width=850&modal=true','');
}

//function for redirect product stock alert confirm page
function fnconfirmSearch(path,flag)
{
	window.parent.tb_show(null,path+'search_confirm.php?keepThis=true&logflag='+flag+'&TB_iframe=true&height=255&width=700&modal=true','');
}

//function for redirect product price fall alert to login page
function fnMyalertsChecklogin(path)
{
	window.parent.tb_show(null,path+'ajaxLogin.php?keepThis=true&TB_iframe=true&height=600&width=850&modal=true','');
}
//function for my alerts results using ajax
function fnMyalertsResult(path,flag)
{
	xmlHttp	=GetXmlHttpObject(handleSearch)		
	if(flag=="" && flag==undefined)
		var parameters="";
	else
		var parameters="flag="+flag;

	if(flag=="paging")
	{
		var pagingstr = "page="+document.getElementById("page").value+"&Pgno="+document.getElementById("Pgno").value+"&Plimit="+document.getElementById("Plimit").value;
	}else
	{
		var pagingstr = "";
	}
	
	if(parameters!="")
		parameters = parameters+"&"+pagingstr;

	var url=path+"myalertsAjax.php";
	xmlHttp.open("POST", url, false);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	xmlHttp.send(parameters)

}

function handleSearch()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("myalertresultdiv").innerHTML=xmlHttp.responseText;
	}
}

function fnMyalerts(path)
{
	window.parent.tb_show(null,path+'userUpdate.php?keepThis=true&TB_iframe=true&height=600&width=850&modal=true','');
}

function fnShowdetail(path,type,id,msg)
{
	if(type==2)
	{
		window.parent.tb_show(null,path+'alert_details.php?keepThis=true&al_type='+type+'&alert_id='+id+'&TB_iframe=true&height=475&width=850&modal=true','');
	}else
	{
		window.parent.tb_show(null,path+'alert_details.php?keepThis=true&al_type='+type+'&alert_id='+id+'&msg='+msg+'&TB_iframe=true&height=330&width=850&modal=true','');
	}
}

function fnupdateAlert(alertid,path)
{
	var alerttype = document.getElementById("alerttype").value;

	var duration = document.myalertsdetails.chkDuration;
	 for (var i=0; i <duration.length; i++) {
		  if (duration[i].checked) {
				var newduration = duration[i].value;
		  }
	 } 
	 
	if(alerttype==2)
	{
		var altfreq = document.myalertsdetails.asNecess;
		 for (var i=0; i <altfreq.length; i++) {
			  if (altfreq[i].checked) {
					var newaltfreq = altfreq[i].value;
			}
		}
	}

	xmlHttp	=GetXmlHttpObject(handlealertUpdate)	
	if(alerttype==2)
	{	
		var parameters="alert_id="+alertid+"&duration="+newduration+"&alerttype="+alerttype+"&altfreq="+newaltfreq;
	}else
	{
		var parameters="alert_id="+alertid+"&duration="+newduration+"&alerttype="+alerttype;
	}
	var url=path+"myalerts_update.php";
	xmlHttp.open("POST", url, false);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
	xmlHttp.send(parameters)
}

function handlealertUpdate()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		if(xmlHttp.responseText==1)
			document.getElementById("myalertresultdiv_msg").innerHTML="<span style='color:red;'>Record updated successfully</span>";
	}
}

function fnAlertStatusAction(alertid,path,flag,main)
{	
	if(flag==1)
	{
		if(confirm("Record(s) selected will be suspended. Do you want to suspend the record(s)? ")) {
			xmlHttp	=GetXmlHttpObject(handlealertActions)	
			var parameters="alert_id="+alertid+"&action=alert_action&flag="+flag;
			var url=path+"myalerts_update.php";
			xmlHttp.open("POST", url, false);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
			xmlHttp.send(parameters)		
		}
	}else if(flag==2)
	{
		if(confirm("Record(s) selected will be deleted. Do you want to delete the record(s)? ")) {
			xmlHttp	=GetXmlHttpObject(handlealertActions)	
			var parameters="alert_id="+alertid+"&action=alert_action&flag="+flag;
			var url=path+"myalerts_update.php";
			xmlHttp.open("POST", url, false);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
			xmlHttp.send(parameters)		
		}
	}else if(flag==3)
	{
		if(confirm("Record(s) selected will be resumed. Do you want to resume the record(s)? ")) {
			xmlHttp	=GetXmlHttpObject(handlealertActions)	
			var parameters="alert_id="+alertid+"&action=alert_action&flag="+flag;
			var url=path+"myalerts_update.php";
			xmlHttp.open("POST", url, false);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
			xmlHttp.send(parameters)		
		}
	}else if(flag==4)
	{
		if(confirm("Record(s) selected will be restarted. Do you want to restart the record(s)? ")) {
			xmlHttp	=GetXmlHttpObject(handlealertActions)	
			var parameters="alert_id="+alertid+"&action=alert_action&flag="+flag;
			var url=path+"myalerts_update.php";
			xmlHttp.open("POST", url, false);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
			xmlHttp.send(parameters)		
		}
	}
		if(main!="")
		{
			if(xmlHttp.responseText==1){
				document.getElementById("myalertresultdiv_main").innerHTML="<span style='color:red;'>Record suspended successfully</span>";
			}else if(xmlHttp.responseText==2){
				document.getElementById("myalertresultdiv_main").innerHTML="<span style='color:red;'>Record supressed successfully</span>";
			}else if(xmlHttp.responseText==3){
				document.getElementById("myalertresultdiv_main").innerHTML="<span style='color:red;'>Record resumed successfully</span>";
			}else if(xmlHttp.responseText==4){
				document.getElementById("myalertresultdiv_main").innerHTML="<span style='color:red;'>Record restarted successfully</span>";
			}
			fnMyalertsResult(path);
		}else
		{			
			if(xmlHttp.responseText==1){
				document.getElementById("myalertresultdiv_msg").innerHTML="<span style='color:red;'>Record suspended successfully</span>";
			}else if(xmlHttp.responseText==2){
				document.getElementById("myalertresultdiv_msg").innerHTML="<span style='color:red;'>Record supressed successfully</span>";
			}else if(xmlHttp.responseText==3){
				document.getElementById("myalertresultdiv_msg").innerHTML="<span style='color:red;'>Record resumed successfully</span>";
			}else if(xmlHttp.responseText==4){
				document.getElementById("myalertresultdiv_msg").innerHTML="<span style='color:red;'>Record restarted successfully</span>";
			}
			var al_type = document.getElementById("alerttype").value;
			fnShowdetail(path,al_type,alertid,document.getElementById("myalertresultdiv_msg").innerHTML);
		}
		
}

function handlealertActions()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		return xmlHttp.responseText;		
	}
}

function fnMyalertsReturn(path)
{
	window.parent.tb_show(null,path+'product_alerts.php?keepThis=true&TB_iframe=true&height=500&width=850&modal=true','');
}

function fnchecknew(flag)
{
	var frmObjnew = document.pricedroup;
	if(flag==1)
	{		
		frmObjnew.txtmaxPricedrop.value = "";
		document.getElementById("error").innerHTML	 ="";
		document.getElementById("error1").innerHTML ="";
		frmObjnew.txtmaxPriceless.disabled = false;
		frmObjnew.txtmaxPricedrop.disabled = true;
		frmObjnew.txtmaxPriceless.focus();
	}else if(flag==2){
		frmObjnew.txtmaxPriceless.value ="";
		document.getElementById("error").innerHTML	 ="";
		document.getElementById("error1").innerHTML ="";
		frmObjnew.txtmaxPriceless.disabled = true;
		frmObjnew.txtmaxPricedrop.disabled = false;
		frmObjnew.txtmaxPricedrop.focus();
	}else if(flag==0){
		frmObjnew.txtmaxPriceless.value = "";
		frmObjnew.txtmaxPricedrop.value = "";
		document.getElementById("error").innerHTML	 ="";
		document.getElementById("error1").innerHTML ="";
		frmObjnew.txtmaxPriceless.disabled = true;
		frmObjnew.txtmaxPricedrop.disabled = true;
	}
}

//Functions for paging starts here

function getpage_ajax(pg,pn,pl)
{	
	var path = document.getElementById("path").value;
	document.getElementById("page").value=pg;
	document.getElementById("Pgno").value=pn;
	document.getElementById("Plimit").value=pl;
	fnMyalertsResult(path,'paging');	
}

function fnNext1_ajax(Plimit)
{
	var path = document.getElementById("path").value;
	/*document.frm.page.value=parseInt(Plimit)+1;
	document.frm.Pgno.value=parseInt(Plimit)+1;
	document.frm.Plimit.value=parseInt(Plimit)+10;*/
	document.getElementById("page").value=parseInt(Plimit)+1;
	document.getElementById("Pgno").value=parseInt(Plimit)+1;
	document.getElementById("Plimit").value=parseInt(Plimit)+10;
	fnMyalertsResult(path,'paging');	
}

function fnPrevious1_ajax(Plimit)
{
	var path = document.getElementById("path").value;
	/*document.frm.page.value=parseInt(Plimit)-19;
	document.frm.Pgno.value=parseInt(Plimit)-19;
	document.frm.Plimit.value=parseInt(Plimit)-10;
	
	if(document.frm.page.value<=0)
	{
		document.frm.page.value=1;
		document.frm.Pgno.value=1;
		document.frm.Plimit.value=10;
	}*/
	document.getElementById("page").value=parseInt(Plimit)-19;
	document.getElementById("Pgno").value=parseInt(Plimit)-19;
	document.getElementById("Plimit").value=parseInt(Plimit)-10;
	
	if(document.getElementById("page").value<=0)
	{
		document.getElementById("page").value=1;
		document.getElementById("Pgno").value=1;
		document.getElementById("Plimit").value=10;
	}
	fnMyalertsResult(path,'paging');	
}

function chkstr(str) {

    return /^[-+]?[0-9]+(\,[0-9]+)?$/.test(str);
}

function fnalertmainpage(path,id,name)
{
	var newcategory ="";
	var newbrand ="";
	var newshop ="";
	var newsearchInput ="";
	if(id==1)
	{
		var category = name;
		newcategory = category.replace("'","&#039;");
	}else if(id==2)
	{
		var brand = name;
		newbrand = brand.replace("'","&#039;");
	}else if(id==3)
	{
		var shop = name;
		newshop = shop.replace("'","&#039;");		
	}else if(id==4)
	{
		var searchInput = name;
		newsearchInput = searchInput.replace("'","&#039;");	
	}
	else if(id==5 || id==6 || id==7)
	{
		var settypeflag = 2;
		//document.getElementById("serType").value = settypeflag;		
	}

	if(id==5)
	{
		var setForflag =1;
		//document.getElementById("serFor").value = setForflag;
	}else if(id==6)
	{
		var setForflag =2;
		//document.getElementById("serFor").value = setForflag;
	}else if(id==7)
	{
		var setForflag =3;
		//document.getElementById("serFor").value = setForflag;
	}

	if(settypeflag!=2)
	{
		window.parent.tb_show(null,path+'search_alert.php?keepThis=true&brand='+newbrand+'&category='+newcategory+'&searchInput='+newsearchInput+'&shop='+newshop+'&settypeflag='+settypeflag+'&setForflag='+setForflag+'&TB_iframe=true&height=500&width=700&modal=true','');
	}else
	{
		window.parent.tb_show(null,path+'search_alert.php?keepThis=true&brand='+newbrand+'&category='+newcategory+'&searchInput='+newsearchInput+'&shop='+newshop+'&settypeflag='+settypeflag+'&setForflag='+setForflag+'&TB_iframe=true&height=280&width=700&modal=true','');
	}
}