// JavaScript Document

function Global_validate(obj)
  {
    var len=obj.length;
	for(i=0;i<len;i++)
	  {
	    if(obj.elements[i].title!='' && obj.elements[i].value=='' && obj.elements[i].disabled==false)
		  {
		    alert(obj.elements[i].title);
			obj.elements[i].focus();
			return false;
		  }
	  }
	return true;
  }
  
  
  function removeSpaces(string,obj) 
	{
		var tstring = "";
		string = '' + string;
		splitstring = string.split(" ");
		for(i = 0; i < splitstring.length; i++)
		{
			tstring += splitstring[i];
		}
		obj.value=tstring;
	}

  function trimspaces(str)
		{
			while((str.indexOf(' ',0) == 0) && (str.length > 1))
			{
				str = str.substring(1, str.length);
			}
			while((str.lastIndexOf(' ') == (str.length - 1) && (str.length > 1)))
			{
				str = str.substring(0,(str.length - 1));
			}
			if((str.indexOf(' ',0) == 0) && (str.length == 1)) str = '';
			return str;
		}
		  


	function validate_form(Obj)
		{

				var paid=md=0;
				for ( i = 0; i < Obj.elements.length; i++) 
				{
						formElem = Obj.elements[i];
						
						if(formElem.name=='subs' && formElem.value=='paid' && formElem.checked==true)
							paid=1;
						
						if(paid==1)
						{
							if(formElem.name=='fee' && (formElem.value=='' || formElem.value==0 ))	
							{
								alert("Please Enter Fee Amount");
								formElem.focus();
								return false;
							}							
						}
						
						if(formElem.name=='mand' && formElem.value==1 && formElem.checked==true)
							md=1;
						
						if(md==1)
						{
							if(formElem.name=='mand_title' && formElem.value=='')	
							{
								alert("Please enter mandatory title");
								formElem.focus();
								return false;
							}							
						}
						
					
					if(Obj.name=='frm_member_profile')
					{
						
						if(trimspaces(document.getElementById("password").value)!='' && trimspaces(document.getElementById("transactPassword").value)!='')
						{
							if(document.getElementById("password").value==document.getElementById("transactPassword").value)
							{
								alert("Transaction Password Should be Different .");
								document.getElementById("transactPassword").focus();
								return false;
							}
						}
					}
					
						
						
						if(formElem.name=='item_content' && formElem.value!='')
						{
							if(formElem.value.length>250)
							{
								alert("The item content should not exceed 250 characters");
								formElem.focus();
								return false;
							}
						}
						
						if(formElem.name=='item_content_russian' && formElem.value!='')
						{
							if(formElem.value.length>250)
							{
								alert("The item content should not exceed 250 characters");
								formElem.focus();
								return false;
							}
						}
						
						if(formElem.type=='checkbox' && formElem.checked==false)
						{
							split_title=formElem.title.split("::");
							alert(split_title[1]);
							formElem.focus();
							return false;
						}
						
						switch (formElem.type) {
								case 'text':
								case 'password':
								case 'select-one':
								case 'textarea':
								case 'file':
								case 'select-multiple':
										split_title=formElem.title.split("::");
										//alert(split_title[0]+"="+formElem.value);
										if(split_title[0]=='mandatory' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory2' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory2'  && isNaN(formElem.value)){
										alert('Please enter numeric value only');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory2'  && parseInt(formElem.value)<=0){
										alert('Phone Number/Country Code should not have a prefix as Zero');
										formElem.focus();
										return false;
										}
										
										if(split_title[0]=='mandatory22' && trimspaces(formElem.value)!=''){
											
/*										if(split_title[0]=='mandatory22' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
*/										if(split_title[0]=='mandatory22'  && isNaN(formElem.value)){
										alert('Please enter numeric value only');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory22'  && parseInt(formElem.value)<=0){
										alert('Mobile Number/Country Code should not have a prefix as Zero');
										formElem.focus();
										return false;
										}
										}
										//START-- CHECK EMAIL FOR MANDATORY [M] FIELD --//
										if(split_title[0]=='FillEmailM' && trimspaces(formElem.value)=='')
										{
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										
										if(split_title[0]=='FillEmailM')
										{
											var fv=formElem.value;
											
											// FOR COMMA SEPARATED EMAIL IDS   (by ABHISHEK SRIVASTAVA)
											
											if(fv.indexOf(',')>0)
											{
												var valArray=new Array();
												var chkVal=0;
												valArray=fv.split(',');
												
												if(valArray.length>50)
												{
													alert('You Can Enter Maximum 50 Email Ids.');
													formElem.focus();
													return false;
												}
												else
												{
													while(chkVal<valArray.length)
													{
														var t=trimspaces(valArray[chkVal]);
														
														if(valArray.length==2 && chkVal==1 && t=='')
														{
															chkVal=valArray.length;
														}
														else
														{
															t=t.replace(/[\r\n]+/g, "");
															if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(t))
															{
															}
															else
															{
															alert('Invalid E-mail Address! Please re-enter.');
															formElem.focus();
															return false;
															}
															chkVal++;
														}
													}
												}
											}
											// END COMMA SEPARATED EMAIL IDS 
											
											else
											{
											if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formElem.value)){
												
												}else{
													alert('Invalid E-mail Address! Please re-enter.');
													formElem.focus();
													return false;
											}
											}
											
										}
										//START-- CHECK EMAIL FOR MANDATORY [M] FIELD --//
										
										//START-- CHECK EMAIL FOR NOT MANDATORY [NM] FIELD --//
										if(split_title[0]=='FillEmailNM')
										{
											if(trimspaces(formElem.value)!='')
											{
												if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formElem.value)){
												}else
												{
													alert(split_title[1]);
													formElem.focus();
													return false;
												}
											}
										}
										//END-- CHECK EMAIL FOR NOT MANDATORY FIELD --//
										
									//START-- VALIDATION FOR TEXT LENGTH [M- mandatory]--// 
										if(split_title[0]=='TxtLenMinAndMaxM'  && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='TxtLenMinAndMaxM'  && (formElem.value.length) < split_title[2]){
										alert('Please Enter Minimum ' + split_title[2] +split_title[4]);
										formElem.focus();
										return false;
										}
										/*
										if(split_title[0]=='TxtLenMinAndMaxM'  && (formElem.value.length) > split_title[3]){
										alert('Please Enter Maximum ' + split_title[3] +split_title[4]);
										formElem.focus();
										return false;
										}
										*/
									//END-- VALIDATION FOR TEXT LENGTH [NM- mandatory]--//
									
									//START-- VALIDATION FOR TEXT LENGTH [M- mandatory]--// 
										if(split_title[0]=='TxtLenMinAndMaxNM'  && trimspaces(formElem.value)!=''){
																				
											if(split_title[0]=='TxtLenMinAndMaxNM'  && (formElem.value.length) < split_title[2]){
											alert('Please Enter Minimum ' + split_title[2] +split_title[4]);
											formElem.focus();
											return false;
											}
											/*
											if(split_title[0]=='TxtLenMinAndMaxNM'  && (formElem.value.length) > split_title[3]){
											alert('Please Enter Maximum ' + split_title[3] +split_title[4]);
											formElem.focus();
											return false;
											}
											*/
										}
									//END-- VALIDATION FOR TEXT LENGTH [M- mandatory]--//
									//START-- CHECK IMAGE [M] FOR MANDATORY FIELD --//
										if(split_title[0]=='FillimgM')
										{
											if(formElem.value=='')
											{
												alert("Please Select a Document.");
												formElem.focus();
												return false;
											}
											
											var valid_extensions = /(.jpg|.jpeg|.png|.gif|.bmp|.pdf)$/;
											if(!valid_extensions.test(formElem.value.toLowerCase()))
											{
												alert(split_title[1]);
												formElem.focus();
												return false;
											}
										}
									//END-- CHECK IMAGE [M] FOR MANDATORY FIELD --//
									
					//START-- PASSWORD VALIDATION --//
								if(split_title[0]=='passwordM' && trimspaces(formElem.value)=='' )
								{
									alert(split_title[1]);
									formElem.focus();
									return false;
								}
								else if(split_title[0]=='passwordM' && trimspaces(formElem.value)!='' )
								{ var passwordVal=formElem.value; }
								
								
								if(split_title[0]=='confirmPasswordM' && trimspaces(formElem.value)=='' )
								{
									alert(split_title[1]);
									formElem.focus();
									return false;
								}
								else if(split_title[0]=='confirmPasswordM' && trimspaces(formElem.value)!='' )
								{ 
									var confirmPasswordVal=formElem.value; 
									if(passwordVal!=confirmPasswordVal)
									{
										alert("Confirm password should not be the same as password !");
										formElem.focus();
										return false;
									}
								}
								//START -- AT THE TIME OF CHANGE PASSWORD -----//
									if(split_title[0]=='oldPasswordM' && trimspaces(formElem.value)=='' )
									{
										alert(split_title[1]);
										formElem.focus();
										return false;
									}
									
									if(split_title[0]=='newPasswordM' && trimspaces(formElem.value)=='' )
									{
										alert(split_title[1]);
										formElem.focus();
										return false;
									}
									else if(split_title[0]=='newPasswordM' && trimspaces(formElem.value)!='' )
									{ var newPasswordVal=formElem.value; }
									
									
									if(split_title[0]=='confirmNewPasswordM' && trimspaces(formElem.value)=='' )
									{
										alert(split_title[1]);
										formElem.focus();
										return false;
									}
									else if(split_title[0]=='confirmNewPasswordM' && trimspaces(formElem.value)!='' )
									{ 
										var confirmNewPasswordVal=formElem.value; 
										if(newPasswordVal!=confirmNewPasswordVal)
										{
											alert("Please verify your Password again!");
											formElem.focus();
											return false;
										}
									}
									if(split_title[0]=='newPasswordM' )
									{
											if(formElem.value !='')
												{
													var strLength = formElem.value.length;
													var spaceindex = formElem.value.lastIndexOf(' ');
													//if(strLength < 5 || strLength > 15)
													if(strLength < 5)
													{
														alert("New password length must be 5-15 characters.");
														formElem.focus();
														return false;
													}
												}
									}
								//END -- AT THE TIME OF CHANGE PASSWORD -----//
								
						//END-- PASSWORD VALIDATION --//
									
									
									
										if(split_title[0]=='mandatory4' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory4' ){
											if(formElem.value !='')
												{
													var strLength = formElem.value.length;
													var spaceindex = formElem.value.lastIndexOf(' ');
													if(strLength < 5)
													{
														alert("Please enter "+formElem.name+" atleast 5 characters.");
														formElem.focus();
														return false;
													}
													if(spaceindex!='-1')
													{
														alert("Please remove space from "+formElem.name+".");
														formElem.focus();
														return false;
													}
												}
										}
										if(split_title[0]=='mandatory5' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory5' && !isNaN(formElem.value)){
										alert("Please enter only letters");
										formElem.focus();
										return false;
										}
										
																				
										if(split_title[0]=='mandatory6' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory6'  && isNaN(formElem.value)){
										alert('Please enter numeric value');
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory6'  && parseInt(formElem.value)<0){
										alert('Please enter positive value');
										formElem.focus();
										return false;
										}
										
										if(split_title[0]=='mandatory7' && trimspaces(formElem.value)!=''){
											if(split_title[0]=='mandatory7'  && isNaN(formElem.value)){
											alert('Please enter numeric value');
											formElem.focus();
											return false;
											}
											if(split_title[0]=='mandatory7'  && parseInt(formElem.value)<=0){
											alert('Please enter positive value');
											formElem.focus();
											return false;
											}
										}
										
										if(split_title[0]=='mandatory8' && trimspaces(formElem.value)!=''){
											if(split_title[0]=='mandatory8'  && isNaN(formElem.value)){
											alert('Please enter benchmark zone value between 1 to 100');
											formElem.focus();
											return false;
											}
											if(split_title[0]=='mandatory8'  && parseInt(formElem.value)<=0){
											alert('Please enter benchmark zone value between 1 to 100');
											formElem.focus();
											return false;
											}
											if(split_title[0]=='mandatory8'  && parseInt(formElem.value)>100){
											alert('Please enter benchmark zone value between 1 to 100');
											formElem.focus();
											return false;
											}
										}
										if(split_title[0]=='mandatory9' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory9' && formElem.value.length!=3){
										alert("Please enter 3 characters");
										formElem.focus();
										return false;
										}
										if(split_title[0]=='mandatory10' && trimspaces(formElem.value)!=''){
											if(split_title[0]=='mandatory7'  && isNaN(formElem.value)){
											alert('Please enter numeric value');
											formElem.focus();
											return false;
											}
										}
										if(split_title[0]=='Fill11' && trimspaces(formElem.value)==''){
										alert(split_title[1]);
										formElem.focus();
										return false;
										}
										if(split_title[0]=='Fill11' ){
											if(formElem.value !='')
												{
													var strLength = formElem.value.length;
													var spaceindex = formElem.value.lastIndexOf(' ');
													if(strLength < 6)
													{
														alert("Please enter "+formElem.name+" atleast 6 characters.");
														formElem.focus();
														return false;
													}
													if(spaceindex!='-1')
													{
														alert("Please remove space from "+formElem.name+".");
														formElem.focus();
														return false;
													}
												}
										}
										if(split_title[0]=='Fill12' ){
											if(Obj.elements[i].value!=Obj.elements[i-1].value)
												{
													alert("Password Mismatched");
													formElem.focus();
													return false;
												}
										}
											
							if(formElem.name=='email')
							{
								var email1=formElem.value;
								
							}
							
							if(formElem.name=='confirn_email')
							{
								var email2=formElem.value;	
								if(email1!=email2)
								{
									alert("Email and retype email should be same.");
																	
									formElem.focus();
									return false;
								}
							}
					
					if(Obj.name=='add_temp_member')
					{
						
						//-- check login password --
						if(trimspaces(document.getElementById("password").value)=='')
						{
							alert("Enter login password first.");
							document.getElementById("password").focus();
							return false;
						}
						if(trimspaces(document.getElementById("verify_Lpassword").value)=='')
						{
							alert("Verify login password .");
							document.getElementById("verify_Lpassword").focus();
							return false;
						}
						if(trimspaces(document.getElementById("password").value)!='' && trimspaces(document.getElementById("verify_Lpassword").value)!='')
						{
							if(document.getElementById("password").value!=document.getElementById("verify_Lpassword").value)
							{
								alert("Passwords do not match.");
								document.getElementById("verify_Lpassword").focus();
								return false;
							}
						}
					}
					
					
					if(Obj.name=='admin_member_frm')
					{
						
						//-- check login password --
						if(trimspaces(document.getElementById("password").value)=='')
						{
							alert("Enter login password first.");
							document.getElementById("password").focus();
							return false;
						}
						if(trimspaces(document.getElementById("verify_Lpassword").value)=='')
						{
							alert("Verify login password .");
							document.getElementById("verify_Lpassword").focus();
							return false;
						}
						if(trimspaces(document.getElementById("password").value)!='' && trimspaces(document.getElementById("verify_Lpassword").value)!='')
						{
							if(document.getElementById("password").value!=document.getElementById("verify_Lpassword").value)
							{
								alert("Verify password should be the same as login password.");
								document.getElementById("verify_Lpassword").focus();
								return false;
							}
						}
						//-- check transaction password --
						if(trimspaces(document.getElementById("transactPassword").value)!='' && trimspaces(document.getElementById("verify_Tpassword").value)!='')
						{
							if(document.getElementById("transactPassword").value!=document.getElementById("verify_Tpassword").value)
							{
								alert("Verify transaction password should be same as transaction password.");
								document.getElementById("verify_Tpassword").focus();
								return false;
							}
						}
						//--  login password can not be same as transaction password --
						if(trimspaces(document.getElementById("password").value)== trimspaces(document.getElementById("transactPassword").value))
						{
							alert("Transaction password should not be the same as login password.");
								document.getElementById("transactPassword").focus();
								return false;
						}
					}
						
							
							if(split_title[0]=='mandatorygroup'){
								if(document.getElementById('group_radio1').checked == true)
								{
										if(document.getElementById('group_name').value=='' )
										{
											alert('Please Enter Group Name.');
											document.getElementById('group_name').focus();
											return false;
										}
										if(document.getElementById('comparison_option').value=='' )
										{
											alert('Please Select One Option.');
											document.getElementById('comparison_option').focus();
											return false;
										}
								}
								
								
								else if(document.getElementById('group_radio2').checked == true)
								{
										if(document.getElementById('group_name2').value=='' )
										{
											alert('Please Select Group Name.');
											document.getElementById('group_name2').focus();
											return false;
										}	
								}
								
							}
					break;
					}
			}//end of for loop
			return true;
		}  

