﻿httpaddress = "http://www.shafayar.com/"
//httpaddress = "http://localhost:1103/"
//-----------------------------------------------------------------------------   is_empty
function is_empty(get_value)
{
    if(get_value.length == 0)
    {
		return true;
	}
    return false;
}
//-----------------------------------------------------------------------------   is_numeric
function is_numeric(get_value)
{
    var str_exp = '^[0-9]+$';
	if(get_value.match(str_exp))
    {
		return true;
	}
    else
    {
        return false;
    }
}
//-----------------------------------------------------------------------------   is_decimal
function is_decimal(get_value)
{
    var str_exp = '^[0-9]+[.][0-9]+$';
    if(get_value.match(str_exp))
    {
        return true;
    }
    else
    {
        return false;
    }
}
//-----------------------------------------------------------------------------   is_mail
function is_mail(get_value)
{
    var emailexp = /^[\w\-\.\+]+\@[a-za-z0-9\.\-]+\.[a-za-z0-9]{2,4}$/;
    if(get_value.match(emailexp)){
        return true;
    }else{
        return false;
    }
}
//-----------------------------------------------------------------------------   is_en
function is_en(get_value)
{
    var alphaexp = /^[a-z A-Z]+$/;
    if(get_value.match(alphaexp)){
        return true;
    }else{
        return false;
    }
}
//-----------------------------------------------------------------------------   is_custom_en
function is_custom_en(get_value,other_char)
{              
    var alphaexp = '^[a-z A-Z' + other_char + ']+$';
    if(get_value.match(alphaexp)){
        return true;
    }else{
        return false;
    }
}
//-----------------------------------------------------------------------------   is_fa
function is_fa(get_value)
{
    var str_exp = '^[ ءآؤئابتثجحخدذرزسشصضطظعغفقكکلمنهويیپچژگ]+$';
    if(get_value.match(str_exp))
    {
        return true;
    }
    else
    {
        return false;
    }
}
//-----------------------------------------------------------------------------   is_custom_fa
function is_custom_fa(get_value,other_char)
{ 
    get_value = get_value.replace(/-/g,'\-');          
    var alphaexp = '^[ ءآؤئابتثجحخدذرزسشصضطظعغفقكلمنهويپچژگ' + other_char + ']+$';
    if(get_value.match(alphaexp)){
        return true;
    }else{
        return false;
    }
}
//-----------------------------------------------------------------------------   check_bad_string
function check_bad_string(get_value)
{
    var str_exp = '[<>\'";&%#]+';
    if(get_value.match(str_exp))
    {
        return true;
    }
    else
    {
        return false;
    }
}
//-----------------------------------------------------------------------------   check_custom_bad_string
function check_custom_bad_string(get_value,other_char)
{
    var str_exp = '[' + other_char + ']+';
    if(get_value.match(str_exp))
    {
        return true;
    }
    else
    {
        return false;
    }
}
//-----------------------------------------------------------------------------   is_std_01
function is_std_01(get_value,other_char)
{
    var alphaexp = '^[a-za-z]+[a-za-z0-9' + other_char + ']+$';
    if(get_value.match(alphaexp)){
        return true;
    }else{
        return false;
    }
}
//-----------------------------------------------------------------------------   get_standard_fa
function get_standard_fa(get_value)
{
//    get_value = get_value.replace(/ە/g,'ه');
//    get_value = get_value.replace(/ى/g,'ي');
//    get_value = get_value.replace(/ی/g,'ي');
//    get_value = get_value.replace(/ک/g,'ك');
    return  get_value;    
}
//-----------------------------------------------------------------------------   get_standard_fa
function open__url(url_,Name_,height_,width_,left_,top_){
		MyWin = window.open(url_,Name_,'height=' + height_ + ',width=' + width_ + ',left=' + left_ +',top=' + top_ + ',resizable=no,scrollbars=no,toolbar=no,status=no');
	//MyWin.focus()
}
//-----------------------------------------------------------------------------   get_standard_fa

function set_clipboard(value_)
{
	window.clipboardData.setData("text", value_);
	alert('آدرس زير در حافظه موقت سيستم ذخيره شد'+ "\n" + value_);
}
//-----------------------------------------------------------------------------   
function get_clipboard()
{
	return window.clipboardData.getData("text");
}
//-----------------------------------------------------------------------------   
function findPosX(obj){
	var curleft = 0;
	if(obj.offsetParent)
		while(1){
			curleft += obj.offsetLeft;
			if(!obj.offsetParent)break;
			obj = obj.offsetParent;
		}
		else if(obj.x) curleft += obj.x;
	return curleft;
}
//-----------------------------------------------------------------------------   
function findPosY(obj){
	var curtop = 0;
	if(obj.offsetParent)
		while(1){
			curtop += obj.offsetTop;
			if(!obj.offsetParent)break;
			obj = obj.offsetParent;
		}
	else if(obj.y)curtop += obj.y;
	return curtop;
}



