function isBlank(s)
{
		for(var i=0; i < s.length; i++)
		{
			var c = s.charAt(i);
			if((c!=' ')&&(c!="\n")&&(c!="\t"))
    			return false;
		}
		return true;
        }
	function spWin(win_nm,nm,w,h)
	{
        	var hs=screen.height; hs=hs-80;
        	var ws=screen.width; ws=ws-10;
	        if(h>hs) h = hs ;
	        if(w>ws) w = ws ;
        	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+w+',height='+h+',left=0,top=0';
	        var newImg = open(win_nm,nm,myfeatures);
        	newImg.focus();
	}
	function openWin(win_nm,nm)
	{
        	var h=screen.height;
	        h=h-150;
        	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,width=650,height=475,left=0,top=0';
	        var newImg = open(win_nm,nm,myfeatures);
        	newImg.focus();
	}
	function smallWin(win_nm,nm)
	{
        	var h=screen.height;
	        h=h-80;

	       	var myfeatures = 'directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,resizable=yes,scrollbars=yes,width=500,height=220,left=0,top=0';

	        var newImg = open(win_nm,nm,myfeatures);
        	newImg.focus();
	}
	function confirmDel(ref)
	{
		if(confirm(msgDelConfirm))
			window.location.replace(ref);
		return;
	}
	function submitf(ref,id,id_ri)
	{
		document.sform.id_rc.value=id;
		document.sform.id_ri.value=id_ri;
		document.sform.action = ref;
		document.sform.submit();
	}

 	function validString(s) {
 		if((s.match(/^['&#\/,.a-zA-Z0-9 !@\?åÅäÄöÖ\n\r\f-]*$/) || s==""))
                	return true;
		else
			return false ;
	}
	function delAttach(id)
	{
		if(confirm(msgDelConfirm))
		{
			document.dform.id_attach.value=id;
			document.dform.submit();
		}
	}

    	function getLength(s) {
		return s.length ;
    	}

	function checkData(str, max){
		if( getLength(s) > 0 && getLength(s) <= max){
			return true ;
		} else if( getLength(s) > max) {
			alert(msgMaxCharExceeded);
			return false ;
		}
		return true ;
	}

	function isFloat(s) {
		if(!s.match(/^\d{0,10}[,]{0,1}\d{0,2}$/))
			return false;
		else
			return true ;
    	}

    	function isNumber(s) {
		if(s.match(/^\d{0,10}$/) && s <= 2147483647)
			return true;
		else
			return false ;
    	}

	function spDelete(loc){
		if(confirm(msgDelConfirm)){
			document.location.href=loc;
			return true;
		}
	}

	function spOld(loc){
		if(confirm(msgOldConfirm)){
			document.location.href=loc;
			return true;
		}
	}

	function spActive(loc){
		if(confirm(msgActiveConfirm)){
			document.location.href=loc;
			return true;
		}
	}
	function isValidChar(s) {
		if(!validString(s)) {
			alert(msgValidCharAllowed);
			return false ;
		}
		else
			return true ;
    	}
function checkDelete(src,langNameAlert)
{
		conString = msgDelConfirm +" "+ langNameAlert;
	if(confirm(conString))
		window.location.replace(src);
}
function checkDeletelistPro(src,langNameAlert)
{
		conString = msgDelConfirmListPro +": "+ langNameAlert;
	if(confirm(conString))
		window.location.replace(src);
}
function groupOfUrlFun(formName,category,winWidth,winHeight)
{
	cform = document.forms[formName] ;
	val = cform.groupOfUrl.checked ;
  if(val)
  {
  	spWin("addGroupUrl.php?category="+category,"myinyt",winWidth,winHeight);
	}
}
function groupofDocumentFun(formName,category,winWidth,winHeight)
{
	cform = document.forms[formName] ;
	val = cform.groupOfDocument.checked ;
  if(val)
  {
  	spWin("addGroupDocument.php?category="+category,"myinyt",winWidth,winHeight);
	}
}
function submitPageForLinkDocAndUrl(formNameForLink,item,winW,winH)
{
	cform = document.forms[formNameForLink];
	cform.linkToAdd.value=item;
	cform.winWidth.value=winW;
	cform.winHeight.value=winH;
	cform.submit();
}

function isDate(DateField) {
    var ValidDigits = "0123456789./";
    var allNum = "";
    var isValidDigit = 'NO';
    var mmddccyy = DateField.replace(/ /gi,"");

    var month,day,year,mt="",m="";

    for(t=0;t<DateField.length;t++)
    {
        ch = DateField.charAt(t);
        if(ch != '/')
           mt = mt + ch;
        else
            m = mt;
    }
    function chk()
    {
        if(day<=31 && month<=12)
        {
            for (i = 0; i < DateField.length; i++)
            {
                ch1 = month.charAt(i);
                ch2 = day.charAt(i);
                ch3 = year.charAt(i);
                for (j = 1;  j < ValidDigits.length;  j++)
                {
                    if (ch+j != ValidDigits.charAt(j-1))
                    {
                        isValidDigit = 'YES';
                       break;
                    }
                }
                if(isValidDigit == 'YES')
                   break;
            }
        }
    }
    if(DateField.length == 10)
    {
        month = m.substring(2,4);
        day = m.substring(0,2);
        year = DateField.substring(6,10);
        if(month == 2 && day < 29)
            chk();
        else
            chk();
    }
    else if(DateField.length == 9)
    {
        month = m.substring(1,4);
        day = m.substring(0,1);
        year = DateField.substring(5,9);
        if(month == 2 && day < 29)
            chk();
        else
            chk();
    }
    else if(DateField.length == 8)
    {
        month = m.substring(1,3);
        day = m.substring(0,1);
        year = DateField.substring(5,9);
        if(month == 2 && day < 29)
            chk();
        else
            chk();
    }
    isValidDigit == 'NO'

    if(isValidDigit == "NO")
        return false;
    else
        return true;

}//date validity

function isEmailValid(email) {

    var ok = true;
    if (!(/^.+@.+\..{2,3}$/.test(email)))
    {
        ok = false;
    }
    if (email.match(/[\(\)\<\>\,\;\:\\\/\"\[\]]/)) {
       ok = false;
    }
    return ok;
}//emailvalid
//url valid..start
function urlValid(curl)
{
    var ok = true;
    //if(!(/^www\.(.*)\..{2,3}$/.test(curl)))
    //{
        //ok = false;
        //alert(msgEnterValidUrl);
    //}
    if(!(/^.*\.(.*)\..{2,3}$/.test(curl))) {
        ok = false;
        alert(msgEnterValidUrl);
    }
    return ok;
}//urlvalid..over


function checkValue(qty) {
    var seperator = '';
    if(qty == '') return false;
	if(qty.indexOf(",") > -1)  seperator = ",";
	else if (qty.indexOf(".") > -1)  seperator = ".";
    if(seperator != '') {
	    arrValues = qty.split(seperator);
	    if(arrValues.length > 2 || !isNumber(arrValues[0]) || !isNumber(arrValues[1]))
	        return  false;
    } else if(!isNumber(qty) || isBlank(qty))
        return false;
    return true;
}//checkValue

