﻿
function urlRandomizer() {
	var strChars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";			
	var minLength = 30;
	var maxLength = 30;
	var diffLength = maxLength - minLength		
	var thisLength = Math.round((Math.random() * diffLength)+minLength);		
	var outLoop = 0; var strGen = '';			
	while(outLoop<thisLength)	{
		strGen += strChars.charAt(Math.round(Math.random() * strChars.length));
		outLoop++;
	}			
	return(strGen);
}

function validateEmail(email){
	 if (email.length == 0) return false; 
	 var splitted = email.match("^(.+)@(.+)$");
	 if(splitted == null) return false;
	 if(splitted[1] != null )
	 {
		var regexp_user=/^\"?[\w-_\.]*\"?$/;
		if(splitted[1].match(regexp_user) == null) return false;
	 }
	 if(splitted[2] != null)
	 {
		var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
		if(splitted[2].match(regexp_domain) == null) 
		{
		 var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
		 if(splitted[2].match(regexp_ip) == null) return false;
		}// if
		return true;
	 }
	return false;
}	

function spinner(divId){
	$(divId).update('<img src="/img/activity_spinners/spinner.gif" width="18" height="18" style="margin-left:20px" alt="Loading..." />');
}

function processor(divId){
	$(divId).update('<img src="/img/activity_spinners/loading_animation_liferay.gif" width="70" height="10" style="margin-left:20px" alt="Processing..." />');
}

function openVideo(srcVideo) {
    // myLytebox.start($('vidprops'+hashies), false, true);
    var a = document.createElement("a");
    a.href = "/content/playvideo.asp?vid=" + srcVideo + "&rnd=" + urlRandomizer();
    a.rel = "lyteframe";
    a.title = "Video player";
    a.rev = "width: 510px; height: 280px; scrolling: no;";
    myLytebox.start(a, false, true);
}

