// JavaScript Document

function showPanel(panelid,imgid)
{
	try {
			panel  = document.getElementById(panelid);
			img 	= document.getElementById(imgid);
			
			//alert(panel.style.display.length);
		
			if(panel.style.display == false || panel.style.display == 'block')	
			{
				panel.style.display = 'none';
				img.src = 'images/down.gif';
				img.title = 'فتح';
				img.blur();
			}
			else if( panel.style.display == 'none')
			{
				panel.style.display = 'block';	
				img.src = 'images/up.gif';	
				img.title = 'غلق';
				img.blur();
			}
		}
		catch (e) 
		{
			//alert(e+'Error'+e.name);
			return false;
		}
}

function showFatwa(panelid)
{
	try {
			panel  = document.getElementById(panelid);
			num = parseInt(panel.offsetHeight) ;
						
			if(panel.style.display == 'none' || num == 0)	
			{
				panel.style.display = 'block';
			}
			else if( panel.style.display == 'block' || num > 0)
			{
				panel.style.display = 'none';	
			}
		}
		catch (e) 
		{
			alert(e+'Error'+e.name);
			return false;
		}
}


function Correctstyle()
{
	var appVer =navigator.appVersion;
	if(appVer.indexOf('MSIE 6') > 0)
	{
//		elm = document.get	
	}
}

function checklogin()
{

    var username = document.getElementById("username");
    var password = document.getElementById("password");
    if( username.value.length < 1 || password.value.length <1 )
    {
        alert('يجب إدخال اسم المستخدم وكلمة السر بشكل صحيح؟');
        return false;
    }
    return true;   
}

function clearField(controlname)
{
    var control = document.getElementById(controlname);
    if(control.value == "الإسم" || control.value == "البريد" || control.value == "الرسالة")
        control.value = "";
}

function textCounter(fieldname, maxlimit) 
{
    var field = document.getElementById(fieldname);
    if (field.value.length > maxlimit) // if too long...trim it!
    {
        field.value = field.value.substring(0, maxlimit);
    }
    // otherwise, update 'characters left' counter    
}

function getCookieData(labelName) 
{
    var labelLen = labelName.length;
    // read cookie property only once for speed
    var cookieData = document.cookie;
    var cLen = cookieData.length;
    var i = 0;
    var cEnd;
    while (i < cLen) 
    {
        var j = i + labelLen;
        if (cookieData.substring(i,j) == labelName) 
        {
            cEnd = cookieData.indexOf(';',j);
                if (cEnd == -1) 
                {
                    cEnd = cookieData.length;
                }
            return decodeURIComponent(cookieData.substring(j+1, cEnd));
        }
        i++;
    }
    return "";
}
function redirect(url)
{
	window.location = url;
}

function openCenteredWindow(url,width,height) 
{
	var myWindow;
//	var width = 500;
//	var height = 250;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = "width=" + width + ",height=" + height + 
		",status,noresizable,left=" + left + ",top=" + top + 
		",screenX=" + left + ",screenY=" + top;
	myWindow = window.open(url, "subWind", windowFeatures);
}
