﻿function ShowDiv(DivId) 
{ 
    var posx = 0; 
    var posy = 0; 
    var e = window.event; 
    if (e.pageX || e.pageY) 
    {posx = e.pageX; 
    posy = e.pageY; 
    } 
    else if (e.clientX || e.clientY) 
    { 
    posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; 
    posy = e.clientY + document.body.scrollTop+ document.documentElement.scrollTop; 
}

var _DivId = document.getElementById(DivId); 
_DivId.style.display="block";
_DivId.style.left=posx;
_DivId.style.top=posy; 
//_DivId.style.z-index:1; 
//window.status = " X :" + posx +" == Y :" + posy ; 
}



function ETGTrim(str)
{
  var i,j;
  i = 0;
  j=str.length-1;
  str = str.split("");
  while(i < str.length)
  {
    if(str[i]==" ")
    {
      str[i] = "";
    }
    else
    {
      break;
    }
    i++;
  }
  while(j > 0)
  {
    if(str[j]== " ")
    {
      str[j]=""
    }
    else
    {
      break;
    }
    j--;
  }
  return str.join("");
}


// Validate an Email.
function validEmail(email) {
var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
var checkend=/\.[a-zA-Z]{2,3}$/;

if((email.search(exclude) != -1) || (email.search(checkend) == -1)) {
	return false;
}

atPos = email.indexOf("@",0);
pPos1 = email.indexOf(".",0);
periodPos = email.indexOf(".",atPos);
pos1 = pPos1;
pos2 = 0;
while (pos2 > -1) {
	pos2 = email.indexOf(".",pos1+1);
	if (pos2 == pos1+1) {return false;
	} else {pos1 = pos2;}
}

if (atPos == -1) {return false;}
if (atPos == 0) {return false;}
if (pPos1 == 0) {return false;}
if(email.indexOf("@",atPos+1) > -1) {return false;}
if (periodPos == -1) {return false;}
if (atPos+1 == periodPos) {	return false;}
if (periodPos+3 > email.length) {return false;}
return true;
}



function AcceptNumber()
			{
	
				code=eval(event.keyCode);						
				if (code<48 || code>57)
				{
				event.keyCode=0;
				}
			}


function OpenPop(url)
{
	window.open(url,"epop","width=400,height=400,scrollbars=yes");
}

function IsValidImage(imgsrc)
{
    //alert ("Image validation");
     var _img = new  Image();
         _img.src=imgsrc;  
         _img.id="uploadingImage"; 
         
        
    
        if (ETGTrim(imgsrc)!="")  
        {
             // document.images["uploadingImage"]    
            if ( (imgsrc.indexOf(".jpg")==-1) && (imgsrc.indexOf(".gif")==-1))
            {
                return false ;
            }
            else  if(eval(_img.width) >400 || eval(_img.height) > 400)
            {
                return false;
            }
            else 
            {
                return true;
            }
          
        }
        else 
        {
          
            return true;
        }
}



