var head = 0;

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.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
			{
			
			    if (head == "1")
			    {
			        head = 0;   
                    return confirm('This will delete all records.');						    
			    }
			    else if (head == "0")
			    {
			        return confirm('Are you sure you want to delete your selections?');			
			    }
			    else
				{
				return confirm('This Will Delete All Recods Related To This, Are You Sure?');
				}
				
			}
		}
	}
	
}
function checkfront(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 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 Product From Wish List?');
				
			}
		}
	}
	
}


function checkheader(name)
{
    //alert("hi");
    
	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 )
				{
				    head = 1;
				   	con = 1;
					i = document.aspnetForm.length ;
				}
				else
				{
				    con =0;
				    head = 0;
				}
			}
		}	
	}
	
	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++)
		{
			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 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
			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("chkDelete")
			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("chkDelete")
			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)
		{
		window.open("ImageView.aspx?imgname=" + imgname ,"mywindow","toolbar=0,directories=0,location=0,resizable=1,width=350,height=250");
		}

function winthumbopen(imgname)
		{
		window.open("ImageView.aspx?msg=thumb&imgname=" + imgname ,"mywindow","toolbar=0,directories=0,location=0,resizable=1,width=350,height=250");
		}
	function resizeMe(imgObj){
	//alert(imgObj);
	hbuff = 90
	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()
	}
}
}



