
function checkNumber(objNumber) {
	if (objNumber == null) {
		return false;
	}
	
	var objRegExp = /^\d*$/;

	if (!objRegExp.test(objNumber.value)) {
		alert("Please enter a valid number.");
		objNumber.select();
		objNumber.focus();
		return false;
	}
	
	return true;
}
    
// Format: "MM/dd/yyyy HH:mm";
// author: Cazacu Mihai
function checkDate(objDate) {
	if (objDate == null) {
		return false;
	}
	
	
    var objRegExp = /^\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}$/;
    var strValue  = objDate.value;

    if(!objRegExp.test(strValue)) {
    	alert('Invalid date.\nPlease use this format: "MM/dd/yyyy HH:mm"');
        objDate.focus();
        return false;
    }
    
    var strDate = strValue.substring(0, 10);
    var strTime = strValue.substring(11);

    var arrayDate = strDate.split('/');
    var arrayTime = strTime.split(':');
    var intMonth  = parseInt(arrayDate[0].charAt(0) == '0' ? arrayDate[0].charAt(1) : arrayDate[0]);
    var intDay    = parseInt(arrayDate[1].charAt(0) == '0' ? arrayDate[1].charAt(1) : arrayDate[1]);
    var intYear   = parseInt(arrayDate[2]);
    var intHour   = parseInt(arrayTime[0].charAt(0) == '0' ? arrayTime[0].charAt(1) : arrayTime[0]);
    var intMinute = parseInt(arrayTime[1].charAt(0) == '0' ? arrayTime[1].charAt(1) : arrayTime[1]);
    
    var arrayLookup = { '01' : 31,
                        '03' : 31, 
                        '04' : 30,
                        '05' : 31,
                        '06' : 30,
                        '07' : 31,
                        '08' : 31,
                        '09' : 30, 
                        '10' : 31,
                        '11' : 30,
                        '12' : 31}

    //------------------------ check day -----------------------------\\
    if(arrayLookup[arrayDate[0]] != null) {
        if((intDay < 1) || (intDay > arrayLookup[arrayDate[0]])) {
            alert("Invalid day value: " + intDay);
            objDate.focus();
            return false;
        }
    }

    //------------------------ check month ---------------------------\\
    if ((intMonth < 1) || (intMonth > 12)) {
        alert("Invalid month value: " + intMonth);
        objDate.focus();
        return false;
    }

    // check for February
    if (intMonth == 2) { 
       if( !(((intYear % 4 == 0 && intDay <= 29) || 
            (intYear % 4 != 0 && intDay <= 28)) && intDay !=0) ) {

              alert("Invalid day(of February month) value: " + intDay);
              objDate.focus();
              return false;
       }
    }
    
    //------------------------- check hour ---------------------------\\
    if ((intHour < 0) || (intHour > 23)) {
        alert("Invalid hour: " + intHour);
        objDate.focus();
        return false;
    }

    //------------------------ check minutes -------------------------\\
    if ((intMinute < 0) || (intMinute > 59)) {
        alert("Invalid minute: " + intMinute);
        objDate.focus();
        return false;
    }

    return true;	        
}

function LTrim(str) {
        var whitespace = new String(" \t\n\r ");
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            var j=0, i = s.length;
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            s = s.substring(j, i);
        }
        return s;
}

function RTrim(str) {
        var whitespace = new String(" \t\n\r ");
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            var i = s.length - 1;       
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            s = s.substring(0, i+1);
        }
        return s;
}
                                                                                                                        
function Trim(str) {
        return RTrim(LTrim(str));
}

function isNullOrEmpty(val) {
	return ((val == null) || (Trim(val) == ""));	
}

// Holds the video div count
var dc_videoDivCount = 0;
// Generates embedded tags for videos. It uses the Windows media player.
// src: indicates the video url
// alignment: optional field. default value is 0 - center. 1 - left, 2 - right
// Generates embedded tags for videos
function DC_EMBED_VIDEO(src,alignment)
{
    var divname = "videodiv";
    var vidalign = 'align="center"';
	var url = "";
	var tmpalign = parseInt(alignment);
	if (tmpalign == 1)
	{
	    vidalign = 'class="fleft"';
	} else if (tmpalign == 2)
	{
	    vidalign = 'class="fright"';
	}
	dc_videoDivCount += 1;
	divname += dc_videoDivCount;
	url = '<div id="' + divname + '" ' + vidalign + '>';	
	url += '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsm p2inf.cab#Version=5,1,52,701" ';
	url += 'standby="Loading Microsoft Windows® Media Player components..." type="application/x-oleobject" width="350" height="325"> ';
	url += '<param name="fileName" value="' + src + '"> ';
	url += '<param name="animationatStart" value="true"> ';
	url += '<param name="transparentatStart" value="false"> ';
	url += '<param name="autoStart" value="false"> ';
	url += '<param name="showControls" value="true"> ';
	url += '<param name="Volume" value="-450"> ';
	url += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="' + src + '" name="MediaPlayer1" width=375 height=350 autostart=0 showcontrols=1 volume=-450> ';
	url += '</object></div>';
	document.write(url);
}


// Older version which uses Shockwave-flash plugin on browsers
function DC_EMBED_VIDEO_1(src,alignment)
{
    var divname = "videodiv";
    var vidalign = 'align="center"';
	var url = "";
	var tmpalign = parseInt(alignment);
	if (tmpalign == 1)
	{
	    vidalign = 'class="fleft"';
	} else if (tmpalign == 2)
	{
	    vidalign = 'class="fright"';
	}
	dc_videoDivCount += 1;
	divname += dc_videoDivCount;
	url = '<div id="' + divname + '" ' + vidalign + '>';
	url += '<object width="350" height="300">';
	url += '<param name="movie" value="' + src + '"></param>';
	url += '<param name="wmode" value="transparent"></param>';
	url += '<embed src="' + src + '" type="application/x-shockwave-flash" wmode="transparent" AUTOSTART="false" width="350" height="300"></embed>';
	url += '</object></div>';
	document.write(url);
}

// Open DC photo gallery
function LoadPhotoGallery(url)
{  
   window.open(url,"PhotoGallery","width=800 height=800 toolbar=no status=no scrollbars=yes menubar=no location=no ");
    
}

function LoadCPhotoGallery()
{
var id=document.getElementById("hd").value;
var url = "photogallery.hspl?tpid="+id;
window.open(url,"PhotoGallery","width=800 height=800 toolbar=no status=no scrollbars=yes menubar=no location=no");
}

function LoadCvPhotoGallery(id)
{
id = document.getElementById(id).value;
//alert(id);
window.location.href="photogallery.hspl?tpid="+id;
//var url = "photogallery.hspl?tpid="+id;
//window.open(url,"PhotoGallery","width=800 height=800 toolbar=no status=no scrollbars=yes menubar=no location=no ");
}
 
