
function openwin(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}

function searchcheck(frmObj)
{
	if (frmObj.txtSearch.value=="")
	{
		alert("- Enter Search keyword")
		return false;
	}
	else
	{	
		frmObj.page.value = 1;
		frmObj.mode.value="search";
		frmObj.searchflag.value="search";
		return true;
	}
}

function show_image(Obj,objimg)
{
	
	//if(isImage(Obj))
	//{
		
		if (objimg.value!='')
			objimg.src=Obj.value;
		else
			objimg.src='images/imagepreview.gif';
	//}
	//else
	//document.form1.imgcat.src='images/imagepreview.gif';
}
function showimage(Obj)
{
	
	//if(isImage(Obj))
	//{
		
		if (Obj.value!='')
			document.form1.imgcat.src=Obj.value;
		else
			document.form1.imgcat.src='images/imagepreview.gif';
	//}
	//else
	//document.form1.imgcat.src='images/imagepreview.gif';
}
function checkall(frmObj)
{
	
	var elm;
	for(i = 0; i < frmObj.elements.length; i++) 
	{	
		elm = frmObj.elements[i];
		
		if (elm.type == "checkbox" && !isNaN(elm.id)) 
		{
			elm.checked = true;
		}
	}
}

function clearall(frmObj)
{
	var elm;
	
	for(i = 0; i < frmObj.elements.length; i++) 
	{	
		elm = frmObj.elements[i]
		if (elm.type == "checkbox" && !isNaN(elm.id)) 
		{
			
			elm.checked = false;
		}
	}
}

function selectcheck(frmObj,strtype)
{
	var flag = 0;
	var strid = "0";
	
	for(i = 0; i < frmObj.elements.length; i++) 
		{	
		
		elm = frmObj.elements[i]
			if (elm.type == "checkbox"  && !isNaN(elm.id)) 
			{
				
				if (elm.checked)
				{
					
					if (flag==0)
					{
						
						flag = 1;
					}
				
				}
			}
		}
	if (flag == 1)
	{
			frmObj.mode.value=strtype;
			frmObj.submit();
		return true;
	
	}
	else
	{
		alert("- Select at least one record.");
		return false;
	}
	

}
function selectcheck1(frmObj,strtype)
{
	var flag = 0;
	var strid = "0";
	
	for(i = 0; i < frmObj.elements.length; i++) 
		{	
		elm = frmObj.elements[i];
			
			if (elm.type == "checkbox" && isNaN(elm.id)) 
			{
				
				if (elm.checked)
				{
					
					if (flag==0)
					{
						
						flag = 1;
					}
				
				}
			}
		}
	if (flag == 1)
	{
			frmObj.mode.value=strtype;
		return true;
	
	}
	else
	{
		alert("- Select at least one module.");
		return false;
	}
	

}
function delconfirm(frmObj)
{
	
	var flag = 0;
	var strid = "0";
	
	for(i = 0; i < frmObj.elements.length; i++) 
		{	
		
		elm = frmObj.elements[i];
			if (elm.type == "checkbox"  && !isNaN(elm.id)) 
			{
				
				if (elm.checked)
				{
					
					if (flag==0)
					{
						
						flag = 1;
					}
				
				}
			}
		}
	if (flag == 1)
	{
	
		if(confirm('- Are you sure you want to delete?'))
		{
			if(!selectcheck(frmObj,'Delete')) return false;
			frmObj.mode.value="Delete";
		}
		else
			return false;
	}
	else
	{
		alert("- Select at least one record.");
		return false;
	}
}

//''''''Below functions are used for moving the value left<>rigth from listbox''''''
var objleft,objlefttext,objright,objrighttext ;

