function InArray(A,C){for(var B=0;B<A.length;B++){if(A[B]==C){return B}}return -1}function display_dropdown_caste_new(K,D,I){if(K=="smart_search"){var G=document.frm_main;var J=G.elements["communityarray[]"];var M=G.elements["mothertonguearray[]"]}else{var G=document.quicksearch;var J=G.community;var M=G.elements["mothertonguearray[]"]}var L="";var H="";if(K=="smart_search"){for(var F=0;F<J.options.length;F++){var O=J.options[F].value;if(!L.match(O)&&J.options[0].text!="Doesn't Matter"){L+=new String(O)+"|"}}}else{L=new String(J.options[J.selectedIndex].value)}var N=new Array;var C=0;var A=false;for(var F=0;F<M.options.length;F++){var E=M.options[F].value;if(K=="smart_search"){if(!H.match(E)&&M.options[0].text!="Doesn't Matter"){if(E){N[C]=E}}}else{if(M.options[F].selected==true){if(E){N[C]=E}}}C++}if(N){H=N.join("|")}if(((L&&H)||(L))&&I){var B=AjaxRequest.get({url:"/ssi/ajax-com-mt-caste.php?community="+escape(L)+"&mothertongue="+escape(H)+"&gender="+escape(I)+"&from_page="+escape(K),onSuccess:function(a){if(K=="smart_search"){var Q=G.elements["caste_fromarray[]"];var Z=G.elements["castearray[]"]}else{var Q=G.elements["castearray[]"]}myString=new String(a.responseText);if(myString!=""){splitString=myString.split("@");Q.innerHTML="";Q.options.length=0;var S=0;var U=0;for(var X=0;X<splitString.length;X++){myString1=new String(splitString[X]);caste_txt_val=myString1.split("|");if((splitString[X].substr(0,1)!="|")){arr_caste_label=Array();if(splitString[X].indexOf(":")>0){arr_caste_label=splitString[X].split(":");caste_display_label=arr_caste_label[0]}else{caste_display_label=splitString[X];if(splitString[X]=="Spiritual - not religious"){caste_display_label="Spiritual"}}if(K=="new_home_page"){if(!A){Q[S]=new Option("Doesn't Matter","",false);A=true}else{Q[S]=new Option("","",false)}}else{Q[S]=new Option(caste_display_label,"",false);Q[S].style.backgroundColor="#F2F2C3"}S++}check_selected_caste_spilt_string=D.split("|");for(var V=1;V<caste_txt_val.length;V++){var R=caste_txt_val[V].trim();arr_caste_txt=Array();if(R.indexOf(":")>0){arr_caste_txt=R.split(":");caste_display_txt=arr_caste_txt[1];if(arr_caste_txt[0]==arr_caste_txt[1]){R=arr_caste_txt[0]}}else{caste_display_txt=R}if(caste_display_txt&&InArray(check_selected_caste_spilt_string,caste_display_txt)>=0){if(K=="smart_search"){Q[S]=new Option(caste_display_txt,R,false);Q[S].style.backgroundColor="#FFFFFF";S++;Z[U]=new Option(caste_display_txt,R);U++}else{Q[S]=new Option(caste_display_txt,R);S++}}else{Q[S]=new Option(caste_display_txt,R);Q[S].style.backgroundColor="#FFFFFF";S++}}}if(K=="smart_search"){var W=document.frm_main.elements["castearray[]"];var P=document.frm_main.elements["caste_fromarray[]"];var b=W.options.length;for(var Y=0;Y<b;Y++){remcst_flag=false;if(W.options[Y].value!=""){for(var c=0;c<P.options.length;c++){if(W.options[Y].value==P.options[c].value){remcst_flag=true;break}}}if(remcst_flag==false){W.options[Y]=null;Y=-1;b--}}if(b==0){W.options[0]=new Option("Doesn't Matter","")}}if(K=="city_search"||K=="keyword_search"||K=="spcases"){for(var T=0;T<Q.options.length;T++){if(Q.options[T].value!=""&&InArray(check_selected_caste_spilt_string,Q.options[T].value)>=0){Q.options[T].selected=true}}}}else{document.getElementById("show_hide_caste").style.display="none"}if(myString.search(/no matches/i)==-1){document.getElementById("show_hide_caste").style.display="inline";document.getElementById("castedp").style.display="inline";if(K!="smart_search"){document.getElementById("loading_caste").innerHTML=""}}else{if(K=="new_home_page"){document.getElementById("castedp").style.display="inline";document.getElementById("loading_caste").innerHTML=""}else{document.getElementById("show_hide_caste").style.display="none";document.getElementById("castedp").style.display="inline";if(K!="smart_search"){document.getElementById("loading_caste").innerHTML=""}}}},onError:function(P){alert("Error!\nStatusText="+P.statusText+"\nContents="+P.responseText)}});return B}}function copytolist1(E,B){var I=false;var A=false;for(i=0;i<E.options.length;i++){var K=E.options[i];if(K.selected){if(E==document.frm_main.elements["communityarray[]"]||E==document.frm_main.elements["mothertonguearray[]"]||E==document.frm_main.elements["castearray[]"]){A=true}if(A==false){to_array=new Array();for(D=0;D<B.options.length;D++){if((K.value)==(B.options[D].value)){to_array[D]=K.value}}}if(A==true){if(E==document.frm_main.elements["communityarray[]"]){if(E.options.length==1){document.frm_main.elements["castearray[]"].options.length=0}else{var H=frm_main.elements["castearray[]"].options.length;for(var D=0;D<H;D++){var C;C=document.frm_main.elements["castearray[]"].options[D].value;if(C.indexOf(K.value)!=-1){document.frm_main.elements["castearray[]"].options[D]=null;D=-1;H--}}if(H==0){document.frm_main.elements["castearray[]"].options[0]=new Option("Doesn't Matter","")}}}}I=true;var G=K.text;var F=K.value;if(G!=""&&G!="----Select Mother Tongue----"&&G!="---------Select Caste---------"&&F!=""){if(B.options[0]&&(B.options[0].text=="Doesn't Matter"||B.options[0].text=="")&&E!=document.frm_main.elements["countryofresidencearray[]"]){B.options.length=0}if(G!="Doesn't Matter"){if(A==false){if((G&&InArray(to_array,F)==-1)){B.options[B.length]=new Option(G,F)}}}if(A){E.options[i]=null;i--}}}}if(E.options.length==0&&A){if(document.frm_main.elements["communityarray[]"].options.length==0){document.frm_main.elements["caste_fromarray[]"].options.length=0;document.getElementById("show_hide_caste").style.display="none"}if(E==document.frm_main.elements["communityarray[]"]||E==document.frm_main.elements["mothertonguearray[]"]||E==document.frm_main.elements["castearray[]"]){var J=" "}else{var J=""}E.options[0]=new Option("Doesn't Matter",J)}if(E.options.length>0&&E.options.length<=2){if(E.options[0].text=="---------Select Caste---------"&&E.options.length==2){if(E.options[1].text==""){E.options[1]=null}}else{if(E.options.length==1&&E.options[0].text==""){E.options[0]=null}}}if(!I){alert("Please select the Options");return false}return true}function which_community(com,gen,fn){var wio_final_array=new Array();wio_final_array.Muslim=new Array("All","Bengali","Dawoodi Bohra","Shia","Sunni");wio_final_array.Christian=new Array("All","Born Again","Protestant","Roman Catholic");wio_final_array.Sikh=new Array("All","Gurusikh","Jat","Khatri","Ramgharia");wio_final_array.Jain=new Array("All","Digambar","Shwetamber","Vania");wio_final_array.Parsi=new Array("parsi");wio_final_array.Buddhist=new Array("Buddhist");wio_final_array.Jewish=new Array("Jewish");wio_final_array.NoReligion=new Array("No Religion");wio_final_array.SpiritualNoReligious=new Array("Spiritual - Not Religious");wio_final_array.Other=new Array("Other");if(com==""||com==" "){document.getElementById("show_hide_mothertongue").style.display="none";document.getElementById("show_hide_caste").style.display="none"}else{if(com=="Hindu"){document.getElementById("show_hide_mothertongue").style.display="inline";document.getElementById("show_hide_caste").style.display="none"}else{var d=eval("document."+fn);var caste_object=d.elements["castearray[]"];caste_object.options.length=0;if(com.match("Spiritual")){com="SpiritualNoReligious"}else{com=com.replace(/\s/,"")}if(wio_final_array[com].length>1){caste_object[0]=new Option("Select Community","",false);for(var i=0;i<wio_final_array[com].length;i++){if(wio_final_array[com][i]=="All"){caste_object[i+1]=new Option(wio_final_array[com][i],"",false)}else{caste_object[i+1]=new Option(wio_final_array[com][i],com+":"+wio_final_array[com][i],false)}}document.getElementById("show_hide_mothertongue").style.display="none";document.getElementById("show_hide_caste").style.display="inline"}else{document.getElementById("show_hide_mothertongue").style.display="none";document.getElementById("show_hide_caste").style.display="none"}}}}function show_mt_caste(D,C,B,A){if(D==""){if(B!="new_home_page"){document.getElementById("show_hide_mothertongue").style.display="none";document.getElementById("show_hide_caste").style.display="none"}}else{if(D==""||D=="doesn't_matter"){if(B=="new_home_page"){document.getElementById("show_hide_mothertongue").style.display="inline";document.getElementById("show_hide_caste").style.display="inline"}else{document.getElementById("show_hide_mothertongue").style.display="inline";document.getElementById("show_hide_caste").style.display="none"}}else{if(document.getElementById("loading_caste")){if(B=="new_home_page"){document.getElementById("loading_caste").innerHTML='<img src="http://img.shaadi.com/imgs/loading.gif" align="absmiddle">'}else{document.getElementById("loading_caste").innerHTML='<img src="'+A+'/imgs/loading.gif" align="absmiddle">'}}document.getElementById("show_hide_mothertongue").style.display="inline";document.getElementById("show_hide_caste").style.display="inline";document.getElementById("castedp").style.display="none";display_dropdown_caste_new(B,"",C)}}};