﻿//****************************Created on 21/12/2009 by Manisha******************************
var ns4 = document.layers;
			var ns6 = document.getElementById && !document.all;
			var ie4 = document.all;
			
			function getObjectByID(Objid){	
				if(ns4)
				{
					return eval('document.' + Objid)
				}
				if(ns6)
				{
					return document.getElementById(Objid);
				}
				if(ie4)
				{
					return document.all(Objid);      
				}  
				return null
			}


			function SetText(objid,msg, fg, bg){
				if(!fg) fg = "#ff0000";
				if(!bg) bg = "#FFFFFF";
				
				var content = msg ;
				if(ns4)
				{
					objItm = eval('document.' + objid)
					objItm.document.write(content);
					objItm.document.close();
					objItm.visibility = "visible";
				}
				if(ns6)
				{
					document.getElementById(objid).innerHTML = content;
				}
				if(ie4)
				{
					document.all(objid).innerHTML=content;
				}  
			}
			
function check(val)
{
//alert(val);
	var con=0;
	for (var i=0; i<document.Form1.length; i++)
	{
		if(document.Form1.elements[i].type == "checkbox")
		{
			if ( document.Form1.elements[i].checked == true )
			{
				con++;
			}
		}	
	}
	if (con==0)
	{
		if (val == "Export")
		{
			
			alert('Please Select Atleast One Record To Export');			
			return false;
        }
        else if (val == "Send") {

            alert('Please Select atleast one Record To Send Mail');
            return false;
        }
        else if (val == "Add") {

            alert('Please Select atleast one record To Add');
            return false;
        }
       else
		{
		    alert('Please select atleast one record to delete');
			return false;
		}
	}
	else
	{
		if (val != "Export")
		{
			if (val == "City" )
			{
				
				return confirm('This Will Delete All Property Of This City, Are You Sure?');			
			}
			else if (val == "Country")
			{
				
				return confirm('This Will Delete All Property And City Of This Country, Are You Sure?');
            }
            else if (val == "Send") 
            {

                return confirm('This Will Send Mail,Are You Sure?');
               
            }
            else if (val == "Add") {

            return confirm('This will Add the Record');
               
            }
        	else
			{

			    return confirm('Are you sure you want to delete selected records?');
			}
		}
	}
	
}
function checkfront(val)
{
//alert(val);
	var con=0;
	for (var i = 0; i < document.aspnetForm.length; i++)
	{
	    if (document.aspnetForm.elements[i].type == "checkbox")
		{
		    if (document.aspnetForm.elements[i].checked == true)
			{
				con++;
			}
		}	
	}
	if (con==0)
	{
		if (val == "Export")
		{
			
			alert('Please Select Atleast One Record To Export');			
			return false;
		}
		else
		{
			alert('Please Select Atleast One Record For Delete');
			return false;
		}
	}
	else
	{
		if (val != "Export")
		{
			if (val == "City" )
			{
				
				return confirm('This Will Delete All Property Of This City, Are You Sure?');			
			}
			else if (val == "Country")
			{
				
				return confirm('This Will Delete All Property And City Of This Country, Are You Sure?');			
			}
			else
			{
				
				return confirm('Are You Sure You Want To Delete This Record?');
			}
		}
	}
	
}


function checkheader(name)
{

//name = "ctl00$ContentPlaceHolder1$rptSiteMaplist$ctl00$chkSelectAll";
	var con = 0;
	for (var i=0; i<document.aspnetForm.length; i++)
	{
		if(document.aspnetForm.elements[i].type == "checkbox")
		{			
			var chkname = document.aspnetForm.elements[i].name
			var ch = chkname.split("$");
			//var ch = chkname.split(":");
			if (ch[4] == name)
			{
			
				if ( document.aspnetForm.elements[i].checked == true )
				{
				
					con = 1;
					i = document.aspnetForm.length ;
				}
			}
		}	
	}
	
	if (con==1)
	{
		for (var i=0; i<document.aspnetForm.length; i++)
		{
			if(document.aspnetForm.elements[i].type == "checkbox")
			{
			
				document.aspnetForm.elements[i].checked = true ;
			}	
		}	
	}
	else
	{
		for (var i=0; i<document.aspnetForm.length; i++)
		{
		//alert(document.aspnetForm.elements[i]);
			if(document.aspnetForm.elements[i].type == "checkbox")
			{
				document.aspnetForm.elements[i].checked = false ;
			}	
		}	
	}
}

