
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";
	var apptype = frmObj.apptype.value;
	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(apptype == "airport") {
            if(strtype == "Inactive") {
        		if(confirm('- Related terminal, tenant, advertisement, airport & concourse maps, airport wall posts and their comments, airport comments will be inactivated.\n\n Are you sure you want to continue?')) {
        			frmObj.mode.value=strtype;
                    frmObj.submit();
                    return true;
        		}
        		else
        			return false;
            }
            else if(strtype == "Active") {
        		if(confirm('- Related terminal, tenant, advertisement, airport & concourse maps, airport wall posts and their comments, airport comments will be activated.\n\n Do you want to activate child records?')) {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=1;
                    frmObj.submit();
                    return true;
        		}
        		else {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=0;
                    frmObj.submit();
                    return true;
                }
            }
            else {
    			frmObj.mode.value=strtype;
                frmObj.submit();
                return true;
            }
        }
        else if(apptype == "terminal") {
            if(strtype == "Inactive") {
        		if(confirm('- Related tenant and advertisement records will be inactivated.\n\n Are you sure you want to continue?')) {
        			frmObj.mode.value=strtype;
                    frmObj.submit();
                    return true;
        		}
        		else
        			return false;
            }
            else if(strtype == "Active") {
        		if(confirm('- Related tenant and advertisement records will be activated.\n\n Do you want to activate child records?')) {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=1;
                    frmObj.submit();
                    return true;
        		}
        		else {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=0;
                    frmObj.submit();
                    return true;
                }
            }
            else {
    			frmObj.mode.value=strtype;
                frmObj.submit();
                return true;
            }
        }
        else if(apptype == "tenant") {
            if(strtype == "Inactive") {
        		if(confirm('- Related advertisement records will be inactivated.\n\n Are you sure you want to continue?')) {
        			frmObj.mode.value=strtype;
                    frmObj.submit();
                    return true;
        		}
        		else
        			return false;
            }
            else if(strtype == "Active") {
        		if(confirm('- Related advertisement records will be activated.\n\n Do you want to activate child records?')) {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=1;
                    frmObj.submit();
                    return true;
        		}
        		else {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=0;
                    frmObj.submit();
                    return true;
                }
            }
            else {
    			frmObj.mode.value=strtype;
                frmObj.submit();
                return true;
            }
        }
        else if(apptype == "airportwall") {
            if(strtype == "Inactive") {
        		if(confirm('- Related comments for this post will be inactivated.\n\n Are you sure you want to continue?')) {
        			frmObj.mode.value=strtype;
                    frmObj.submit();
                    return true;
        		}
        		else
        			return false;
            }
            else if(strtype == "Active") {
        		if(confirm('- Related comments for this post will be activated.\n\n Do you want to activate child records?')) {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=1;
                    frmObj.submit();
                    return true;
        		}
        		else {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=0;
                    frmObj.submit();
                    return true;
                }
            }
            else {
    			frmObj.mode.value=strtype;
                frmObj.submit();
                return true;
            }
        }
        else if(apptype == "airline") {
            if(strtype == "Inactive") {
        		if(confirm('- Related airline contact, airline contact point, airline details, reviews will be inactivated.\n\n Are you sure you want to continue?')) {
        			frmObj.mode.value=strtype;
                    frmObj.submit();
                    return true;
        		}
        		else
        			return false;
            }
            else if(strtype == "Active") {
        		if(confirm('- Related airline contact, airline contact point, airline details, reviews will be activated.\n\n Do you want to activate child records?')) {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=1;
                    frmObj.submit();
                    return true;
        		}
        		else {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=0;
                    frmObj.submit();
                    return true;
                }
            }
            else {
    			frmObj.mode.value=strtype;
                frmObj.submit();
                return true;
            }
        }
        else if(apptype == "airlinecontact") {
            if(strtype == "Inactive") {
        		if(confirm('- Related airline contact point records will be inactivated.\n\n Are you sure you want to continue?')) {
        			frmObj.mode.value=strtype;
                    frmObj.submit();
                    return true;
        		}
        		else
        			return false;
            }
            else if(strtype == "Active") {
        		if(confirm('- Related airline contact point records will be activated.\n\n Do you want to activate child records?')) {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=1;
                    frmObj.submit();
                    return true;
        		}
        		else {
        			frmObj.mode.value=strtype;
        			frmObj.active_mode.value=0;
                    frmObj.submit();
                    return true;
                }
            }
            else {
    			frmObj.mode.value=strtype;
                frmObj.submit();
                return true;
            }
        }
        else {
			frmObj.mode.value=strtype;
            frmObj.submit();
            return true;
        }
	}
	else
	{
		message = " - Select at least one record.";
		alert(message);
		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
	{

		message = "- Select at least one module.";
		alert(message);
		return false;
	}
	

}
function delconfirm(frmObj)
{
	
	var flag = 0;
	var strid = "0";
	var apptype = frmObj.apptype.value;
	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(apptype == "airport") {
    		if(confirm('- Related terminal, tenant, advertisement, airport & concourse maps, airport wall posts and their comments, airport comments will be deleted.\n\n Are you sure you want to continue?'))
    		{
    			if(!selectcheck(frmObj,'Delete')) return false;
    			frmObj.mode.value="Delete";
    		}
    		else
    			return false;
        }
        else if(apptype == "terminal") {
    		if(confirm('- Related tenant and advertisement records will be deleted.\n\n Are you sure you want to continue?'))
    		{
    			if(!selectcheck(frmObj,'Delete')) return false;
    			frmObj.mode.value="Delete";
    		}
    		else
    			return false;
        }
        else if(apptype == "tenant") {
    		if(confirm('- Related advertisement records will be deleted.\n\n Are you sure you want to continue?'))
    		{
    			if(!selectcheck(frmObj,'Delete')) return false;
    			frmObj.mode.value="Delete";
    		}
    		else
    			return false;
        }
        else if(apptype == "airportwall") {
    		if(confirm('- Related comments for this post will be deleted.\n\n Are you sure you want to continue?'))
    		{
    			if(!selectcheck(frmObj,'Delete')) return false;
    			frmObj.mode.value="Delete";
    		}
    		else
    			return false;
        }
        else if(apptype == "airline") {
    		if(confirm('- Related airline contact, airline contact point, airline details, reviews will be deleted.\n\n Are you sure you want to continue?'))
    		{
    			if(!selectcheck(frmObj,'Delete')) return false;
    			frmObj.mode.value="Delete";
    		}
    		else
    			return false;
        }
        else if(apptype == "airlinecontact") {
    		if(confirm('- Related airline contact point records will be deleted.\n\n Are you sure you want to continue?'))
    		{
    			if(!selectcheck(frmObj,'Delete')) return false;
    			frmObj.mode.value="Delete";
    		}
    		else
    			return false;
        }
        else {
    		if(confirm('- Are you sure you want to delete?'))
    		{
    			if(!selectcheck(frmObj,'Delete')) return false;
    			frmObj.mode.value="Delete";
    		}
    		else
    			return false;
        }
		
		/*
		frmObj1 = frmObj;
		message = "- Are you sure you want to delete?";
		alert("<h1>"+title+"</h1><p>"+message+"</p><p align = center><a href='' onclick=returntru(frmObj1); >Ok</a>&nbsp;&nbsp;<a href='#' onclick='closeMessage()'>Cancle</a>",false);
		*/
	}
	else
	{
		message = " - Select at least one record.";
		alert(message);
		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)
}

//'''''''''''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();
}	

function returntru(frmObj)
{
		if(!selectcheck(frmObj,'Delete')) return false;
		frmObj.mode.value="Delete";
}
