﻿var isForsedEnter = false;

function doNotLoggedMSG()
{
    if(!isForsedEnter){
        if (confirm("You must be Logged In")) { 
            location.href="/SignUp.aspx";
        }
    }
    return false;
}

function doNotActivatedMSG()
{
    alert("You account must be activated");
    return false;
}

function calcCharsLeft(cur_obj,max_chars,comm_id)
{
    var _out = document.getElementById(comm_id)
    var iCurLen = String(cur_obj.value).length;
    if(_out!=null)
    {
        if(max_chars > iCurLen){
            _out.innerHTML = "<b>"+String(max_chars-iCurLen)+"</b> chars left.";
            _out.style.color = "";
        }else{
            _out.innerHTML = "<b>0</b> characters left.";
            cur_obj.value = String(cur_obj.value).substring(0,(max_chars-1));
            _out.style.color = "red";
            return false;            
        }
    }
}
function CutLongString(sInString, iMaxLen)
{
    var sString = String(sInString);
    if(sString.length > iMaxLen){
        sString = sString.substring(0,iMaxLen-4)+"...";
    }
    return sString;
}
//provile view
function profileSetCurTab(tab_name)
{
    //clear all tabs 
    document.getElementById("tab_requests").className = ""
    document.getElementById("tab_gallery").className = ""
    document.getElementById("tab_favorites").className = ""
    document.getElementById("tab_friends").className = ""
    //=====================================================
    document.getElementById(tab_name).className = "current";
}
//============================================================
function fGetLeft(obj){
   return(obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+fGetLeft(obj.offsetParent));
}
function fGetTop(obj){
   return(obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+fGetTop(obj.offsetParent));
}

function show_hide_Obj(id_name)
{
   var _obj = document.getElementById(id_name);
   if(_obj.style.visibility=="hidden")
   {
    _obj.style.visibility = "visible";
   }else{
    _obj.style.visibility = "hidden";
   }

}
//================================================================

function refresh_send_message()
{
    var sURL =  document.getElementById("send_message").src
    document.getElementById("send_message").src = sURL;
}

function doConfirm(sMessage)
{
    if (confirm(sMessage))
    {
        return true; 
    }else{
        return false;
    }
}

function showWindow(sURL, iWidth, iHeight)
{
	var winLeft = (screen.availWidth/2) - (iWidth/2);
	var winTop = (screen.availHeight/2) - (iHeight/2);
	window.open(sURL,'pp_form','top='+winTop+',left='+winLeft+',width='+iWidth+',height='+iHeight+',directories=0,location=0,resizable=0,scrollbars=0,status=0,toolbar=0,menubar=0')
}

function forseEnter(e,sBTNID)
{
    var keynum;
    if(window.event)//ie
        keynum=window.event.keyCode
    else if (e.which)//Netscape/Firefox/Opera
        keynum=e.which;
    if (keynum == 13)
    {
        if(window.event)//ie
        {
            event.cancelBubble = true;
            event.returnValue = false;            
            document.getElementById(sBTNID).click();
        }
        else //FF
        {
            try{document.getElementById(sBTNID).click();}catch(err){
                location.href = document.getElementById(sBTNID).href
                }
        }
        
        //action 
        isForsedEnter = true;
        
    }
}

function putFlash(sFilePath, iWidth, iHeight, sWMode)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+iWidth+'" height="'+iHeight+'">');
	document.write('<param name="movie" value="'+sFilePath+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="WMode" value="'+sWMode+'">');
	document.write('<embed src="'+sFilePath+'" quality="high" wmode="'+sWMode+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+iWidth+'" height="'+iHeight+'"></embed>');
	document.write('</object>');
}