function getSelectedText()
{
	var userSelection;
	if(window.getSelection)
		userSelection=window.getSelection();
	else if(document.selection)
		userSelection=document.selection.createRange().text;
	return userSelection;
}

function getUrlParameterByName(param)
{
	param=param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS="[\\?&]"+param+"=([^&#]*)";
	var regex=new RegExp(regexS);
	var results=regex.exec(window.location.href);
	if(results==null)
		return "";
	else
		return results[1];
}

function getPasswordStrength(Password)
{
    var pwlength=Password.length;
    if(pwlength>5)
        pwlength=5;
    var numnumeric=Password.replace(/[0-9]/g,"");
    var numeric=(Password.length-numnumeric.length);
    if(numeric>3)
        numeric=3;
    var symbols=Password.replace(/\W/g, "");
    var numsymbols=(Password.length-symbols.length);
    if(numsymbols>3)
        numsymbols=3;
    var numupper=Password.replace(/[A-Z]/g, "");
    var upper=(Password.length-numupper.length);
    if(upper>3)
        upper=3;
    var pwstrength=((pwlength*10)-20)+(numeric*10)+(numsymbols*15)+(upper*10);
    if(pwstrength<0)
        pwstrength=0;
    if(pwstrength>100)
		pwstrength=100;
    return pwstrength;
}

function addTip(TargetID,Param)
{
	if($(TargetID)!=undefined)
		Event.observe(window,'load',function(e){new Tip(TargetID,Param,{delay:0.01,style:'darkgrey',stem:'topLeft',hook:{tip:'topLeft',mouse:true},offset:{x:8,y:8}});});
}

function addRightTip(TargetID,Param)
{
	if($(TargetID)!=undefined)
		Event.observe(window,'load',function(e){new Tip(TargetID,Param,{delay:0.01,hideOthers:true,style:'darkgrey',stem:'leftMiddle',hook:{tip:'leftMiddle',mouse:true},offset:{x:0,y:-8}});});
}


function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return false;
}

function initWhatQuotationBox()
{
	QuotationTimer='';
	Event.observe('what-quotation-link','mouseover',function(e){try{$('list-settings').hide();}catch(e){}clearTimeout(QuotationTimer);Effect.BlindDown($('what-quotation'),{duration:.5});});
	Event.observe('what-quotation-link','mouseout',function(e){QuotationTimer=setTimeout("Effect.BlindUp($('what-quotation'),{duration:.9});try{Effect.Appear($('list-settings'),{duration:1.5});}catch(e){}",1100);});
}

function initAddQuotationByUser()
{
	Event.observe('add-quotation-by-user','click',
		function(e)
		{
			if($('add-quotation-by-user-block').style.display=='none')
				$('add-quotation-by-user-block').show();
			else
				$('add-quotation-by-user-block').hide();
		}
	);
}