function all_array()
{
	
	objrighttext.value ="";
	for(var i=0;i< objright.length;i++)
		objrighttext.value=objrighttext.value + '#'+objright.options[i].value;
		
	objlefttext.value ="";
	for(var i=0;i<objleft.length;i++)
		objlefttext.value=objlefttext.value + '#'+objleft.options[i].value;
	
	if (objlefttext.value.length >0) 
		objlefttext.value=objlefttext.value.substring(1,objlefttext.value.length)
	if (objrighttext.value.length >0) 
		objrighttext.value=objrighttext.value.substring(1,objrighttext.value.length)
}/*
function AddOne()
{
	if(objleft.selectedIndex >= 0)
	{
		flag=0;
		
		for(var i=0;i< objright.length;i++)
		{
			if(objleft.options[objleft.selectedIndex].value == objright.options[i].value)
			flag =1;
		}
		
		if(flag==0)
		{
			var newOption;
			newOption= new Option(objleft.options[objleft.selectedIndex].text, objleft.value,0,0);
			objright.options[objright.length] = newOption;
			objleft.remove(objleft.selectedIndex);
		}
		else
		{
			alert("- alreday present.");
		}
		//all_array();			
	}	
}
function RemoveOne()
{
	if(objright.selectedIndex >= 0)
	{
		var newOption;
		newOption= new Option(objright.options[objright.selectedIndex].text, objright.value,0,0);
		objleft.options[objleft.length] = newOption;
		objright.remove(objright.selectedIndex);
		//all_array();
	}
}
function RemoveAll()
{
	
	var newOption ;
	for(var i=0;i<objright.length;i++)
	{
		objright.selectedIndex=i;
		newOption= new Option(objright.options[objright.selectedIndex].text, objright.value,0,0);
		objleft.options[objleft.length] = newOption;
			
	}								
	for(var i=(objright.length-1);i>=0;i--)
		objright.options[i] = null;
	objright.selectedIndex = -1;
	//all_array();
}
function AddAll()
{
	for(var i=(objright.length-1);i>=0;i--)
	{	objright.options[i] = null;
		
	}
	objright.selectedIndex = -1;
	var newOption ;
	for(var i=0;i<objleft.length;i++)
	{
		objleft.selectedIndex=i;
		newOption= new Option(objleft.options[objleft.selectedIndex].text, objleft.value,0,0);
		objright.options[objright.length] = newOption;
			
	}	
	for(var i=(objleft.length-1);i>=0;i--)
		objleft.options[i] = null;
	objleft.selectedIndex = -1;							
	//all_array();
}	
*/
//'''''''''''Random String Generator

function RamdomString(intLen)
{
	var strRet = "";
	var iCntr  = 0;
	var rndNo  = 0;
	var arrCharacters = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
	for (iCntr = 0; iCntr < intLen; iCntr++)
	{
		rndNo = Math.floor((61 - 1 + 1) * Math.random() + 1)
		strRet = strRet + arrCharacters[rndNo];
	}
	return strRet;
	//alert(strRet)
}
function valid_frm(frmobj)
{
	
	
	for(i=0;i<frmobj.iSubCat.length;i++)
	{
		
		if(frmobj.iSubCat.options[i].selected)
		{
			if(frmobj.iSubCat.options[i].text.indexOf("*")==-1)
			{
				alert("- You Can Only Select Parent Category Which Has No Products And  Marked With ' * '.");
				return false;
			}
		}
	}
	

	if(frmobj.vCatName.value=="")
	{
		alert("- Category Name is mandatory.");
		return false;
	}
		
}
function setval()
{
	if(document.form1.drpState.value=='0')
	{
		document.form1.hdnstate.value=document.form1.txtother.value;
	}
	else
	{
		document.form1.hdnstate.value=document.form1.drpState.value;
	}
}
function clearval()
{
	if(document.form1.iState.value>0)
	{
		document.form1.vOther.value="";
		document.form1.chkother.checked=false;
		document.form1.vOther.disabled=true;
	}
	else if(document.form1.iState.value==0)
	{
		document.form1.vOther.value="";
		document.form1.chkother.checked=true;
		document.form1.vOther.disabled=false;
	}
}
function setstate1(Obj)
{
	if (Obj.checked)
	{
		document.form1.iState.value = "0"
		document.form1.vOther.disabled=false;
	}
	else
	{
		document.form1.iState.value = "";
		document.form1.vOther.value="";
		document.form1.vOther.disabled=true;
		
	}
}
function AddOne()
{
	
	if(objleft.selectedIndex >= 0)
	{
		var newOption;
		newOption= new Option(objleft.options[objleft.selectedIndex].text, objleft.value,0,0);
		objright.options[objright.length] = newOption;
		objleft.remove(objleft.selectedIndex);			
		//all_array();			
	}	
}
function RemoveOne()
{
	
	if(objright.selectedIndex >= 0)
	{
		var newOption;
		newOption= new Option(objright.options[objright.selectedIndex].text, objright.value,0,0);
		objleft.options[objleft.length] = newOption;
		objright.remove(objright.selectedIndex);
		//all_array();
	}
}
function RemoveAll()
{
	
	
	var newOption ;
	for(var i=0;i<objright.length;i++)
	{
		objright.selectedIndex=i;
		newOption= new Option(objright.options[objright.selectedIndex].text, objright.value,0,0);
		objleft.options[objleft.length] = newOption;
			
	}								
	for(var i=(objright.length-1);i>=0;i--)
		objright.options[i] = null;
	objright.selectedIndex = -1;
	//all_array();
}
function AddAll()
{
	
	
	var newOption ;
	for(var i=0;i<objleft.length;i++)
	{
		objleft.selectedIndex=i;
		newOption= new Option(objleft.options[objleft.selectedIndex].text, objleft.value,0,0);
		objright.options[objright.length] = newOption;
			
	}	
	for(var i=(objleft.length-1);i>=0;i--)
		objleft.options[i] = null;
	objleft.selectedIndex = -1;							
	//all_array();
}	
