var foc=0;var focName='';function getXMLHTTP()
{var xmlhttp=false;try{xmlhttp=new XMLHttpRequest();}
catch(e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){try{req=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e1){xmlhttp=false;}}}
return xmlhttp;}
function div_file_attach(strURL,name)
{var req=getXMLHTTP();if(req)
{req.onreadystatechange=function()
{if(req.readyState==4)
{if(req.status==200)
{try{if(parseInt(document.getElementById(name+"file_count").value)>0)
{var file_count=parseInt(document.getElementById(name+"file_count").value)-1;}
else
file_count=1;var divTag=document.createElement("div");divTag.innerHTML=req.responseText;document.getElementById(name+"file_attach_exclusion").appendChild(divTag);document.getElementById(name+"img"+file_count).src=HOST_ROOT_PATH_VAR+"images/DefaultImage/sub_blue_icon.png";document.getElementById(name+"lnk"+file_count).href="javascript:removeField('"+file_count+"','"+name+"')";if(window.parent.document.getElementById('childframe1'))
{window.parent.document.getElementById('childframe1').style.height='';window.parent.document.getElementById('childframe1').style.height=(parseInt(window.parent.document.getElementById('childframe1').contentWindow.document.body.scrollHeight)+parseInt(35))+"px";}
if(window.parent.document.getElementById('providerFrame1'))
{window.parent.document.getElementById('providerFrame1').style.height='';window.parent.document.getElementById('providerFrame1').style.height=(parseInt(window.parent.document.getElementById('providerFrame1').contentWindow.document.body.scrollHeight)+parseInt(35))+"px";}}
catch(e)
{document.getElementById(name+"file_attach_exclusion").innerHTML=req.responseText;}}
else
{alert("There was a problem while using XMLHTTP:\n"+req.statusText);}}}
req.open("GET",strURL,true);req.send(null);}}
function addMore(ele,count_file,name)
{var file_count=document.getElementById(name+"file_count").value;if(count_file==0)
{select_And_Or=$('#'+name+'AndOr_'+file_count).attr('value');}
else
{select_And_Or=$('#'+name+'AndOr_'+file_count).attr('value');}
if(select_And_Or!='none')
{$('#resetSpan'+file_count).html('');var file_count=document.getElementById(name+"file_count").value;var campaign_id=document.getElementById(name+"campaign_id").value;document.getElementById(name+"file_count").value=parseInt(file_count)+1;div_file_attach(HOST_ROOT_PATH_VAR+"code/CreateExclusionRule/AjexCreateExclusionRule.php?file_count="+file_count+'&campaignId='+campaign_id+"&name="+name,name);document.getElementById(name+"file_attach_exclusion").style.display='block';if($('#'+name+'storeExclusionRulesIds').attr('value')=='')
{$('#'+name+'storeExclusionRulesIds').attr('value',parseInt(file_count)+1)}
else
{$('#'+name+'storeExclusionRulesIds').attr('value',$('#'+name+'storeExclusionRulesIds').attr('value')+","+(parseInt(file_count)+1))}
var selector="[value='none']";$("#"+name+"AndOr_"+file_count).children(selector).remove();$('#exclusionDiv').html('');}
else
{$('#exclusionDiv').html('Please select And/Or from the drop down');}
foc=parseInt(count_file)+1;focName=name
setTimeout("setFous()",430)}
function setFous()
{$('#'+focName+'criteria_'+foc).focus();foc=0;}
function removeField(id,name)
{var focRemove=parseInt(id)+1;focName=name
$("#"+name+"div_"+id).remove();if(window.parent.document.getElementById('childframe1'))
{window.parent.document.getElementById('childframe1').style.height='';window.parent.document.getElementById('childframe1').style.height=(parseInt(window.parent.document.getElementById('childframe1').contentWindow.document.body.scrollHeight)+parseInt(35))+"px";}
if(window.parent.document.getElementById('providerFrame1'))
{window.parent.document.getElementById('providerFrame1').style.height='';window.parent.document.getElementById('providerFrame1').style.height=(parseInt(window.parent.document.getElementById('providerFrame1').contentWindow.document.body.scrollHeight)+parseInt(35))+"px";}
var exclusionFieldIdIdArry=$("#"+name+"storeExclusionRulesIds").attr('value').split(",");tempArrayIndex=findArrayUser(id,name);exclusionFieldIdIdArry.splice(tempArrayIndex,1);$("#"+name+"storeExclusionRulesIds").attr('value',exclusionFieldIdIdArry);$('#criteria_'+focRemove).focus();}
function findArrayUser(value,name)
{var exclusionFieldIdIdArry=$('#'+name+'storeExclusionRulesIds').attr('value').split(",");tempArray=exclusionFieldIdIdArry;for(i=0;i<tempArray.length;i++)
{if(tempArray[i]==value)
{return i;}}}
function exclusionValidation(dataType,name,imgCount)
{if(trim(dataType)!="")
$("#"+name+"criteria_"+imgCount).attr('disabled',"");else
{$("#"+name+"criteria_"+imgCount).attr('value',"");$("#"+name+"criteria_"+imgCount).attr('disabled',"disabled");}
if(trim(dataType)=="int")
{document.getElementById(name+"criteria_"+imgCount).onkeypress=function(event){return criteriaKeyEvent(event);};}
else
{document.getElementById(name+"criteria_"+imgCount).onkeypress="";}}
function criteriaKeyEvent(evt)
{var charCode=(evt.which)?evt.which:event.keyCode
if(charCode==45)
return true;if(charCode>31&&(charCode<48||charCode>57))
return false;return true;}
function filedCriteriaValidate(ele)
{var tempItem=ele.value.split("|");if(trim(tempItem[0])=="")
{$("#"+tempItem[1]+"criteria_"+tempItem[2]).attr('disabled',"disabled");}}
var countPrice2=0;function fetchCampField(name,countPrice)
{countPrice2=countPrice;campaignId=$('#'+name+'CampaignName_'+countPrice).attr("value");$.post(HOST_ROOT_PATH_VAR+'code/CreateExclusionRule/AjexFetchField.php',{"countPrice":countPrice,"campaignId":campaignId,"name":name},reponseFetchCampField,"html");}
function reponseFetchCampField(d,s)
{$('#campField_'+countPrice2).html(d);}
var countPrice1=0;function fetchCampFieldAjex(name,countPrice)
{countPrice1=countPrice;campaignId=$('#'+name+'CampaignName_'+countPrice).attr("value");$.post(HOST_ROOT_PATH_VAR+'code/CreateExclusionRule/AjexFetchField.php',{"countPrice":countPrice1,"campaignId":campaignId,"name":name},reponseFetchCampFieldAjex,"html");}
function reponseFetchCampFieldAjex(d,s)
{$('#campFieldAjex_'+countPrice1).html(d);}
var countPrice4=0;function showDivValueOther(checkDiv,countPrice,name,modeClear,condition_id)
{countPrice4=countPrice;if(checkDiv=='val')
{if(modeClear!='update')
{$('#'+name+'CampaignName_'+countPrice).attr("value",'');$('#'+name+'FieldNameOther_'+countPrice).attr("value",'');}
$('#'+name+'excusion_type_'+countPrice).attr("value",'v');$('#showValue_'+countPrice).show();$('#showOther1_'+countPrice).hide();$.post(HOST_ROOT_PATH_VAR+'code/CreateExclusionRule/AjexFetchConditions.php',{"type":'v',"countPrice":countPrice4,"name":name,"condition_id":condition_id},reponseShowDivValueOther,"html");}
else if(checkDiv=='oth')
{$('#'+name+'excusion_type_'+countPrice).attr("value",'o');if(modeClear!='update')
{$('#criteria_'+countPrice).attr('value',"");}
$('#showValue_'+countPrice).hide();$('#showOther1_'+countPrice).show();$.post(HOST_ROOT_PATH_VAR+'code/CreateExclusionRule/AjexFetchConditions.php',{"type":'o',"countPrice":countPrice4,"name":name,"condition_id":condition_id},reponseShowDivValueOther,"html");}}
function reponseShowDivValueOther(d,s)
{$('#conditionDiv_'+countPrice4).html(d);}
function resetExclusion(name,count)
{$('#'+name+'FieldName_'+count).attr('value','');$('#'+name+'FieldNameOther_'+count).attr('value','');$('#'+name+'conditionName_'+count).attr('value','');$('#'+name+'criteria_'+count).attr('value','');$('#'+name+'CampaignName_'+count).attr('value','');$('#'+name+'AndOr_'+count).attr('value','none');}