function checkother(name)
{
	var con = 0;
	for (var i=0; i<document.aspnetForm.length; i++)
	{
		if(document.aspnetForm.elements[i].type == "checkbox")
		{			
			var chkname = document.aspnetForm.elements[i].name
			var ch = chkname.split("$");
			//var ch = chkname.split(":");
			if (ch[2] != name)
			{
				if ( document.aspnetForm.elements[i].checked == false )
				{
					con = 1 ;
					i = document.aspnetForm.length ;
				}
			}
		}	
	}
	if (con==1)
	{
		for (var i=0; i<document.aspnetForm.length; i++)
		{
			if(document.aspnetForm.elements[i].type == "checkbox")
			{			
				var chkname = document.aspnetForm.elements[i].name
				var ch = chkname.split("$");
				//var ch = chkname.split(":");
				if (ch[2] == name)
				{
					document.aspnetForm.elements[i].checked = false ;
					i = document.Form1.length ;
				}
			}	
		}	
	}
	
}

/////////////////////


function checkheader123(name) {
   // alert(name);
    var con = 0;
    for (var i = 0; i < document.Form1.length; i++) {
        if (document.Form1.elements[i].type == "checkbox") {
            var chkname = document.Form1.elements[i].name

           var ch = chkname.split("$");

           // var ch = chkname.split(":");
            //alert(ch[2]);
            if (ch[2] == name) {
                if (document.Form1.elements[i].checked == true) {
                    head = 1;
                    con = 1;
                    i = document.Form1.length;
                }
                else {
                    con = 0;
                    head = 0;
                }
            }
        }
    }

    if (con == 1) {
        for (var i = 0; i < document.Form1.length; i++) {
            if (document.Form1.elements[i].type == "checkbox") {
                document.Form1.elements[i].checked = true;
            }
        }
    }
    else {
        for (var i = 0; i < document.Form1.length; i++) {
            if (document.Form1.elements[i].type == "checkbox") {
                document.Form1.elements[i].checked = false;
            }
        }
    }
}


function checkother123(name) {
    var con = 0;
    for (var i = 0; i < document.Form1.length; i++) {
        if (document.Form1.elements[i].type == "checkbox") {
            var chkname = document.Form1.elements[i].name
            var ch = chkname.split("$");
            //var ch = chkname.split(":");
            if (ch[2] != name) {
                if (document.Form1.elements[i].checked == false) {
                    con = 1;
                    i = document.Form1.length;
                }
            }
        }
    }
    if (con == 1) {
        for (var i = 0; i < document.Form1.length; i++) {
            if (document.Form1.elements[i].type == "checkbox") {
                var chkname = document.Form1.elements[i].name
                //var ch = chkname.split("$");
                var ch = chkname.split(":");
                if (ch[2] == name) {
                    document.Form1.elements[i].checked = false;
                    i = document.Form1.length;
                }
            }
        }
    }

}

function checkheader1(name)
{

    
var test =0;
	var con = 0;
	for (var i=0; i<document.Form1.length; i++)
	{
	
	if(document.Form1.elements[i].type == "checkbox")

		{	
	//lastSlash = fullPath.lastIndexOf("_")
//	fileName = fullPath.substring(lastSlash+1,fullPath.length)



		    var chkname = document.Form1.elements[i].name

		    //alert(chkname);
			var ch = chkname.split("$");	
			//var ch = chkname.split(":");
			if (ch[2] == name)
			{
		
				if ( document.Form1.elements[i].checked == true )
				{
					con = 1;
					i = document.Form1.length ;
				}
			}
		}	
	}
	
	if (con==1)
	{
		for (var i=0; i<document.Form1.length; i++)
		{
		
			if(document.Form1.elements[i].type == "checkbox")
			{
			    test = document.Form1.elements[i].name.indexOf("chkSelect")
			if (test > 0)
			{
			document.Form1.elements[i].checked = true ; 
			}	
			}	
		}	
	}
	else
	{
		for (var i=0; i<document.Form1.length; i++)
		{
			if(document.Form1.elements[i].type == "checkbox")
			{
			    test = document.Form1.elements[i].name.indexOf("chkSelect")
			if (test > 0)
			{
			document.Form1.elements[i].checked = false ;
			}
			}	
		}	
	}
}