function CheckAll(obj)
{
	//alert(obj);
	var count = obj.elements.length;
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox' && obj.elements[i].name=='chk[]')
			obj.elements[i].checked = obj.chkall.checked;
	}
}

function CheckAll_invit(obj)
{
	//alert(obj);
	var count = obj.elements.length;
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox' && obj.elements[i].name=='invite[]')
			obj.elements[i].checked = obj.chkall_invite.checked;
	}
}

function doAction(action,obj,msgtype)
{
	
	//alert(action+" =="+obj);
	var count = obj.elements.length;
	
	var flag=false;
	var msg = "";
	if(msgtype !='')
	{
		msg = msgtype;	
	}
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			if(obj.elements[i].checked == 1)
				flag=true;
		}
	}
	if(flag==true)
	{
		if(window.confirm("Do you want to delete "+msg))
		{
			obj.action.value=action;
			obj.submit();
		}
		else
		{
			var count = obj.elements.length;
			for (i=0; i < count; i++) 
			{
				obj.elements[i].checked =0;
				flag=false;
			}
		}
	}
	else
		alert("Please select at least one record to perform the action.");
}
function doActionContact(action,obj,msgtype)
{
	
	//alert(action+" =="+obj);
	var count = obj.elements.length;
	
	var flag=false;
	var msg = "";
	if(msgtype !='')
	{
		msg = msgtype;	
	}
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			if(obj.elements[i].checked == 1)
				flag=true;
		}
	}
	if(flag==true)
	{
		if(window.confirm("Do you want to delete "+msg))
		{
			obj.act.value=action;
			obj.submit();
		}
		else
		{
			var count = obj.elements.length;
			for (i=0; i < count; i++) 
			{
				obj.elements[i].checked =0;
				flag=false;
			}
		}
	}
	else
		alert("Please select at least one record to perform the action.");
}

