﻿// JScript File

function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function myImageUpload(editor)
{
  var imageFileName = null;
  var imageFileTitle = null;

  function postback(doc,popup_iframe)
  {
    if(doc != null) // Upload clicked
    {
      if(doc.getElementById("path").value != "")
      {
        var frm = doc.getElementById("fraExecute");

        function onLoad()
        {
          setTimeout(function()
                    {
                     if(frm.detachEvent)
                        frm.detachEvent("onload", onLoad);
                     else
                     if(frm.removeEventListener)
                        frm.removeEventListener("load", onLoad, true);

                     imageFileName = frm.contentWindow.imageFileName;
                     imageFileTitle = frm.contentWindow.imageFileTitle;

                     if(imageFileName == null)
                        alert(frm.contentWindow.imageSaved);

                     popup_iframe.contentWindow.document.getElementById("cancel").onclick();  // emulate Cancel pressed
                    },0);
        }

        if(frm.attachEvent)
           frm.attachEvent("onload", onLoad);
        else
        if(frm.addEventListener)
           frm.addEventListener("load", onLoad, true);

        try{doc.getElementById("frmFile").submit();}
        catch(e)
        {
          alert(e.message);

          if(frm.detachEvent)
             frm.detachEvent("onload", onLoad);
          else
          if(frm.removeEventListener)
             frm.removeEventListener("load", onLoad, true);

         popup_iframe.contentWindow.document.getElementById("cancel").onclick();
        }
        return false;
      }
    }
    else  // Cancel clicked or emulated
    {
      if(imageFileName != null)
      {
        editor.focusEditor();
        editor.InsertHTML("<img src=\""+imageFileName+"\" alt=\""+imageFileTitle+"\" title=\""+imageFileTitle+"\" />");
      }
    }
  }

  function init(doc,popup_iframe)
  {
    if(doc != null)
    {
        doc.getElementById("title").value = "";
        if(document.all)
        {
          popup_iframe.style.display = "none";
          doc.getElementById("path").click();
          popup_iframe.style.display = "";
          if(doc.getElementById("path").value == "")
            popup_iframe.contentWindow.document.getElementById("cancel").onclick();
        }
    }
  }

  editor.customPopup("popup_image_upload","image-upload","__cs_myImageUpload.aspx",postback,init, false, false);
}

function Enlarge(which,size,folder,ImageName,largeWidth,LargeHeight)
{
   var ie=document.all
var ns6=document.getElementById&&!document.all

var largeImage = 'javascript:LargeImage(\''+'cp/SiteImages/'+folder+'/'+ImageName+'\','+largeWidth+','+LargeHeight+')';
	var newHTML = '<a href="'+largeImage+'"><img src="' +which+ '" width="' +size+ '" height="' +size+ '" border="0"/></a>';

	if (ie||ns6){
		var crossobj = document.getElementById? document.getElementById("showimage") : document.all.showimage;
		var Enlarge = document.getElementById? document.getElementById("EnlargeImageID") : document.all.EnlargeImageID;
		
		var newHTML2 = '<a class="ProductDetails_ItemText" href="'+largeImage+'">أنقر لمشاهدة صورة أكبر</a>';
		Enlarge.innerHTML = newHTML2;
		Enlarge.style.visibility="visible";
		
		crossobj.innerHTML=newHTML;
		crossobj.style.visibility="visible"
	return false
	}
	else {
		return true;
	}

}
/***************************************/
function ReadProductImageOver(imageElement)
    {
        imageElement.src = 'images/ReadMore_MouseOver.jpg';
    }
function ReadProductImageOut(imageElement)
    {
        imageElement.src = 'images/ReadMore_Normal.jpg';
    }
