﻿function Show(strId)
{
	var objElement;
	
	objElement = document.getElementById('div' + strId);
	
	if (objElement.style.display == 'none')
	  objElement.style.display = 'block';
	else
	  objElement.style.display = 'none';
}
function Submit_ok(){
	if (document.getElementById("Reply_content").value.length > 2){
		document.getElementById("Submit2").disabled=false;
		}else{
		document.getElementById("Submit2").disabled=true;	
		}
		
}

function GoSun(){
	GoPages = document.getElementById("GoPage");
	GetUrls= document.getElementById("GetUrl");
	if(parseInt(GoPages.value)!=GoPages.value || GoPages.value==""){ 
		GoPages.style.backgroundColor="#F60";
    }else{
		location.href=GetUrls.value + "&page=" + GoPages.value;
	}
}
function GoSun2(){
	GoPages = document.getElementById("GoPage");
	GetUrls= document.getElementById("GetUrl");
	if(parseInt(GoPages.value)!=GoPages.value || GoPages.value==""){ 
		GoPages.style.backgroundColor="#F60";
    }else{
		location.href=GetUrls.value + "?page=" + GoPages.value;
	}
}
function KeyUpBack(){
	GoPages = document.getElementById("GoPage");
	if(parseInt(GoPages.value)!=GoPages.value || GoPages.value==""){ 
		GoPages.style.backgroundColor="#F60";
    }else{
		GoPages.style.backgroundColor="#FFF";
	}
}

function reply(intid,runstr){
	var ri_title = document.getElementsByName("span_title");
	document.getElementById('Reply_title').value=runstr+":"+ri_title[intid-1].innerHTML;
}
function Action_add(VarUrl,IntID){
	var keyword=document.getElementById("KeyWord").value;
	if (keyword!=""){
		location.href=VarUrl+"?Journal_id="+IntID+"&Search=ok&keyword="+keyword+"&rnd=" + Math.random();
	}
}
function Action_add2(VarUrl,IntID){
	var keyword=document.getElementById("KeyWord").value;
	if (keyword!=""){
		location.href=VarUrl+"&Search=ok&keyword="+keyword+"&rnd=" + Math.random();
	}
}
function User_Action_add(VarUrl,IntID){
	var keyword=document.getElementById("KeyWord").value;
	if (keyword!=""){
		location.href=VarUrl+"?Cabinet_id="+IntID+"&Search=ok&keyword="+keyword+"&rnd=" + Math.random();
	}
}
function User_Action_add_dt(VarUrl,IntID){
	var keyword=document.getElementById("KeyWord").value;
	if (keyword!=""){
		location.href=VarUrl+"?Group_id="+IntID+"&Search=ok&keyword="+keyword+"&rnd=" + Math.random();
	}
}
function User_RC_add(VarUrl,IntID){
	var keyword=document.getElementById("KeyWord").value;
	if (keyword!=""){
		location.href=VarUrl+"?List_id="+IntID+"&Search=ok&keyword="+keyword+"&rnd=" + Math.random();
	}
}
function show_r(IntId){
	if (IntId=="1"){
		var StationsName=document.getElementsByName("Cabinet_Stations");
		if (StationsName.length==0){
			StationsName=document.getElementsByName("Journal_Stations");
		}
		StationsName[0].checked=true;
		Journal_Stationsjs(0);
		document.getElementById("pdf_tr").style.display="block";
		document.getElementById("html_tr").style.display="none";
	}else if(IntId=="0"){
		document.getElementById("pdf_tr").style.display="none";
		document.getElementById("html_tr").style.display="block";
	}
	
}
function modeint(){
	var modes=document.getElementsByName("Journal_mode");
	for(var i=0;i<modes.length;i++){ 
		if(modes[i].checked==true){
			if(modes[i].value=="0"){
				show_r('0');
			}else if(modes[i].value=="1"){
				show_r('1');
			}
		} 
	}
}
function Stationsback(){
	var StrStations=document.getElementsByName("Cabinet_Stations");
	//alert(StrStations.length);
	if (StrStations.length==0){
			StrStations=document.getElementsByName("Journal_Stations");
	}
	if (StrStations[1].checked==true){
			Journal_Stationsjs(1);
	}
}
function modeint2(){
	var modes=document.getElementsByName("Cabinet_mode");
	for(var i=0;i<modes.length;i++){ 
		if(modes[i].checked==true){
			if(modes[i].value=="0"){
				show_r('0');
			}else if(modes[i].value=="1"){
				show_r('1');
			}
		} 
	}
}
function payint(){
	var payints=document.getElementsByName("Journal_pay");
	for(var i=0;i<payints.length;i++){ 
		if(payints[i].checked==true){
			if(payints[i].value=="0"){
				Journal_payjs('0');
			}else if(payints[i].value=="1"){
				Journal_payjs('1');
			}
		} 
	}
}