function doActionMsg(action,obj,msgtype,loc)
{
	//alert(action+" =="+obj);
	var count = obj.elements.length;
	
	var flag=false;
	var msg = "";
	if(msgtype !='')
	{
		msg = msgtype;	
	}
	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox')
		{
			if(obj.elements[i].checked == 1)
				flag=true;
		}
	}
	if(flag==true)
	{
		if(window.confirm("Do you want to delete "+msg))
		{
			obj.action.value=action;
			obj.loc.value=loc;
			obj.submit();
		}
		else
		{
			var count = obj.elements.length;
			for (i=0; i < count; i++) 
			{
				obj.elements[i].checked =0;
				flag=false;
			}
		}
	}
	else
		alert("Please select at least one record to perform the action.");
}

function doShow(action,obj,mid)
{
	//alert(action+" =="+obj);
	
	var count = obj.elements.length;
	var count1=0;
	var flag=false;

	for (i=0; i < count; i++) 
	{
		if(obj.elements[i].type == 'checkbox' && obj.elements[i].name=='show[]')
		{

			if(obj.elements[i].checked==true)
				count1=count1+1;
				
			if(obj.elements[i].checked == true)
				flag=true;
		}
	}
	if(flag==true)
	{
		switch(mid)
		{
			case 2:
				if(count1>4)
				{
					alert("You can not select more than 4 fields to show");
					obj.unset.value=1;
				}
				else if(count1<4)
				{
					alert("You can not select less than 4 fields to show");
					obj.unset.value=1;
				}
			break;
			
			case 14:
			
				if(count1>3)
				{
					alert("You can not select more than 3 fields to show");
					obj.unset.value=1;
				}
				else if(count1<3)
				{
					alert("You can not select less than 3 fields to show");
					obj.unset.value=1;
				}
				break;
			
			case 5:
			case 17:
			case 6:
			
				if(count1>1)
				{
					alert("You can not select more than 1 fields to show");
					obj.unset.value=1;
				}
				break;
				
			default:
				break;
		}
		
		obj.action.value=action;
		obj.submit();
	}
	else
	{
		alert("Please select at least one Record to perform the action.");
		obj.unset.value=1;
		obj.submit();
	}
}