function LargeImage (sUrl, sWidth, sHeight) 
	{
		agent = navigator.userAgent;
		windowName = "ImageLarg";
		params  = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,height="+sHeight+",width="+sWidth;
		win = window.open(sUrl, windowName , params);
		if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) 
			{
				win = window.open(sUrl, windowName , params);
			}
			if (!win.opener) 
			{
				win.opener = window;
			}
	}
	
	function EditImage(ImageName,ImageID,Folder)
		{
			var url="EditImage.aspx?Image="+ImageName+"&ImageID="+ImageID+"&Folder="+Folder;
			window.open(url,"","height=230,width=320,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
		}
	function InputBorder(input)
		{
			//document.write(input.id.toString());
			
			var el=document.getElementById(input.id.toString());
			el.className="InputBorder";
			input.select();
		}
	function InputNoBorder(input)
		{
			var el=document.getElementById(input.id.toString());
			el.className="InputNoBorder";
		}
		
	<!--

	//var theForm = document.forms['form1'];
//******************************************Cheick Box that Confirm..********************************
function confirmDelete () { 
		
// loop through all elements
var a=0;
for (i=0; i<theForm.elements.length; i++) {
// Look for our checkboxes only

if (theForm.elements[i].name.indexOf('DeleteThis') !=-1) {

// If any are checked then confirm alert, otherwise nothing happens
if(theForm.elements[i].checked) 
{
a=1;
return confirm ('You are about to delete a record:\nAre you sure you want to delete this item(s)?')

}
}
}
if(a==0)
{
alert("If you would like to delete an item select them and press delete.");
return false;
}
}
//**************************DeleteConfirm*********
function confirmDeleteImages() { 
		
// loop through all elements
var a=0;
for (i=0; i<theForm.elements.length; i++) {
// Look for our checkboxes only

if (theForm.elements[i].name.indexOf('DeleteThisImage') !=-1) {

// If any are checked then confirm alert, otherwise nothing happens
if(theForm.elements[i].checked) 
{
a=1;
return confirm ('You are about to delete an image(s):\nAre you sure you want to delete this image(s)?')

}
}
}
if(a==0)
{
alert("If you would like to delete a an image select them and press delete.");
return false;
}
}
//********************************On Check Box Clicked **********************************
function CA(isO,noHL)
{
	var trk=0;
	for (var i=0;i<theForm.elements.length;i++)
			{
				var e=theForm.elements[i];
					if ((e.id.indexOf ('CheckAll') == -1) && (e.type=='checkbox') && (e.name.indexOf('DeleteThis'))!=-1)
							{
								if (isO != 1)
										{
											trk++;
											e.checked=theForm.CheckAll.checked;
											HighlightRow(e);
										}
								else
										{
											e.tabIndex=i;
										}//End of Second If..
							}//End of First If
			}//End of loop..
}
//****************************************Check box clicked.................
//********************************On Check Box Clicked **********************************
function CAImages(isO,noHL)
{
	var trk=0;
	for (var i=0;i<theForm.elements.length;i++)
			{
				var e=theForm.elements[i];
					if ((e.id.indexOf ('CheckAllImages') == -1) && (e.type=='checkbox') && (e.name.indexOf('DeleteThisImage'))!=-1)
							{
								if (isO != 1)
										{
											trk++;
											e.checked=theForm.CheckAllImages.checked;
											HighlightRow(e);
										}
								else
										{
											e.tabIndex=i;
										}//End of Second If..
							}//End of First If
			}//End of loop..
}
//*****************************************Check Box All Clicked..**************
function CCA(CB,noHL)
{
	var TB=TO=0;
	for (var i=0;i<theForm.elements.length;i++)
	{
	//document.getElementById("").style.borderColor
	var e=theForm.elements[i];
		if ((e.name != 'CheckAll') && (e.type=='checkbox') && (e.name.indexOf('DeleteThis'))!=-1)
			{
				TB++;
				if (e.checked)
				TO++;
			}
	}
theForm.CheckAll.checked=(TO==TB)?true:false;

}
//*******************************check all images***********************
function CCAImages(CB,noHL)
{
	var TB=TO=0;
	for (var i=0;i<theForm.elements.length;i++)
	{
	//document.getElementById("").style.borderColor
	var e=theForm.elements[i];
		if ((e.name != 'CheckAllImages') && (e.type=='checkbox') && (e.name.indexOf('DeleteThisImage'))!=-1)
			{
				TB++;
				if (e.checked)
				TO++;
			}
	}
theForm.CheckAllImages.checked=(TO==TB)?true:false;

}
function HighlightRow(chkB)	
	{
	// Old code for VS 2002 / .NET framework 1.0 code
	//-----------------------------------------------
	// In .NET 1.0 ASP.NET was using SPAN tag with
	// CheckBox control. 
	//var oItem = chkB.children;
	//xState=oItem.item(0).checked;
	var xState=chkB.checked;
		
	if(xState)
		{chkB.parentElement.parentElement.style.backgroundColor='#C1CDD8';  // grdEmployees.SelectedItemStyle.BackColor
		 //chkB.parentElement.parentElement.style.color='black'; // grdEmployees.SelectedItemStyle.ForeColor
		}else 
		{chkB.parentElement.parentElement.style.backgroundColor='F5F5F5'; //grdEmployees.ItemStyle.BackColor
		 //chkB.parentElement.parentElement.style.color='black'; //grdEmployees.ItemStyle.ForeColor
		}
	}
function CACells(isO,noHL)
{
	var trk=0;
	
	for (var i=0;i<theForm.elements.length;i++)
			{
				var e=theForm.elements[i];
					if ((e.id.indexOf ('CheckAll') == -1) && (e.type=='checkbox') && (e.name.indexOf('DeleteThis')!=-1 || e.name.indexOf('DeleteThis1')!=-1 || e.name.indexOf('DeleteThis2')!=-1))
							{
								if (isO != 1)
										{
											trk++;
											e.checked=theForm.CheckAll.checked;
											HighlightCell(e);
										}
								else
										{
											e.tabIndex=i;
										}//End of Second If..
							}//End of First If
			}//End of loop..
}
function HighlightCell(chkB)	
	{
	// Old code for VS 2002 / .NET framework 1.0 code
	//-----------------------------------------------
	// In .NET 1.0 ASP.NET was using SPAN tag with
	// CheckBox control. 
	//var oItem = chkB.children;
	//xState=oItem.item(0).checked;
	var xState=chkB.checked;
		
	if(xState)
		{chkB.parentElement.style.backgroundColor='#C1CDD8';  // grdEmployees.SelectedItemStyle.BackColor
		 //chkB.parentElement.parentElement.style.color='black'; // grdEmployees.SelectedItemStyle.ForeColor
		}else 
		{chkB.parentElement.style.backgroundColor='F5F5F5'; //grdEmployees.ItemStyle.BackColor
		 //chkB.parentElement.parentElement.style.color='black'; //grdEmployees.ItemStyle.ForeColor
		}
	}
function HighlightRowMouseOver(e)
	{
		e.style.backgroundColor='#C1CDD8';
	}
function HighlightRowMouseOut(e)
	{
		var el=e.children[0].children[0];
	
	if(el.checked==false)
		{
		e.style.backgroundColor='#F5F5F6';
		}
	}
function ShowHideButton( buttonId, controlId, showClass, hideClass ) {
	   var button = document.getElementById(buttonId);
	   var control = document.getElementById(controlId);
	   if (control.style.display == "none") {
		   button.className = hideClass;
		   control.style.display = 'block';
	   } else {
	   	   button.className = showClass;
		   control.style.display = 'none';
	   }
}
function ShowHideButton_Show( buttonId, controlId, classname ) {
	   var button = document.getElementById(buttonId);
	   var control = document.getElementById(controlId);
	   button.className = classname;
	   control.style.display = 'block';
}
function ShowHideButton_Hide( buttonId, controlId, classname ) {
	   var button = document.getElementById(buttonId);
	   var control = document.getElementById(controlId);
	   button.className = classname;
	   control.style.display = 'none';
}
-->

