

var global_array=new Array();var tid=0;var keycode=0;var req_search=null;var prev_hilighted_index=-1;var hilighted_index=-1;var enter=false;var result_bg_color="#FFFAEE";var result_fg_color="#000000";var result_hi_color="#C58610";var head_bg_color="#FFCC00";function search_keyword(D,C,B){var A=0;if(!C&&window.event){C=window.event}if(document.layers){A=(C.modifiers&Event.CONTROL_MASK)>0}else{A=C.ctrlKey}if(tid){return }keycode=C.keyCode;if(A){return true}if(isCtrlKey(keycode)){return true}if(isSendKey(keycode)){tid=setTimeout("SendQuery('"+D+"','"+B+"')",100)}return UpDown(D,keycode)}function isCtrlKey(A){if(A==16||A==17||A==18){return true}else{return false}}function isSendKey(B){var A=true;switch(B){case 13:case 27:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 45:A=false;break;default:break}return A}function SendQuery(D,C){tid=0;var B=document.getElementById("global_search").value;if(B.length!=0&&B.search(/\S/)!=-1){var A="http://"+C+"/utils/search_data_xml.html?keyword="+encodeURIComponent(B);if(req_search){req_search.abort()}req_search=(!window.XMLHttpRequest)?(ActiveXObject?(new ActiveXObject("Microsoft.XMLHTTP")):""):(new XMLHttpRequest());req_search.open("GET",A,true);req_search.onreadystatechange=new Function("Process('"+D+"')");req_search.send(null)}else{hide_div()}}function Process(E){if(req_search.readyState==4){try{if(req_search.status==200){if(req_search.responseText==""){alert("empty response got");hide_div()}else{ShowDiv(E);response=req_search.responseXML.documentElement;var M=response.getElementsByTagName("data");var D=document.getElementById("global_search");var P=findPosX(D);var O=findPosY(D);O=O+D.offsetHeight;var Q=window.document.getElementById("gs_auto_div");var F=document.createElement("DIV");setStyle(F,"cbad");F.innerHTML='<b><font color="#412041" size="2">Choose a suggestion or type and click search.</font></b>';F.style.background=head_bg_color;while(Q.childNodes.length>0){Q.removeChild(Q.childNodes[0])}Q.style.top=O+"px";Q.style.left=P+"px";var A="";global_array=new Array();if(!M.length){hide_div()}Q.appendChild(F);for(var G=0;G<M.length;G++){var H=M[G].getElementsByTagName("search")[0].firstChild.nodeValue;var K=M[G].getElementsByTagName("count")[0].firstChild.nodeValue;var C=M[G].getElementsByTagName("headline")[0].firstChild.nodeValue;K="&nbsp;";global_array[G]=String(H);var J=document.createElement("DIV");J.id=G;J.onmouseover=new Function("mouse_in('"+G+"')");J.onmouseout=new Function("mouse_out('"+G+"')");J.onclick=new Function("submitItem('"+G+"')");var B=document.createElement("SPAN");B.id=String("global_"+G);var N=document.createElement("SPAN");N.id=String("search_"+G);setStyle(N,"abcd");var I=document.createElement("SPAN");I.id=String("count_"+G);setStyle(I,"bcda");N.innerHTML=C;B.displaySpan=I;I.innerHTML=K;B.appendChild(N);B.appendChild(I);J.appendChild(B);Q.appendChild(J)}hilighted_index=-1;pre_hilighted_index=-1;enable_blur()}}}catch(L){hide_div()}}}function setStyle(B,A){switch(A.charAt(0)){case"a":B.style.visibility="visible";B.style.width="80%";B.style.fontSize="12px";B.style.fontFamily="Verdana, Arial, Helvetica";B.style.color=result_fg_color;B.style.whiteSpace="nowrap";B.style.styleFloat="left";B.style.cssFloat="left";B.style.textAlign="left";break;case"b":B.style.visibility="visible";B.style.width="20%";B.style.fontSize="12px";B.style.fontFamily="Verdana, Arial, Helvetica";B.style.color="#0000DE";B.style.styleFloat="right";B.style.cssFloat="right";B.style.textAlign="right";break;case"c":B.style.width="100%";B.style.weight="bold";B.style.fontFamily="Verdana, Arial, Helvetica";B.style.fontSize="15px";B.style.styleFloat="left";B.style.cssFloat="left";B.style.textAlign="left";break;default:break}}function ShowDiv(A){document.getElementById("gs_auto_div").style.visibility="visible";document.getElementById("gs_auto_div").style.background=result_bg_color;document.getElementById("gs_auto_div").style.border="solid 1px black"}function hide_div(){if(global_array.length){hide_all()}document.getElementById("gs_auto_div").style.visibility="hidden"}function hide_div_later(){setTimeout("hide_div()",100)}function hide_all(){for(var A=0;A<global_array.length;A++){document.getElementById("search_"+A).style.visibility="hidden";document.getElementById("count_"+A).style.visibility="hidden";document.getElementById("global_"+A).style.visibility="hidden";document.getElementById(A).style.visibility="hidden"}}UpDown=function(A,B){if(handleCursorUpDownEnter(B,A)||isShowKey(B)){return true}else{return false}};function isShowKey(A){if(A==40||A==38||A==33||A==34||A==13){return false}else{return true}}function handleCursorUpDownEnter(C,A){var B=document.getElementById("gs_auto_div");if(C==40){if(B.style.visibility=="visible"){highlightNewValue(Number(hilighted_index)+Number(1),C,A);return false}}else{if(C==38){if(B.style.visibility=="visible"){highlightNewValue(hilighted_index-1,C,A);return false}}else{if(C==13||C==3){if(C==13){enter=true;return submitHandlerIncr1(A)}return false}}}if(keycode!=0){ForEachKeyPressed(keycode,A)}return true}function highlightNewValue(A,C,B){if(A<0){if(prev_hilighted_index>=0){change_background(prev_hilighted_index,"2");prev_hilighted_index=-1}hilighted_index=-1;return }if(A>global_array.length-1){change_background(A-1,"1");hilighted_index=global_array.length-1;prev_hilighted_index=global_array.length-1;return }if(C==40){if(prev_hilighted_index>=0){change_background(prev_hilighted_index,"2")}change_background(A,"1");hilighted_index=A;prev_hilighted_index=A}if(C==38){if(prev_hilighted_index>=0){change_background(prev_hilighted_index,"2")}change_background(A,"1");hilighted_index=A;prev_hilighted_index=A}}function change_background(B,A){switch(A.charAt(0)){case"1":document.getElementById("search_"+B).style.backgroundColor=result_hi_color;document.getElementById("count_"+B).style.backgroundColor=result_hi_color;break;case"2":document.getElementById("search_"+B).style.backgroundColor=result_bg_color;document.getElementById("count_"+B).style.backgroundColor=result_bg_color;break;default:break}}function mouse_in(A){basic_style();change_background(A,"1");hilighted_index=A;prev_hilighted_index=A;disable_blur()}function mouse_out(A){change_background(A,"2");enable_blur()}function enable_blur(){var A=document.getElementById("global_search");A.onblur=new Function("hide_div_later()")}function disable_blur(){var A=document.getElementById("global_search");A.onblur=null}function basic_style(){for(i=0;i<global_array.length;i++){change_background(i,"2")}}function findPosX(A){var B=0;if(A.offsetParent){while(A.offsetParent){B+=A.offsetLeft;A=A.offsetParent}}else{if(A.x){B+=A.x}}return B}function findPosY(B){var A=0;if(B.offsetParent){while(B.offsetParent){A+=B.offsetTop;B=B.offsetParent}}else{if(B.y){A+=B.y}}return A}function ForEachKeyPressed(F,D){var A=document.getElementById("global_search");var B=document.getElementById("gs_auto_div");var E=A.value;var C=global_array.length;if(E==""||C==0||keycode==27||E.search(/\S/)==-1||(B.style.visibility=="hidden"&&(keycode==35||keycode==36))){hide_div()}}function submitHandlerIncr1(A){var B=document.getElementById(hilighted_index).id;document.getElementById("global_search").value=global_array[B];hide_div()}function submitItem(A){document.getElementById("global_search").value=String(global_array[A]);hide_div()};