function delete_record(id,msgtype)
{
	var count = document.adminForm.elements.length;
	var flag=false;
	var msg = "";
	//alert(msgtype);
	if(msgtype !='')
	{
		msg = msgtype;
	}

	for (i=0; i < count; i++) 
	{
		if(document.adminForm.elements[i].type == 'checkbox')
		{
			if(document.adminForm.elements[i].value==id){
			document.adminForm.elements[i].checked =1;
			flag=true;
			}
		}
	}
	if(flag==true)
	{
		if(window.confirm("Are you sure want to delete "+msg))
		{
			document.adminForm.action.value='delete';
			document.adminForm.submit();
		}
	else
		{
			var count = document.adminForm.elements.length;
			for (i=0; i < count; i++) 
			{
				if(document.adminForm.elements[i].value==id)
				{
					document.adminForm.elements[i].checked =0;
					flag=false;
				}
			}
		}
	}
	
}

function delete_msg(id,msgtype,loc)
{
	var count = document.adminForm.elements.length;
	var flag=false;
	var msg = "";
	//alert(msgtype);
	if(msgtype !='')
	{
		msg = msgtype;
	}

	for (i=0; i < count; i++) 
	{
		if(document.adminForm.elements[i].type == 'checkbox')
		{
			if(document.adminForm.elements[i].value==id){
			document.adminForm.elements[i].checked =1;
			flag=true;
			}
		}
	}
	if(flag==true)
	{
		if(window.confirm("Are you sure want to delete "+msg))
		{
			document.adminForm.action.value='delete';
			document.adminForm.loc.value=loc;
			document.adminForm.submit();
		}
	else
		{
			var count = document.adminForm.elements.length;
			for (i=0; i < count; i++) 
			{
				if(document.adminForm.elements[i].value==id)
				{
					document.adminForm.elements[i].checked =0;
					flag=false;
				}
			}
		}
	}
	
}