function checkother1(name)
{
	var con = 0;
	for (var i=0; i<document.Form1.length; i++)
	{
		if(document.Form1.elements[i].type == "checkbox")
		{			
			var chkname = document.Form1.elements[i].name
			var ch = chkname.split("$");
			//var ch = chkname.split(":");
			if (ch[2] != name)
			{
				if ( document.Form1.elements[i].checked == false )
				{
					con = 1 ;
					i = document.Form1.length ;
				}
			}
		}	
	}
	if (con==1)
	{
		for (var i=0; i<document.Form1.length; i++)
		{
			if(document.Form1.elements[i].type == "checkbox")
			{			
				var chkname = document.Form1.elements[i].name
				var ch = chkname.split("$");
				//var ch = chkname.split(":");
				if (ch[2] == name)
				{
					document.Form1.elements[i].checked = false ;
					i = document.Form1.length ;
				}
			}	
		}	
	}
	
}
function opnParamValue(flag,Productid)
{
window.open("ImageView.aspx?flag=" + flag + "&Productid=" + Productid ,"mywindow","toolbar=0,directories=0,location=0,resizable=1,width=350,height=250");
}
////add for product page for ajax///
function chkgrid()
			{
			
				document.getElementById("delid").value="";
				
				var test =0;
				var con = 3;
				for (var i=0; i<document.Form1.length; i++)
				{
				
					if(document.Form1.elements[i].type == "checkbox")
					{	
						var chkname = document.Form1.elements[i].id
						/*if ( document.getElementById("dgProduct_ctl02_chkHeader").checked == true)
							{
								
								document.getElementById("dgProduct_ctl0" + con + "_chkDelete").checked = true;
								//document.getElementById("delid").value += document.getElementById("dgProduct_ctl0"+con+"_dgpid").value + ",";
										
							}
						else
							{
							document.getElementById("dgProduct_ctl0" + con + "_chkDelete").checked = false;	
							}*/
						if ( document.getElementById("dgProduct_ctl0" + con + "_chkDelete").checked == true)
							
									{
									//alert(document.getElementById("dgProduct_ctl0"+con+"_dgpid").value);
									document.getElementById("delid").value += document.getElementById("dgProduct_ctl0"+con+"_dgpid").value + ",";
									}	
													
								if ( document.getElementById("dgProduct_ctl0" + con + "_chkDelete").checked == false)
									{
										
									}
						con =con + 1;			
					}	
					
				}
									
			}


function chkheadergrid()
			{
			
				document.getElementById("delid").value="";
				
				var test =0;
				var con = 3;
				for (var i=0; i<document.Form1.length; i++)
				{
				
					if(document.Form1.elements[i].type == "checkbox")
					{	
						var chkname = document.Form1.elements[i].id
						if ( document.getElementById("dgProduct_ctl02_chkHeader").checked == true)
							{
								
								document.getElementById("dgProduct_ctl0" + con + "_chkDelete").checked = true;
								document.getElementById("delid").value += document.getElementById("dgProduct_ctl0"+con+"_dgpid").value + ",";
										
							}
						else
							{
							document.getElementById("dgProduct_ctl0" + con + "_chkDelete").checked = false;	
							document.getElementById("delid").value="";
							}
						
						con =con + 1;			
					}	
					
				}
			}


////end product page for ajax///


			function winopen(imgname, flag)
		{
		window.open("ImageView.aspx?imgname=" + imgname + "&flag=" + flag ,"mywindow","toolbar=0,directories=0,location=0,resizable=1,width=350,height=250");
		}

		function winthumbopen(imgname, flag)
		{
		    window.open("ImageView.aspx?msg=thumb&imgname=" + imgname + "&flag=" + flag, "mywindow", "toolbar=0,directories=0,location=0,resizable=1,width=350,height=250");
		}
	function resizeMe(imgObj){
	//alert(imgObj);
	hbuff = 100
	wbuff = 30		
if(typeof(imgObj) != "undefined"){			
	nheight = imgObj.height
	nwidth = imgObj.width
	if(nheight > 0 && nwidth > 0){
		maxhth  = screen.availHeight 
		maxwdh = screen.availWidth 
		//status = maxhth + " , " + maxwdh
		if(nwidth >= maxwdh-wbuff){
			nwidth = maxwdh - (wbuff + 10)
		}
		if(nheight >= maxhth-hbuff){															
			nheight = maxhth - (hbuff + 10)										
		}				
		resizeTo(nwidth + wbuff,nheight + hbuff)				
		midx = (maxwdh / 2) - ((nwidth + wbuff) / 2)				
		moveTo(midx,0)
		focus()
	}
}
}

