function OpenWindow(url)
{
    window.open(url, "_blank", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=600');
    return false;
}

function Messages(msg, url)
{
    alert(msg);
    document.location.href = url;
}
function showImageDetail(DivPicture,BigPicture)
{
    var divObj = document.getElementById(DivPicture);
    var PWidth = document[BigPicture].width + 3;
    var PHeight = document[BigPicture].height + 3;
    divObj.style.width = PWidth + 'px';
    divObj.style.height = PHeight + 'px';
    divObj.style.visibility = 'visible';
    divObj.focus();
    return false;
}
function hideImageDetail(DivPicture)
{
    DivPicture.style.visibility='hidden';
    return false;
}
function Printer(url)
{
    window.open(url, "_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=650,height=600,left=60, top=60,screenX=60px,screenY=60px");
    return false;
}
function SendMail(url)
{
    window.open(url, "_blank","toolbar=no,location=no,directories=no,addressbar=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=530,height=220,left=230, top=120,screenX=230px,screenY=120px");
    return false;
}
function ActivePrinter(idTopHidden,idBottomHidden)
{
    document.getElementById(idTopHidden).style.visibility='hidden';
    document.getElementById(idBottomHidden).style.visibility='hidden';
    window.print();
    window.close();
    return false;
}
function trimall(str) 
{
	return str.replace(/^\s+|\s+$/g,"");
}

function isValidEmail(strEmail)
{
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;  

   // search email text for regular exp matches
   if (strEmail.search(validRegExp) == -1) 
   {      
      return false;
    } 
    return true; 
}

function encode(string) 
{
    return escape(this._utf8_encode(string));
}

// public method for url decoding
function decode(string) 
{
    return this._utf8_decode(unescape(string));
}

// private method for UTF-8 encoding
function _utf8_encode(string) 
{
    string = string.replace(/\r\n/g,"\n");
    var utftext = "";

    for (var n = 0; n < string.length; n++) {

        var c = string.charCodeAt(n);

        if (c < 128) {
            utftext += String.fromCharCode(c);
        }
        else if((c > 127) && (c < 2048)) {
            utftext += String.fromCharCode((c >> 6) | 192);
            utftext += String.fromCharCode((c & 63) | 128);
        }
        else {
            utftext += String.fromCharCode((c >> 12) | 224);
            utftext += String.fromCharCode(((c >> 6) & 63) | 128);
            utftext += String.fromCharCode((c & 63) | 128);
        }

    }

    return utftext;
}

// private method for UTF-8 decoding
function _utf8_decode  (utftext) 
{
    var string = "";
    var i = 0;
    var c = c1 = c2 = 0;

    while ( i < utftext.length ) {

        c = utftext.charCodeAt(i);

        if (c < 128) {
            string += String.fromCharCode(c);
            i++;
        }
        else if((c > 191) && (c < 224)) {
            c2 = utftext.charCodeAt(i+1);
            string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
            i += 2;
        }
        else {
            c2 = utftext.charCodeAt(i+1);
            c3 = utftext.charCodeAt(i+2);
            string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }

    }
    return string;
}

function hideAllTooltip(dvNewsIDs)
{
    var dvNewsIDs=document.getElementById(dvNewsIDs);
    
    var strNewsIDs=dvNewsIDs.innerHTML;
    var arrNewsID=strNewsIDs.split(",");
    
    var tagDiv=null;
    for(var i=0;i<arrNewsID.length;i++)
    {        
        tagDiv=document.getElementById(arrNewsID[i]);                            
        tagDiv.style.visibility="hidden";        
    }
}

function showTooltip(e,divID,dvNewsIDs)
{
    var dvNewsIDs=document.getElementById(dvNewsIDs);
    
    var strNewsIDs=dvNewsIDs.innerHTML;
    var arrNewsID=strNewsIDs.split(",");
    
    var tagDiv=null;
    for(var i=0;i<arrNewsID.length;i++)
    {
        if(arrNewsID[i]!=divID)
        {
            tagDiv=document.getElementById(arrNewsID[i]);                
            
            tagDiv.style.visibility="hidden";
        }
    }
    
    if (!e) e = window.event;
    
    tagDiv=document.getElementById(divID);                
    
	if (e)
    { 
        if (e.pageX || e.pageY)
        { 
            tagDiv.style.visibility="visible";
           
            if(e.pageX<450)
    	        tagDiv.style.left = (e.pageX+10)+"px";
    	    else
    	        tagDiv.style.left = (e.pageX-280)+"px";    
  	    	tagDiv.style.top = (e.pageY)+"px";		    			
				
        }
        else if (e.clientX || e.clientY)
        { 
            tagDiv.style.visibility="visible";
            if(e.clientX<450)
                tagDiv.style.left = e.clientX+document.documentElement.scrollLeft+10;
            else
    	        tagDiv.style.left = e.clientX+document.documentElement.scrollLeft-280;
    	    tagDiv.style.top = e.clientY+document.documentElement.scrollTop;		    
    	    
        }  
    }
}
function checkStatus(trContent,trFooter,imgCE)
{
    var trContent=document.getElementById(trContent);
    var trFooter=document.getElementById(trFooter);
    var imgCE=document.getElementById(imgCE);
    var status=readCookie("ProfileStatus");
    
    if(status=="expand")
    {
        imgCE.src="../Web/Images/collapse.gif";
        trContent.style.display="";
        trFooter.style.display="";
    }
    else
    {
        imgCE.src="../Web/Images/expand.gif";
        trContent.style.display="none";
        trFooter.style.display="none";
    }
}
function collapseExpand(trContent,trFooter,imgCE)
{
    
    var trContent=document.getElementById(trContent);
    var trFooter=document.getElementById(trFooter);
    var imgCE=document.getElementById(imgCE);
    
    if(imgCE.src.indexOf("collapse.gif")>-1)
    {
        imgCE.src="../Web/Images/expand.gif";
        trContent.style.display="none";
        trFooter.style.display="none";
        createCookie("ProfileStatus","collapse",1);
    }
    else
    {
        imgCE.src="../Web/Images/collapse.gif";
        trContent.style.display="";
        trFooter.style.display="";
        createCookie("ProfileStatus","expand",1);
    }
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";	
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