function delete_field(id,msgtype)
{
	var msg = "";
	if(msgtype !='')
	{
		msg = msgtype;
	}
	
	if(window.confirm("Are you sure want to delete "+msg))
	{
		document.adminForm.action.value='delete';
		document.adminForm.submit();
	}
}

//function delete_record(id)
//{
//	var count = document.adminForm.elements.length;
//	var flag=false;
//	var msg = "";
//	
//	for (i=0; i < count; i++) 
//	{
//		if(document.adminForm.elements[i].type == 'checkbox')
//		{
//			if(document.adminForm.elements[i].value==id){
//			document.adminForm.elements[i].checked =1;
//			flag=true;
//			}
//		}
//	}
//	if(flag==true)
//	{
//		if(window.confirm("Are you sure?\n"+msg))
//		{
//			document.adminForm.action.value='delete';
//			document.adminForm.submit();
//		}
//	else
//		{
//			var count = document.adminForm.elements.length;
//			for (i=0; i < count; i++) 
//			{
//					if(document.adminForm.elements[i].value==id)
//						{
//							document.adminForm.elements[i].checked =0;
//							flag=false;
//						}
//			}
//		}
//	}
//	
//}

function next_link(choice,lang_abbr)
{
	window.location.href='./?choice='+choice+'&lang_abbr='+lang_abbr;
}

function send_to(choice)
{
	window.location.href=choice;
}
function next_tools(choice,stat)
{
	window.location.href='./?choice='+choice+'&stat='+stat;
}

function next_link1(choice,mod_id,usertype_id,lang_abbr)
{
	window.location.href='./?choice='+choice+'&mod_id='+mod_id+'&usertype_id='+usertype_id+'&lang_abbr='+lang_abbr;
}

function next_link2(choice,user_type,lang_abbr)
{
	var user_type=user_type;
	if(user_type=='')
		window.location.href='./?choice='+choice;
	else
		window.location.href='./?choice='+choice+'&usertype_id='+user_type+'&lang_abbr='+lang_abbr;	
}

function next_link3(choice,brand_id,lang_abbr)
{
	window.location.href='./?choice='+choice+'&brand_id='+brand_id+'&lang_abbr='+lang_abbr;
}