function assign_Prd(val) {


    //alert(val);
   // var con = 0;
    con = 0;
    for (var i = 0; i < document.Form1.length; i++) {
        if (document.Form1.elements[i].type == "checkbox") {
            if (document.Form1.elements[i].checked == true) {
                con++;
            }
        }
    }
    if (con == 0) {
        if (val == "Export") {

            alert('Please Select Atleast One Record To assign');
            return false;
        }
        else {
            alert('Please select at least a single record to assign Products');
            return false;
        }
    }
    else {
        if (val != "Export") {
            if (val == "City") {

                return confirm('This Will assign all Products , Are You Sure?');
            }
            else if (val == "Country") {

            return confirm('This Will assign all Products, Are You Sure?');
            }
            else {

                return confirm('Are you sure you want to assign all selected Products?');
            }
        }
    }

}


function check_qty(txtqty) {

    if (emptyField(document.getElementById("txtqty"))) {
        alert('Please enter quantity');
        txtqty.focus();
        return false;
    }
    if (!isInt(document.getElementById("txtqty").value)) {
        alert('Please enter Numeric Quantity');
        txtqty.focus();
        return false;
    }
    if (document.getElementById("txtqty").value < 1) {
        alert('Quentity must be greater then zero.');
        txtqty.focus();
        return false;
    }

    if (!isInt(document.getElementById("txtqty").value)) {
        alert('Please enter integer value.');
        txtqty.focus();
        return false;
    }
}


function check_qty1() {

    var test = 0;
    var con = 2;
    //alert(test);
    for (var i = 0; i < document.Form1.length; i++) {
        if (emptyField(document.getElementById("dtgridCart_ctl0" + con + "_txtqty"))) {
            alert('Please enter quantity');
            document.getElementById("dtgridCart_ctl0" + con + "_txtqty").focus();
            return false;
        }

        if (document.getElementById("dtgridCart_ctl0" + con + "_txtqty").value < 1) {
            alert('Quentity must be greater then zero.');
            document.getElementById("dtgridCart_ctl0" + con + "_txtqty").focus();
            return false;
        }

        if (!isInt(document.getElementById("dtgridCart_ctl0" + con + "_txtqty").value)) {
            alert('Please enter integer value.');
            document.getElementById("dtgridCart_ctl0" + con + "_txtqty").focus();
            return false;
        }


        con = con + 1;
    }
}




function valid_qty(e) {
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    if (code == 8 || code == 9 || code == 13) return true;
    var character = String.fromCharCode(code);
    if (character == '.') return false;

    if ('0' <= character && character <= '9') {
        return true;
    }
    else {

        // alert("Please Enter Numeric Value")
        return false;
    }
}

function check_send(val) {
    //alert(val);
    var con = 0;
    for (var i = 0; i < document.Form1.length; i++) {
        if (document.Form1.elements[i].type == "checkbox") {
            if (document.Form1.elements[i].checked == true) {
                con++;
            }
        }
    }
    if (con == 0) {
        if (val == "Export") {

            alert('Please Select Atleast One Record To Export');
            return false;
        }
        else {
            alert('Please select at least a single record to send mail');
            return false;
        }
    }
    else {
        if (val != "Export") {
            if (val == "City") {

                return confirm('This Will Delete All Property Of This City, Are You Sure?');
            }
            else if (val == "Country") {

                return confirm('This Will Delete All Property And City Of This Country, Are You Sure?');
            }
            else {

                return confirm('Are you sure you want to send newsletter to selected emails?');
            }
        }
    }

}

//create by kalpesh
//handle enter on textbox 
function handleEnter(e)
{

	var characterCode;
	
	if(e && e.which)
	{
		e = e;
		characterCode = e.which;
	} 
	else 
	{
		e = event;
		characterCode = e.keyCode;
	}

	if(characterCode == 13 || characterCode == 1)
	{
	    
		//window.location.href='searchpage.aspx?str='+document.getElementById('txtsearch').value;
		
		return false;
	} 
	else
	{
		return true;
	}
}