function MM_openBrWindow(C,A,B){window.open(C,A,B)}function open_popup(C,A,B){window.open(C,A,B)}var pop;function show_win(){pop.focus()}function hide_win(A){pop.blur()}function get_form(C){for(var B=0;B<document.forms.length;B++){for(var A=0;A<document.forms[B].length;A++){if(document.forms[B].elements[A].name==C){return document.forms[B].elements[A].form}}}}function setCookie(B,D,A,F,C,E){document.cookie=B+"="+escape(D)+((A)?"; expires="+A.toGMTString():"")+((F)?"; path="+F:"")+((C)?"; domain="+C:"")+((E)?"; secure":"")}function getCookie(C){var B=document.cookie;var E=C+"=";var D=B.indexOf("; "+E);if(D==-1){D=B.indexOf(E);if(D!=0){return null}}else{D+=2}var A=document.cookie.indexOf(";",D);if(A==-1){A=B.length}return unescape(B.substring(D+E.length,A))}function deleteCookie(A,C,B){if(getCookie(A)){document.cookie=A+"="+((C)?"; path="+C:"")+((B)?"; domain="+B:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"}}function toggle_view(A){if(document.getElementById){if(document.getElementById(A).style.visibility=="visible"){document.getElementById(A).style.visibility="hidden"}else{document.getElementById(A).style.visibility="visible"}}else{if(document.layers&&document.layers[A]!=null){if(document.layers[A].visibility=="visible"||document.layers[A].visibility=="show"){document.layers[A].visibility="hidden"}else{document.layers[A].visibility="visible"}}else{if(document.all){if(document.all[A].style.visibility=="visible"){document.all[A].style.visibility="hidden"}else{document.all[A].style.visibility="visible"}}}}return false}function style_chkbx(C,A){C.checked==true?B=A:B="";do{C=C.parentNode}while(C.nodeName!="TR");var B;C.style.backgroundColor=B}function style_form(B,A){do{B=B.parentNode}while(B.nodeName!="TR");B.style.backgroundColor=A}function getselectedradio(A){if(A[0]){for(var B=0;B<A.length;B++){if(A[B].checked){return B}}}else{if(A.checked){return 0}}return -1}function getselectedradiovalue(A){var B=getselectedradio(A);if(B==-1){return false}else{if(A[B]){return A[B].value}else{return A.value}}}function dropdownvalue(A){return A.options[A.selectedIndex].value}function dropdowntext(A){return A.options[A.selectedIndex].text}function resetradios(C){var A=document.getElementsByTagName("input");for(var B=0;B<A.length;B++){if(A[B].type=="radio"){if(C){if(A[B].name==C){A[B].checked=false}}else{A[B].checked=false}}}}function selectfirstfield(){var A=document.getElementsByTagName("input");for(var B=0;B<A.length;B++){if(A[B].type=="text"){A[B].focus();break;alert(A[B].name)}}}function bullet(A){document.write("<table cellspacing=0 cellpadding=0 border=0 style='font-size:8px'><tr bgcolor='"+A+"'><td>&nbsp;&nbsp;</td></tr></table>")}function bullet1(A){document.write("<table cellspacing='0' cellpadding='0' align='left'><tr><td bgcolor='#000000'><table cellspacing=1 cellpadding=0 border=0 style='font-size:8px'><tr bgcolor='"+A+"'><td>&nbsp;&nbsp;</td></tr></table></td></tr></table>")}function bullet2(B,A,C){document.write("<table cellspacing='0' cellpadding='0' align='left'><tr><td bgcolor='#000000'><table cellspacing=1 cellpadding=0 border=0 style='font-size:8px'><tr bgcolor='"+B+"'><td style='"+A+"'>"+C+"</td></tr></table></td></tr></table>")}function confirm_click(B,A){if(confirm(B)){window.location=A}}function hide_advanced_search(){document.getElementById("advanced_search").style.visibility="hidden";document.getElementById("advanced_search").style.display="none";if(document.getElementById("category_search_box")){document.getElementById("category_search_box").style.visibility="hidden";document.getElementById("category_search_box").style.display="none"}document.getElementById("search").innerHTML='<a href="javascript:void(0);" onclick="javascript:show_advanced_search()">Advanced Search</a>'}function show_advanced_search(){document.getElementById("search").innerHTML='<a href="javascript:void(0);" onclick="hide_advanced_search()">Normal Search</a>';document.getElementById("advanced_search").style.visibility="visible";document.getElementById("advanced_search").style.display="inline";if(document.getElementById("category_search_box")){document.getElementById("category_search_box").style.visibility="visible";document.getElementById("category_search_box").style.display="inline"}return };

var debug=0;var max_error=20;var show_error=new Array();var i,z,err,pat,er;var error=0;var send="";var field_val,form_name;var back_m=0;var hi=new Array();var temp_hi=new Array();var tfname;var tkname=new Array();var process=1;function start(A){show_error[0]="Please make note of following things :\n";form_name=A.name;return }function finish(){error_counter("1");if(back_m==1){disable();back_m=0;return true}else{error_counter("2");error_counter("0");return false}}if(debug==1){alert("Validation In Testing Mode...\nPlease dont report bug for this\nFor Details : aditya@tradeindia.com")}function validate_text(field_id,field_name,field_type,min,max){if(debug==1){alert("in validate text for "+field_id)}var result=1;var message_x;var field_val=eval("document."+form_name+"."+field_id+".value");if(field_type=="char_up"){pat=/^[A-Z_-]+$/;message_x=" should consist only of characters in upper case A - Z";if(field_val.match(pat)){result=0}else{result=1}}if(field_type=="char_low"){pat=/^[a-z_-]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of characters in lower case a - z"}if(field_type=="char"){pat=/^[a-zA-Z\.]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of characters only a - z or A - Z"}if(field_type=="no_symbols"){pat=/^[a-zA-Z0-9. -]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should not consist of any non character values"}if(field_type=="user_id"){pat=/^[a-z0-9A-Z\_\.\&\-]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of characters(upper or lower),numbers (0-9),-,&,. or _ only."}if(field_type=="password"){pat=/^[a-z-0-9_]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of characters in lower case or numbers 0 - 9"}if(field_type=="phone"){pat=/^[0-9 \/ -]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of numbers 0-9, separate multiple numbers by /"}if(field_type=="mobile"){pat=/^[0-9+]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of characters 0-9 and +"}if(field_type=="mob_in"){pat=/^\+91[0-9+]{10,10}$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should begin with +91 and\nconsist only of characters 0-9 for Indian mobiles"}if(field_type=="num_coma"){pat=/^[0-9,]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of numericals 0 - 9 and comma"}if(field_type=="float"){pat=/^[0-9.]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of 0 - 9 and ."}if(field_type=="nonzero"){pat=/^[0-9]+$/;if(field_val.match(pat)&&field_val>0){result=0}else{result=1}message_x=" should be a number greater than zero "}if(field_type=="int"){pat=/^[0-9]*$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of numbers 0 - 9"}if(field_type=="char_int"){pat=/^[a-z0-9]+$/;if(field_val.match(pat)){result=0}else{result=1}message_x=" should consist only of characters in lower case a - z or numericals 0 - 9"}if(field_type=="string"){if(debug==1){alert("in string pat init")}var pat=/^[\s_.=]*$/;if(field_val.match(pat)){result=1}else{result=0}message_x=" should not be left blank or should consist of some valid values"}if(field_type=="email"){if(debug==1){alert("in email pat init")}if(emailCheck(field_val)==true){result=0}else{result=1}message_x=" should contain a valid email address "}if(debug==1){alert("field empty validation started")}var len=field_val.length;if(debug==1){alert("length is ="+len)}if(len==0&&min!=0){send="Please specify your "+field_name;hi[hi.length]=field_id;error_process(send);return false}if(debug==1){alert("field pattern validation started")}if(result==1){if(min==0&&len==0){}else{send=field_name+message_x;hi[hi.length]=field_id;error_process(send);return false}}if(debug==1){alert("field max min validation started")}if(max>0&&((len<min)||(len>max))){send="Length of "+field_name+" should be between "+min+" and "+max;hi[hi.length]=field_id;error_process(send);return false}else{if(len<min){if(debug==1){alert("field min validation started")}send="Length of "+field_name+" should be more than "+min;hi[hi.length]=field_id;error_process(send);return false}}if(debug==1){alert("field validation ended")}send="";return true}function validate_radio(radio_var,radio_name){if(debug==1){alert("validate radio called for "+radio_var)}var rOpt=-1;var defchecked;defchecked=eval("document."+form_name+"."+radio_var+".defaultChecked");if(defchecked){return true}for(var i=0;i<eval("document."+form_name+"."+radio_var+".length");i++){if(eval("document."+form_name+"."+radio_var+"["+i+"].checked")){rOpt=i;if(debug==1){alert("found one radio selected hence increasing counter")}}}if(rOpt==-1){if(debug==1){alert("counter was not increased during validation process hence no radio selected")}send="Please select one option for field "+radio_name;if(debug==1){alert("now sending error : "+send)}error_process(send);if(debug==1){alert("now returning radio valid false")}return false}else{if(debug==1){alert("counter was increased means that radio was selected hence return radio true")}return(true)}if(debug==1){alert("exit radio validate")}}function validate_dd(field_id,field_name){var str="document."+form_name+"."+field_id+".options.selectedIndex";if(eval(str)==0){hi[hi.length]=field_id;send="Please select a option in dropdown for field "+field_name;error_process(send)}}function validate_list(field_id,field_name,min){var inc=0;for(i=0;i<eval("document."+form_name+"."+field_id+".options.length");i++){if(eval("document."+form_name+"."+field_id+".options["+i+"].selected")){inc++;if(inc==min){break}}}if(inc<min){hi[hi.length]=field_id;send="Please select at least "+min+" option in list "+field_name;error_process(send)}}function validate_checkBox(arr,disc,typ,min){var x=0;eval("var newAr=new Array("+arr+");");for(var px=0;px<eval("newAr.length");px++){if(eval("document."+form_name+"."+newAr[px]+".checked")==true){x++}}if(x<min){if((x<min)&&(typ=="single")){for(var w=0;w<newAr.length;w++){hi[hi.length]=newAr[w]}send="You Must check "+disc+" Checkbox to submit this form";error_process(send)}if((x<min)&&(typ=="group")){send="Please select at least "+min+" checkbox"+((min>1)?"es":"")+" from "+disc;error_process(send)}}}function validate_confirm(field1,field2,disc){var field1_val=eval("document."+form_name+"."+field1+".value");var field2_val=eval("document."+form_name+"."+field2+".value");if(field1_val!=field2_val){send="The value for field "+disc+" is not confirmed";hi[hi.length]=field1;hi[hi.length]=field2;error_process(send)}}function validate_dates(G,C,F,E,B,A){var D=new Date(G,C,F);var H=new Date(E,B,A);if(H<D){send="End date should be after or equal to the start date";error_process(send)}}function error_process(A){if(process==1){if(error>=max_error){return }show_error[show_error.length]="-- "+A;error_counter("+")}if(process==0){filter=1}}function process_status(A){if(A=="start"){process=1}if(A=="stop"){process=0}return }function error_counter(A){switch(A){case"0":hi=new Array();error=0;break;case"1":if(error>0){back_m=0}else{back_m=1}break;case"+":error++;break;case"2":if(error>0){show_error[0]="Please re-enter the following field(s) again:\n";show_error[show_error.length]="\nPlease correct the above problems and submit again.";thi=hi;tkname=thi;tfname=form_name;alert(show_error.join("\n"));hi=new Array();field_id="";field_name="";field_type="";min=0;field_val="";temp_hi=hi;show_error=new Array();break}else{field_id="";field_name="";field_type="";min=0;field_val="";show_error=new Array();back_m=1;break}}}function disable(){return true;if(debug==1){alert("Disabling process started")}if(document.all||document.getElementById){for(i=0;i<eval("document."+form_name+".length");i++){var tempobj=eval("document."+form_name+".elements[i]");if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset"){tempobj.disabled=true;if(tempobj.type.toLowerCase()=="submit"){tempobj.value="Please wait .."}}}}}function high_light_clear(){for(var k=0;k<tkname.length;k++){if(eval("document."+tfname+"."+tkname[k]+".type")!="radio"&&"button"&&"hidden"){eval("document."+tfname+"."+tkname[k]+".style.backgroundColor=''")}}}function high_light(){tkname=hi;tfname=form_name;high_light_clear();high_light_clear();for(var l=0;l<hi.length;l++){if(eval("document."+form_name+"."+hi[l]+".type")!="radio"&&"button"&&"hidden"){eval("document."+form_name+"."+hi[l]+".style.backgroundColor='fff79e'")}}}var bbg=0;var thi=new Array();function blink_bg(bbg){if(bbg==0){for(var l=0;l<thi.length;l++){if(eval("document."+form_name+"."+thi[l]+".type")!="radio"&&"button"&&"hidden"){eval("document."+form_name+"."+thi[l]+".style.backgroundColor='fff79e'")}}bbg=1}else{for(var k=0;k<tkname.length;k++){if(eval("document."+tfname+"."+tkname[k]+".type")!="radio"&&"button"&&"hidden"){eval("document."+tfname+"."+tkname[k]+".style.backgroundColor=''")}}bbg=0}}function emailCheck(D){var K=D.split(",");for(var S=0;S<K.length;S++){var B=K[S];var U=/^(.+)@(.+)$/;var R='\\(\\)<>@,;:\\\\\\"\\.\\[\\]';var M="[^\\s"+R+"]";var E='("[^"]*")';var T=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;var A=M+"+";var Q="("+A+"|"+E+")";var N=new RegExp("^"+Q+"(\\."+Q+")*$");var G=new RegExp("^"+A+"(\\."+A+")*$");var C=B.match(U);if(C==null){return false}var V=C[1];var W=C[2];if(V.match(N)==null){return false}var J=W.match(T);if(J!=null){for(var O=1;O<=4;O++){if(J[O]>255){return false}}return true}var H=W.match(G);if(H==null){return false}var I=new RegExp(A,"g");var F=W.match(I);var P=F.length;if(F[F.length-1].length<2||F[F.length-1].length>8){return false}if(P<2){var L='This address is missing a hostname! "'+B+'"';return false}}return true};