function next_link4(choice,brand_id,chapter_id,lang_abbr)
{
	window.location.href='./?choice='+choice+'&brand_id='+brand_id+'&chapter_id='+chapter_id+'&lang_abbr='+lang_abbr;
}
function next_link5(choice,mod_id,usertype_id,resource_category,lang_abbr)
{
	window.location.href='./?choice='+choice+'&mod_id='+mod_id+'&usertype_id='+usertype_id+'&resource_cat_id='+resource_category+'&lang_abbr='+lang_abbr;
}
function next_link6(choice,resource_cat,lang_abbr)
{
	var resource_cat=resource_cat;
	if(resource_cat=='')
		window.location.href='./?choice='+choice;
	else
		window.location.href='./?choice='+choice+'&resource_cat_id='+resource_cat+'&lang_abbr='+lang_abbr;	
}
function next_link7(choice,value,lang_abbr)
{
	window.location.href='./?choice='+choice+'&ns='+value+'&lang_abbr='+lang_abbr;
}
function add_content(choice,id,lang_abbr)
{
	window.location.href='./?choice='+choice+'&mod_id='+id+'&lang_abbr='+lang_abbr;
}

function delete_brand(obj,action,id)
{
	//alert(obj+"=="+action+",ooo=="+id);
	if(window.confirm("Are you sure want to delete the category.\n"))
		{
			//obj.action.value=action+":"+id;
			//obj.submit();
		}
		return false;
}
function submit_status(what,choice,super_id)
{
	location.href=("./?choice="+choice+"&status="+what.value+"&super="+super_id);
	//location.href=("index.php?cat=2&category_status="+what.value);
	
}
function submit_category(what)
{
	
	//var what = what.value;
	location.href=("./?choice=5&pi=1&status="+what.value);
	
}

function announce_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=6&ci="+what+"&status="+action+"&limitstart="+lstart);
	}

function display_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=6&di="+what+"&status="+action+"&limitstart="+lstart);
	}
function spotlight_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=115&ci="+what+"&status="+action+"&limitstart="+lstart);
	}
function testimonial_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=98&ci="+what+"&status="+action+"&limitstart="+lstart);
	}
function news_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=101&ci="+what+"&status="+action+"&limitstart="+lstart);
	}
function hof_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=104&ci="+what+"&status="+action+"&limitstart="+lstart);
	}
function pr_status(action,what)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=108&ci="+what+"&status="+action+"&limitstart="+lstart);
	}
function tool_status(action,what,stat)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?choice=8&ci="+what+"&status="+action+"&limitstart="+lstart+"&stat="+stat);
	}


