/*======================================================================*\
|| #################################################################### ||
|| # DevContact Version 2.3.1 - Developer 2007							||
|| # هذا السكربت مجانى ولكن لا يمكنك استخدام اكواده فى اى سكربت آخر		||
|| # ByPHP.NET															||
|| #################################################################### ||
\*======================================================================*/
/*
@ DEFINE ("These Functions has made by Developer", "http://www.ByPHP.net");
@ You can't use this script without permission from me
@ To contact me addslashes@msn.com
*/
function init()
{
	var cookie = getCookie('Developer_Collapsable');
    if(cookie)
    {
		var values = cookie.split(',');
        for(var i = 0; i < values.length; i++)
        {
	        var itm = getItem(values[i]);
            if(itm)
            {
                itm.style.display = 'none';
            }
		}
	}
}

function setCookie(name, value, expires)
{
    var time = new Date()  
    time.setDate(time.getDate()+expires)  
	var cookie = name + '=' + escape(value) + ';' + ((expires == null) ? '' : ';expires=' + time.toGMTString());
    document.cookie = cookie;
}


function getCookie(name)
{
	if(document.cookie == '')
	return false;
	var firstPos;
	var lastPos;
    var cookie = document.cookie;

	firstPos = cookie.indexOf(name);

    if(firstPos != -1)
    {
		firstPos += name.length + 1;
        lastPos = cookie.indexOf(';', firstPos);

        if(lastPos == -1)
		lastPos = cookie.length;

        return unescape(cookie.substring(firstPos, lastPos));
	}

    else
		return false;
}

function getItem(id)
{
	var itm = false;
    if(document.getElementById)
		itm = document.getElementById(id);
	else if(document.all)
		itm = document.all[id];
    else if(document.layers)
		itm = document.layers[id];
    return itm;
}

function toggleItem(id)
{
	itm = getItem(id);
    if(!itm)
	    return false;
    if(itm.style.display == 'none')
		itm.style.display = '';
    else
        itm.style.display = 'none';
    ////////////////////

	cookie = getCookie('Developer_Collapsable');
    values = new Array();
    newval = new Array();
    add    = 1;

    if(cookie)
    {
		values = cookie.split(',');

        for(var i = 0; i < values.length; i++)
		{
			if(values[i] == id)
				add = 0;
            else
	            newval[newval.length] = values[i];
        }
	}

    if(add)
		newval[newval.length] = id;

        setCookie('Developer_Collapsable', newval.join(','), 365);
		itm.focus()
        return false;
}

function ShowMenu(num, menu, max)
{
	for(i = 1; i <= num; i++)
	{
		var menu2 = menu + i;
        document.getElementById(menu2).style.display = 'block';
    }
    var num2 = num;
    num2++;

    while(num2 <= max)
	{
		var menu3 = menu + num2;
        document.getElementById(menu3).style.display = 'none';
        num2=num2+1;
	}
}

var c=1;
var cc = 1;
var t;
function prepareChange(id, cols, rows)
{
	textarea = new Object();
	textarea.id = document.getElementById(id);
	textarea.cols = cols;
	textarea.rows = rows;
	change();
}

function change()
{
	textarea.id.rows = c;
	textarea.id.cols = cc;

	if(cc == textarea.cols)
	{
		cc = textarea.cols;
	}
	else if(textarea.cols < cc)
	{
		cc = 1;
	}
	else
	{
		cc++;
	}

	if(c == textarea.rows)
	{
		c = textarea.rows;
	}
	else if(textarea.rows < c)
	{
		c = 1;
	}
	else
	{
		c++;
	}

	t=setTimeout('change()',50);
}

function resize(id, so)
{
	if (so == 0)
	{
		var rows = -5;
		var cols = -10;
	}
	else
	{
		var rows = 5;
		var cols = 10;
	}
	var textarea = document.getElementById(id);
	var newrows = textarea.rows + rows;
	var newcols = textarea.cols + cols;
	textarea.rows = newrows;
	textarea.cols = newcols;


}
function new_window(url)
{
	link = window.open(url, 'Maillist', 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1, width=500, height=250, left=180, top=180');
}
function pick(name, email)
{
	if (window.opener && !window.opener.closed)
	{
		if (window.opener.document.mail.name.value.length == 0)
		{
			window.opener.document.mail.name.value = name;
		}
		else if (window.opener.document.mail.name.value.length > 0)
		{
			window.opener.document.mail.name.value += '|' + name;
		}

		if (window.opener.document.mail.email.value.length == 0)
		{
			window.opener.document.mail.email.value = email;
		}
		else if (window.opener.document.mail.email.value.length > 0)
		{
			window.opener.document.mail.email.value += '|' + email;
		}
	}
}
function remlink()
{
	if (window.link && window.link.open && !window.link.closed)
	{
		window.link.opener = null;
	}
}
function changeBg(id, color)
{
	var theCur = getCookie('curid');
	if(theCur)
	{
		document.getElementById(theCur).style.backgroundColor = '#F2F2F2';
	}
	document.getElementById(id).style.backgroundColor = '#' + color;
	setCookie('curid', id);
}
var toggled;
function makeCheck(formName)
{
	if (toggled == 0)
	{
		unCheck(formName);		
	}
	else
	{
		check(formName);
	}
}

function check(formName)
{
    for (i=0; i < document.forms[formName].length; i++)
    {
		current = document.forms[formName].elements[i];
		if (current.type == 'checkbox')
		{
			current.checked = true;
		}
	}
	toggled = 0;
}
function unCheck(formName)
{
    for (i=0; i < document.forms[formName].length; i++)
    {
		current = document.forms[formName].elements[i];
		if (current.type == 'checkbox')
		{
			current.checked = false;
		}
	}
	toggled = 1;
}
function DevTimeDate(input)
{
	var d = new Date();
	var currYear = d.getFullYear();
	var currMonth = d.getMonth() + 1;
	var currDate = d.getDate();
	var currHour = d.getHours();
	var currMin = d.getMinutes();
	var theInput;
	time = 'التاريخ: ' + currYear + '/' +
	(currMonth < 10 ? '0' : '') + currMonth + '/' +
	(currDate < 10 ? '0' : '') + currDate + ' ' +
	'الوقت: ' + (currHour < 10 ? '0' : '') + currHour + ':' +
	(currMin < 10 ? '0' : '') + currMin;
	theInput = document.getElementById(input);
	theInput.value = theInput.value + ' ' + time + ' ';
	theInput.focus();
}
/* ------------------------------------ */