function Stations(){
	var Stationss=document.getElementsByName("Journal_Stations");
	for(var i=0;i<Stationss.length;i++){
		if(Stationss[i].checked==true){
			if(Stationss[i].value=="0"){
				Journal_Stationsjs('0');
			}else if(Stationss[i].value=="1"){
				Journal_Stationsjs('1');
			}
		}
	}
}

function openmore(IngID){
	document.getElementById("jmores"+IngID).style.display="block";
}
function closemore(IngID){
	document.getElementById("jmores"+IngID).style.display="none";
}
function Journal_payjs(IntID){
	if (IntID=="1"){
		document.getElementById("price_s").style.display="block";
	}else if(IntID=="0"){
		document.getElementById("price_s").style.display="none";
	}
}

function Journal_Stationsjs(IntID){
	if (IntID=="1"){
		document.getElementById("Path_s").style.display="block";
		var Journal_modeStr=document.getElementsByName("Journal_mode");
		if (Journal_modeStr.length==0){
			Journal_modeStr=document.getElementsByName("Cabinet_mode");	
		}
		Journal_modeStr[0].checked=true;
		Journal_modeStr[1].checked=false;
		show_r(0);
	}else if(IntID=="0"){
		document.getElementById("Path_s").style.display="none";
	}
}

function ConfirmDel(){
if(document.form.Action.value=='del'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
 else if(document.form.Action.value=='del_Dissolve'){
     if(confirm('Once a Risk Circle is dissolved, all Discussion Thread/post/topic/information attached to this Risk Circle will be permanently deleted. Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
  else if(document.form.Action.value=='del_Dissolve_dt'){
     if(confirm('Once a Discussion Thread is deleted, all post/topic/information attached to this Discussion Thread will be permanently deleted. Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
 else if(document.form.Action.value=='ishot'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
 else if(document.form.Action.value=='nothot'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
 else if(document.form.Action.value=='isPublic'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
  else if(document.form.Action.value=='isPublic1'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
  else if(document.form.Action.value=='isPublic2'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
 else if(document.form.Action.value=='notPublic'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
  else if(document.form.Action.value=='Favorite'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
  else if(document.form.Action.value=='islock'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
 else if(document.form.Action.value=='isShare'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
 else if(document.form.Action.value=='notShare'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
  else if(document.form.Action.value=='notlock'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
   else if(document.form.Action.value=='istop'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
  else if(document.form.Action.value=='nottop'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
  else if(document.form.Action.value=='is Album Cover'){
     if(confirm('Are you sure you want to proceed?'))
         	document.form.submit();
 }
  else if(document.form.Action.value=='Delete'){
     if(confirm('Are you sure you want to proceed?'))
         	document.form.submit();
 }
  else if(document.form.Action.value=='not Album Cover'){
     if(confirm('Are you sure you want to proceed?'))
         	document.form.submit();
 }
 else if(document.form.Action.value=='Accept'){
     if(confirm('Are you sure you want to proceed?'))
         	document.form.submit();
 }
 else if(document.form.Action.value=='Refused'){
     if(confirm('Are you sure you want to proceed?'))
         	document.form.submit();
 }
  else if(document.form.Action.value=='isApprove'){
     if(confirm('Are you sure you want to proceed?'))
         return true;
     else
         return false;
 }
}

function Search(){
	if (document.getElementById("Keyword").value!=""){
		var s_types=document.getElementsByName("s_type");
		for(var i=0;i<s_types.length;i++){ 
			if(s_types[i].checked==true){
				if(s_types[i].value=="0" || s_types[i].value=="1"){
					document.getElementById("Searchforms").action="Librarys_list.asp?Search=ok";
				}else if(s_types[i].value=="2"){
					document.getElementById("Searchforms").action="Documents_list.asp?Search=ok";
				}
			} 
		}
		document.Searchforms.submit();	
	}
}

function Add_Bookshelf(IntId,backurlstr){
	location.href="Library_Save.asp?action=Add_Bookshelf&IntId="+IntId+"&backurlhttp="+backurlstr+"&rnd=" + Math.random();
}
function Down_Bookshelf(IntId){
	location.href="Library_Save.asp?action=Down_Bookshelf&IntId="+IntId+"&rnd=" + Math.random();
}
function Down_BookCabinet(IntId){
	location.href="Library_Save.asp?action=Down_BookCabinet&IntId="+IntId+"&rnd=" + Math.random();
}
function BS_Update(obj,Types){
	location.href="Basic_Settings.asp?Action=" + Types + "&rnd=" + Math.random();
	obj.value='Loading...';
	obj.disabled=true;
}
function SH_HDIV(){
	var targelem = document.getElementById('hdiv');
    targelem.style.display='block';
	if (window.innerHeight){
		if(document.body.clientHeight < window.innerHeight){
			targelem.style.height = window.innerHeight+"px";
		}
		else{
			targelem.style.height = document.body.clientHeight+"px";
		}
	}
	else{
		if(document.body.scrollHeight < document.documentElement.offsetHeight){
			targelem.style.height = document.documentElement.offsetHeight+"px";
		}else{
			targelem.style.height = document.body.scrollHeight+"px";
		}
	}
}
function Show_OD(){
	SH_HDIV();
	var select_dom_arr=document.getElementsByTagName("select");
	for(var i=0;i<select_dom_arr.length;i++){
		select_dom_arr[i].style.visibility="hidden";
	}
	var targelem2 = document.getElementById('htmldiv');
    targelem2.style.display='block';
	leftx()
}
function Show_SP(){
	SH_HDIV();
	var targelem2 = document.getElementById('htmldiv2');
    targelem2.style.display='block';
	leftx2()
}
function Hide_OD(){
	var select_dom_arr=document.getElementsByTagName("select");
	for(var i=0;i<select_dom_arr.length;i++){
		select_dom_arr[i].style.visibility="visible";
	}
	var targelem = document.getElementById('htmldiv');
    targelem.style.display='none';
	var targelem2 = document.getElementById('hdiv');
	targelem2.style.display='none';
	}
function Hide_SP(){
	var targelem = document.getElementById('htmldiv2');
    targelem.style.display='none';
	var targelem2 = document.getElementById('hdiv');
	targelem2.style.display='none';
	}
function Check_OD(){
	if (document.getElementById("checksub")){
		if (document.getElementById("checksub").checked==false){
			alert("Please review terms governing submission first");
		}else{
			if (document.getElementById("OD_Description").value!=""){
				document.ODforms.submit();
			}else{
				alert('* Required Fields');
				document.ODforms.OD_Description.focus();
			}
		}
	}else{
		if (document.getElementById("OD_Description").value!="")
		document.ODforms.submit();	
	}
}
function Check_SP(){
	if (document.getElementById("Cabinet_cont").value!=""){
		document.SPforms.submit();
	}else{
		alert('* Required Fields');
		document.SPforms.Cabinet_cont.focus();
	}
}
function leftx(){
    var o = document.getElementById("htmldiv");
	//var o2 = document.getElementById("mmm2");
    var w = o.clientWidth||o.offsetWidth;
	var lefts=(document.documentElement.offsetWidth-w)/2;
    o.style.left=lefts+"px";
	//o2.style.width=(w-20)+"px";

}
function leftx2(){
    var o = document.getElementById("htmldiv2");
	//var o2 = document.getElementById("mmm2");
    var w = o.clientWidth||o.offsetWidth;
	var lefts=(document.documentElement.offsetWidth-w)/2;
    o.style.left=lefts+"px";
	//o2.style.width=(w-20)+"px";

}
function Online_Payment(IntID){
	alert("["+IntID+"] On The Make...");
}
function SForms(sAuthors_name,sJournal_title,sJournal_tags,sJournal_txt,SearchType){
	if(sAuthors_name.length<1 && sJournal_title.length<1 && sJournal_tags.length<1 && sJournal_txt.length<1){
		alert("Parameter Error!");
	}else{
		if(SearchType==0 || SearchType==1)
			document.getElementById("S_Form").action="/Librarys_list.asp?Search=ok";
		if(SearchType==2)
			document.getElementById("S_Form").action="/Documents_Search.asp?Search=ok";
		document.S_Form.submit();
	}
	
}
function ConfirmInvite(){
		var pattern =  /^([a-zA-Z0-9_-]|[\.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
		var MailBool = pattern.test(document.Inviteform.User_Mail.value);  
		if(document.Inviteform.User_Mail.value==''){
			alert('Please enter E-Mail!');
			document.Inviteform.User_Mail.focus();
			return false;
		 }
		 else if(!MailBool){
			alert('Please fill out in proper format!');
			document.Inviteform.User_Mail.focus();
			return false;
		 }
		 document.Inviteform.submit.disabled=true;
		 document.Inviteform.submit.value='loading...';
}
function pic_preview(imgid){
	pic_url=document.getElementById(imgid).value;
	if (pic_url!=""){
		document.getElementById("pic_view").src=pic_url;
	}
}
function SelectArray(){
	var Newoptions = new Array();
	Newoptions[0]=new Array("Document","0","1");
	Newoptions[1]=new Array("News","0","2");
	Newoptions[2]=new Array("Risk Circles","0","3");
	Newoptions[3]=new Array("Discussion Thread","0","4");
	Newoptions[4]=new Array("FAQ","0","5");
	Newoptions[5]=new Array("Photos","3","1");
	Newoptions[6]=new Array("Events","3","2");
	Newoptions[7]=new Array("Announcements","3","3");
	Newoptions[8]=new Array("Topic","4","4");
	return Newoptions;
}

function selecttwo(GETStr){
	Newoptions= new SelectArray();
	//alert(Newoptions[0][0]);
	//var optionsone=document.getElementById("SectionOne");
	//var optionstwo=document.getElementById("SectionTwo");
	//var optionstwos=document.getElementsByName("SectionTwo");
	var onecount=Newoptions.length;
	if(document.getElementById("SectionOne").value==1){
		document.getElementById("datetd").style.display="";
	}else{
		document.getElementById("datetd").style.display="none";
	}
	if(document.getElementById("SectionOne").value!=0){
		//document.getElementById("SectionTwo").style.display="block";
		if(document.getElementById("SectionOne").value==3 || document.getElementById("SectionOne").value==4){
			document.getElementsByName("SectionTwo").SectionTwo.length = 0;
		}else{
			document.getElementsByName("SectionTwo").SectionTwo.length = 1;
			document.getElementById("SectionTwo").options[0]=new Option("All Categories","0");
		}
		var ListI=0;
		for (i=0;i < onecount; i++){
			if (Newoptions[i][1] == GETStr){
				ListI++;
				//alert(document.Searchforms.SectionOne.length);
				//alert(document.getElementById("SectionOne").length);
				document.getElementById("SectionTwo").options[document.getElementById("SectionTwo").length]=new Option(Newoptions[i][0], Newoptions[i][2]);
			}
		}
		if(ListI==0)
			document.getElementById("SectionTwo").disabled=true;
			//document.getElementById("SectionTwo").style.display="none";
		else
			//document.getElementById("SectionTwo").value = 2;
			document.getElementById("SectionTwo").disabled=false;
			//document.getElementById("SectionTwo").style.display="none";
	}else{
		document.getElementsByName("SectionTwo").SectionTwo.length = 1;
		document.getElementById("SectionTwo").options[0]=new Option("All Categories","0");	
	}
}

function selecttwolist(GETStr){
	NewoptionsList= new SelectArrayList();
	var onecount=NewoptionsList.length;
	
	if(document.getElementById("List_type").value!=-1){
		//document.getElementById("SectionTwo").style.display="block";
		document.getElementsByName("List_id").List_id.length = 1;
		document.getElementById("List_id").options[0]=new Option("---------Select---------","0");
		var ListI=0;
		for (i=0;i < onecount; i++){
			if (NewoptionsList[i][1] == GETStr){
				ListI++;
				//alert(document.Searchforms.SectionOne.length);
				//alert(document.getElementById("SectionOne").length);
				document.getElementById("List_id").options[document.getElementById("List_id").length]=new Option(NewoptionsList[i][0], NewoptionsList[i][2]);
			}
		}
		if(ListI!=0)
			document.getElementById("List_id").style.display="block";
	}else{
		document.getElementById("List_id").style.display="none";
	}
}

function ONSubmit(){
	document.SearchListForm.submit();		
}

function CallTwoSelect(OneInt,TwoInt){
	if(OneInt!=0 && OneInt!=""){
		if(OneInt==1){
			document.getElementById("datetd").style.display="";
		}else{
			document.getElementById("datetd").style.display="none";
		}
		document.getElementById("SectionOne").value = OneInt;
		Newoptions= new SelectArray();
		var onecount=Newoptions.length;
		if(OneInt==3 || OneInt==4){
			document.getElementsByName("SectionTwo").SectionTwo.length = 0;
		}else{
			document.getElementsByName("SectionTwo").SectionTwo.length = 1;
			document.getElementById("SectionTwo").options[0]=new Option("All Categories","0");
		}
			var ListI=0;
			for (i=0;i < onecount; i++){
				if (Newoptions[i][1] == OneInt){
					ListI++;
					document.getElementById("SectionTwo").options[document.getElementById("SectionTwo").length]=new Option(Newoptions[i][0], Newoptions[i][2]);
				}
			}
			if(ListI==0){
				document.getElementById("SectionTwo").disabled=true;
			}else{
				document.getElementById("SectionTwo").value = TwoInt;
				document.getElementById("SectionTwo").disabled=false;
			}
	}
}

function SearchList(){
		var SectionOnes=document.getElementById("SectionOne");
		var SectionTwos=document.getElementById("SectionTwo");
		if(SectionOnes.value!=0){
			if(SectionTwos.value==0){
				if(SectionOnes.value==1)
					document.getElementById("SearchListForm").action="Documents_list.asp?Search=ok";
				if(SectionOnes.value==2)
					document.getElementById("SearchListForm").action="News.asp?Search=ok";
				if(SectionOnes.value==5)
					document.getElementById("SearchListForm").action="FAQ.asp?Search=ok";
				if(SectionOnes.value==1){
					if(document.SearchListForm.Keyword.value!="" || (document.SearchListForm.Journal_riqi.value!="" && document.SearchListForm.Journal_riqi2.value!="")){
						ONSubmit();
					}
				}else{
					if(document.SearchListForm.Keyword.value!=""){
						ONSubmit();
					}
				}
			}else{
				if(SectionTwos.value==1)
					document.getElementById("SearchListForm").action="Search_RC_Photos.asp?Search=ok";
				if(SectionTwos.value==2)
					document.getElementById("SearchListForm").action="Search_RC_Events.asp?Search=ok";
				if(SectionTwos.value==3)
					document.getElementById("SearchListForm").action="Search_RC_Announcements.asp?Search=ok";
				if(SectionTwos.value==4)
					document.getElementById("SearchListForm").action="Search_DT_Topic.asp?Search=ok";
				if(document.SearchListForm.Keyword.value!=""){
					ONSubmit();
				}
			}
		}
}
function onSubmitEvent(){
	SearchList();
	return false;
}
function Document_View_SUB(backstr){
     if(confirm('Please click on “Cancel” to Login, or click on “Ok” to register a new account.')){
         location.href="/RegSelect.asp";
	 }else{
		 location.href=backstr;
	 }
}
function Save_Edit(TypeID){
	if(TypeID==0){
		document.getElementById("EditForm").action="Library_Save_Cabinet.asp";
	}else if(TypeID==1){
		document.getElementById("EditForm").action="Library_Save_Down.asp";
	}
	document.EditForm.submit();
}
function selecttolist(objval){
	if(objval=="no"){
		document.getElementById("Search_div").style.display="block";
	}else{
		document.getElementById("Search_div").style.display="none";
	}
}
function Search_exec(){
	if(document.getElementById("keyword").value!=''){
		location.href='Members_Search.asp?keyword='+document.getElementById("keyword").value;
	}	
}
function All_Select_Fun(obj){
	var checkboxdoms = document.getElementsByTagName("INPUT");
	for(var i=0;i<checkboxdoms.length;i++){
		if(checkboxdoms[i].type=="checkbox" && checkboxdoms[i].checked==false){
			checkboxdoms[i].checked=true;
		}else if(checkboxdoms[i].type=="checkbox" && checkboxdoms[i].checked==true){
			checkboxdoms[i].checked=false;
		}
	}
}