function product_status(action,what,brand_id,chapter_id,lang_abbr,choice)
	{
		var lstart=document.adminForm.limitstart.value;
		if(brand_id!=0)
			location.href=("./?choice="+choice+"&ci="+what+"&brand_id="+brand_id+"&chapter_id="+chapter_id+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
		else
			location.href=("./?choice="+choice+"&ci="+what+"&chapter_id="+chapter_id+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}		

function category_status(action,what,lang_abbr)
	{
		var lstart=document.frm_category.limitstart.value;
		location.href=("./?choice=5&cati="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
function user_status(action,what,usertype_id,lang_abbr)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?&usertype_id="+usertype_id+"&choice=7&user_id="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}

	
function usertype_status(action,what,lang_abbr)
	{
		var lstart=document.frm_user.limitstart.value;
		location.href=("./?choice=20&usertype_id="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}


function showmand(chk)
{
	if(chk==0)
		document.getElementById('mand_title').disabled=true;
	
	if(chk==1)
	{
		document.getElementById('mand_title').disabled=false;
		document.getElementById('mand_title').focus();
	}
}

function language(what,choice,type)
{
	var language=what.value;
	var choice=choice;
	var type=type;
	location.href=("./?choice="+choice+"&lang_abbr="+language+"&usertype_id="+type);
}
function main_language(what,query_string)
{
	var language=what.value;
		
	var string=query_string;
	
	if(string.indexOf('?')>-1)
		location.href=("."+string+"&lang_abbr="+language);
	else	
		location.href=("./?"+string+"&lang_abbr="+language);
}

function main_language_front(what,pg,query_string)
{
	if(what.src)
	{
		if(what.id=='en')
			var language='en';
		else
			var language='ru';
	}
		
	var string=query_string;
	
	//alert("pg==>  "+pg);
	//alert("string==>  "+string);
	//return false;
	if(string.indexOf('?')>-1)
	{
		
		location.href=("./"+string+"&lang_abbr="+language);
	}
	else	
	{
		
		location.href=("./"+string+"?lang_abbr="+language);
	}
}

function usertype(what,choice,id,lang)
{
	var usertype=what;
	var choice=choice;
	location.href=("./?choice="+choice+"&usertype_id="+usertype+"&mod_id="+id+"&lang_abbr="+lang);
}


function viewdetail(what,choice,pay_type,lang)
{
	var viewby=what.value;
	var choice=choice;
	location.href=("./?choice="+choice+"&view_by="+viewby+"&pay_type="+pay_type+"&lang_abbr="+lang);
}



function viewproductcat(what,choice,lang)
{
	var category_id=what.value;
	
	
	var choice=choice;
	location.href=("./?choice="+choice+"&category_id="+category_id+"&lang_abbr="+lang);
}


function viewproductbrand(what,choice,lang,brand)
{
	var brand_id=what.value;
	var category_id=brand;
	
	var choice=choice;
	location.href=("./?choice="+choice+"&brand_id="+brand_id+"&category_id="+category_id+"&lang_abbr="+lang);
}


function onKeyPressBlockNumbers(e)
{
	
 var key = window.event ? e.keyCode : e.which;
//alert(key)
 if(key==8 || key==45 || key==11 || e.keyCode==36 || e.keyCode==35 || e.keyCode==46 || e.keyCode==9 || e.keyCode==116 || e.keyCode==37 || e.keyCode==39) return true;


/* if(key==45) return true;
 if(key==11) return true;
 if(e.keyCode==9) return true;
 if(e.keyCode==116) return true;
 if(e.keyCode==37) return true;
 if(e.keyCode==39) return true;*/
 
var keychar = String.fromCharCode(key);
 reg = /\d/;
 return reg.test(keychar);
}



function disp_product(frm,id)
{
	if(id==0)
	{
		document.getElementById('add_product').style.display='none';	
		document.getElementById('txtproduct').style.display='none';	
		document.getElementById('linkproduct').style.display='';	
		frm.submit();
	}
	else
	{
		document.getElementById('add_product').style.display='';	
		document.getElementById('txtproduct').style.display='';
		document.getElementById('linkproduct').style.display='none';	
	}
}


function popUp1(URL) {
//eval("window.open(URL, '" + id + "');");
eval("window.open(URL, 'toolbar=0,scrollbars=1,location=0,fullscreen=1,statusbar=0,menubar=0,resizable=0,left = 150,top = 100, width=670,height=480');");
}


function popUpWindow(URL,toolbar,scrollbars,fullscreen,statusbar,menubar,resizable,left,top,width,height) {
//eval("window.open(URL, '" + id + "');");
eval("window.open(URL, 'mywin','toolbar="+toolbar+",scrollbars="+scrollbars+",location=0,fullscreen="+fullscreen+",statusbar="+statusbar+",menubar="+menubar+",resizable="+resizable+",left = "+left+",top = "+top+", width="+width+",height="+height+"');");
}


function data_status(action,what,lang_abbr,choice,table)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?&choice="+choice+"&"+table+"_id="+what+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}


function data_status1(action,what,lang_abbr,choice,table,cat,brand)
	{
		var lstart=document.adminForm.limitstart.value;
		location.href=("./?&choice="+choice+"&"+table+"_id="+what+"&category_id="+cat+"&brand_id="+brand+"&status="+action+"&limitstart="+lstart+"&lang_abbr="+lang_abbr);
	}
	

function set_combo_brand(obj,id,lang_abbr)
{
	location.href=("./?choice=1812&id="+id+"&brand="+obj+"&lang_abbr="+lang_abbr);
}

function popitup(url) 
{
	newwindow=window.open(url,'','toolbar=0,scrollbars=1,location=0,height=500,width=800,left=100,top=100');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popittest(url) 
{
	newwindow=window.open(url,'','toolbar=0,scrollbars=1,location=0,height=550,width=600,left=200,top=100');
	if (window.focus) {newwindow.focus()}
	return false;
}

function show(id,tog)
{
	if(tog==1)
		document.getElementById(id).style.display="";
	else	
		document.getElementById(id).style.display="none";
}
function delete_prod(id)
{
	if(confirm("Do you want to delete the image?"))
	{
		document.getElementById('delid').value=id;
		document.adminForm.submit();
	}	
}
function viewstatus(obj,ch,ss)
{
	var status=obj.value;
	
	if(ss!='')
		location.href=("./?ss="+ss+"&status="+status+"&choice="+ch);
	else	
		location.href=("ticket.php?status="+status);
}

function showreply()
{
	document.getElementById('showrep').style.display='';	
	document.getElementById('showrep1').style.display='';	
	document.getElementById('general_submit').style.display='';
	document.getElementById('show_document').style.display='';
	
	//document.getElementById('show_document').style.display='';
	document.getElementById('rep').style.display='none';
}
function hidereply(cls)
{
	if(document.getElementById('reply').value!='')
	{
		document.getElementById('close').value=cls;	
		document.getElementById('showrep').style.display='none';
		document.getElementById('showrep1').style.display='none';
		document.getElementById('general_submit').style.display='none';
		//document.getElementById('general_submit1').style.display='none';
		document.getElementById('rep').style.display='';
	}
}

function delete_tool(id)
{
	if(confirm("Do you want to delete the image?"))
	{
		document.getElementById('delid').value=id;
		document.tool_frm.submit();
	}	
}

function down(path)
{
	document.adminForm.action='download.php';
	document.adminForm.path.value=path;
	document.adminForm.submit();	
}

function readcookie(cookieName)
{
	 var theCookie=""+document.cookie;
	 var ind=theCookie.indexOf(cookieName);
	 if (ind==-1 || cookieName=="") return ""; 
	 var ind1=theCookie.indexOf(';',ind);
	 if (ind1==-1) ind1=theCookie.length; 
	 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


/*function showprev(img)
{
	document.getElementById('divshow').innerHTML="<img src=../content/"+img+">";	
}
*/

//////////////////////// Website functions Starts ///////////////////////////////////

	function getContactInfo()
	{ 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
			 alert ("Browser does not support HTTP Request")
			 return
		 }

		var name=trimspaces(document.getElementById('name').value);
		var email=trimspaces(document.getElementById('email').value);
		var country=trimspaces(document.getElementById('country').value);
		var subject=trimspaces(document.getElementById('subject').value);
		var vstring=trimspaces(document.getElementById('verify_box').value);
		var message=trimspaces(document.getElementById('message').value);
		
		if(name=='')
		{
			alert('Please enter your name.');
			document.getElementById('name').focus();
			return false;
		}
		if(email=='')
		{
			alert('Please enter your email.');
			document.getElementById('email').focus();
			return false;
		}
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{}
		else
		{
			alert('Invalid E-mail Address! Please re-enter.');
			document.getElementById('email').focus();
			return false;
		}
		if(subject=='')
		{
			alert('Please enter your subject.');
			document.getElementById('subject').focus();
			return false;
		}
		
		if(vstring=='')
		{
			alert('Please enter verify string.');
			document.getElementById('verify_box').focus();
			return false;
		}
		if(vstring != readcookie('tntcon'))
		{
			alert('Invalid Verfication Code.');
			document.getElementById('verify_box').focus();
			return false;
		}
		if(message=='')
		{
			alert('Please enter your message.');
			document.getElementById('message').focus();
			return false;
		}
		var url="contact-information.php?name="+name+"&email="+email+"&subject="+escape(subject)+"&message="+escape(message)+"&country="+country+"&vstring="+vstring;
		xmlHttp.onreadystatechange=contactInfo
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	
	function contactInfo() 
	{ 
		 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 	 
			if(xmlHttp.responseText=="error")
			{
				document.getElementById("contactInfo").style.display='none';
				document.getElementById("cform").style.display='';
				//document.getElementById("errorRow").style.display='';
				document.getElementById("errorInfo").style.display='';
			}
			else
			{
				document.getElementById("cform").style.display='none';
				document.getElementById("contactInfo").style.display='';
				document.getElementById("contactInfo").innerHTML='<span style="color:#000000;">'+xmlHttp.responseText+'</span>';
			}
			
		} 
		else 
		{
			document.getElementById("contactInfo").style.display='';
			document.getElementById("contactInfo").innerHTML="<div align='center' style='padding-top:120px;'><img src='member/images/loader.gif' border='0'  height='20' width='20'></div>";
			document.getElementById("cform").style.display='none';
		}
	}
	function getInfo()
	{ 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		 {
			 alert ("Browser does not support HTTP Request")
			 return
		 }
		
		var name=document.getElementById('optinName').value;
		var email=document.getElementById('optinEmail').value;
		var phone=document.getElementById('optinPhone').value;
		var country=document.getElementById('optinCountry').value;
		var pos=document.getElementById('position').value;
		
		if(name=='')
		{
			alert('Please enter your name.');
			document.getElementById('optinName').focus();
			return false;
		}
		if(email=='')
		{
			alert('Please enter your email address.');
			document.getElementById('optinEmail').focus();
			return false;
		}
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{}
		else
		{
			alert('Invalid E-mail Address! Please re-enter.');
			document.getElementById('optinEmail').focus();
			return false;
		}
		if(phone=='')
		{
			alert('Please enter your phone number.');
			document.getElementById('optinPhone').focus();
			return false;
		}
		if(phone!='')
		{
			if(isNaN(phone))
			{
				alert('Please enter a valid phone number.');
				document.getElementById('optinPhone').focus();
				return false;
			}
		}
		if(country=='')
		{
			alert('Please enter your country.');
			document.getElementById('optinCountry').focus();
			return false;
		}
		var url="optin-information.php?name="+name+"&email="+email+"&phone="+phone+"&country="+country+"&pos="+pos;
		//alert(url);
		xmlHttp.onreadystatechange=optIn
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	function redirect(val)
	{
		if(val=='center')
		document.location.href="compensation.php";
		else if(val=='right')
		document.location.href="compensation.php";
	}
	function optIn() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			var response = xmlHttp.responseText.split("|");
			document.getElementById("messageshow").style.display='';
			document.getElementById("messageshow").innerHTML='<span style="color:#000000;">'+response[0]+'</span>' ;
			document.getElementById('optinName').value='';
			document.getElementById('optinEmail').value='';
			document.getElementById('optinCountry').value='';
			document.getElementById('optinPhone').value='';
			setTimeout("redirect('"+response[1]+"')",1000);
		 } 
		 else
		 {
		 	document.getElementById("messageshow").innerHTML="<div align='center' style='padding-top:120px;'><img src='member/images/loader.gif' border='0'  height='20' width='20'></div>";
		 }
		
	}
	function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try
		 {
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
		 }
		catch (e)
		 {
		 //Internet Explorer
		 try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		 }
		return xmlHttp;
   }

//////////////////////// Website functions Ends ////////////////////////////////////