//-----------------------------------------------------------------------------   (show and hidden calender page)
	var CDateitem = 0;
	function SetDateValue(num){
		if(num!=0){
			document.getElementById("t"+CDateitem).value = num;
		}
		document.getElementById("CalendarView").style.visibility = "hidden";
	}

	function ShowCalendar(num){
		CDateitem = num
		CalendarTableHeight = 230;
		CalendarTableWidth = 220;

		MyLeft = findPosX(document.getElementById("t"+CDateitem)) - CalendarTableWidth;
		MyTop = findPosY(document.getElementById("t"+CDateitem))
		if(screen.height<MyTop+CalendarTableHeight+200){
			MyTop = MyTop - CalendarTableHeight + 25;
		}
		document.getElementById("CalendarView").style.position = "absolute";
		document.getElementById("CalendarView").style.left = MyLeft;
		document.getElementById("CalendarView").style.top = MyTop;
		document.getElementById("CalendarView").style.visibility = "visible";
	}
//-----------------------------------------------------------------------------/////(show and hidden calender page)

//-----------------------------------------------------------------------------   (show and hidden RichText page)

	var CRichText = 0;
	var Cpicaddress = 0;
	var CLinkaddress = 0;
	var TRichText = "";
	function SetRichText(text){
		if(text!=0){
			document.getElementById("t"+CRichText).value = text;
		}
	}

	function SetPicAddress(text){
		if(text!=0){
			document.getElementById("t"+Cpicaddress).value = text;
		}
	}

	function SetLinkAddress(text){
		if(text!=0){
			document.getElementById("t"+CLinkaddress).value = text;
		}
	}
	
	function ShowRichText(num){
		CRichText = num;
		if(document.getElementById("t"+CRichText).value!=''){
			TRichText = document.getElementById("t"+CRichText).value;
		}
		CalendarTableHeight = 650
		CalendarTableWidth = 850
		MyTop = (window.screen.height - CalendarTableHeight) / 2;
		MyLeft = (window.screen.width - CalendarTableWidth) / 2;
//url_,Name_,height_,width_,left_,top_

		open__url(httpaddress+"module/TextEditorPro/TextEditor.html","",CalendarTableHeight,CalendarTableWidth,MyLeft,MyTop)
		//open__url(httpaddress+"module/richtext/richtext.htm","",CalendarTableHeight,CalendarTableWidth,MyLeft,MyTop)
	}
	
	function ShowRichTextEN(num){
		CRichText = num;
		if(document.getElementById("t"+CRichText).value!=''){
			TRichText = document.getElementById("t"+CRichText).value;
		}
		CalendarTableHeight = 650
		CalendarTableWidth = 850
		MyTop = (window.screen.height - CalendarTableHeight) / 2;
		MyLeft = (window.screen.width - CalendarTableWidth) / 2;
//url_,Name_,height_,width_,left_,top_
		open__url(httpaddress+"module/en_richtext/richtext.htm","",CalendarTableHeight,CalendarTableWidth,MyLeft,MyTop)
	}
	
//-----------------------------------------------------------------------------/////(show and hidden RichText page)
function selectAllCheckbox(Co){
	if(document.getElementById("C__selectall").checked){
		for(i=1;i<=Co;i++){
			document.getElementById("C__"+i).checked = true;
		}
	}else{
		for(i=1;i<=Co;i++){
			document.getElementById("C__"+i).checked = false;
		}
	}
}
	function ShowImageViewer(num){
		Cpicaddress = num;
		CalendarTableHeight = 500
		CalendarTableWidth = 600
		MyTop = (window.screen.height - CalendarTableHeight) / 2;
		MyLeft = (window.screen.width - CalendarTableWidth) / 2;
		open__url(httpaddress+"module/picture_viewer/viewer.asp","",CalendarTableHeight,CalendarTableWidth,MyLeft,MyTop)
		//			MyWin1 = window.open(httpaddress+"module/picture_viewer/viewer.asp","viewer",'height=' + CalendarTableHeight + ',width=' + CalendarTableWidth + ',left=' + MyLeft +',top=' + MyTop + ',resizable=no,scrollbars=no,toolbar=no,status=no');
	}

	function ShowLinkViewer(num){
		CLinkaddress = num;
		CalendarTableHeight = 300
		CalendarTableWidth = 300
		MyTop = (window.screen.height - CalendarTableHeight) / 2;
		MyLeft = (window.screen.width - CalendarTableWidth) / 2;
		open__url(httpaddress+"module/Link_viewer/viewer.asp","",CalendarTableHeight,CalendarTableWidth,MyLeft,MyTop)
		//			MyWin1 = window.open(httpaddress+"module/picture_viewer/viewer.asp","viewer",'height=' + CalendarTableHeight + ',width=' + CalendarTableWidth + ',left=' + MyLeft +',top=' + MyTop + ',resizable=no,scrollbars=no,toolbar=no,status=no');
	}
function cell_hover(a) {
	document.getElementById("cell_" + a).className = "page2_cell_hover";
}
function Len(str){return String(str).length;}
function Mid(str, start, len){if (start < 0 || len < 0) return "";	var iEnd, iLen = String(str).length;if (start + len > iLen){iEnd = iLen;}else{iEnd = start + len;}return String(str).substring(start,iEnd);}

function slowdownScroll() {
   if(navigator.appName == "Microsoft Internet Explorer" && document.compatMode == "CSS1Compat") {
      sctop = document.body.parentNode.scrollTop;
   }
   else if(window.pageYOffset){
      sctop = window.pageYOffset;
   } else {
      sctop = document.body.scrollTop;
   }

   if(sctop){
      scup = Math.ceil(sctop*.1);
      scrollBy(0,-scup);
      if (sctop-scup) setTimeout("slowdownScroll()",10);
   }
}


