// JavaScript Document
//fillTitle();
	fillPostGiud();


//check the language 
function fnPastText()
{
	try
	{
		var bCheckFeedbackTextSize=false;		
		if(fnCheckLanguagePast(window.clipboardData.getData("Text")))
		{
			var strComments = document.getElementById('txtComments').value;
			bCheckFeedbackTextSize = fnCheckFeedbackTextSize(strComments + window.clipboardData.getData("Text"));
		}
		if(!bCheckFeedbackTextSize)
		{
			window.clipboardData.setData("Text","");
			return false;
		}
	}
	catch (ex)
	{
		//do nothing 
	}
}


//check the language 
function fnCheckDropedText()
{
	var bCheckDropedTextSize = false;
	if(fnCheckLanguagePast(event.dataTransfer.getData("Text")))
	{	
		var strComments = document.getElementById('txtComments').value;
		bCheckDropedTextSize = fnCheckFeedbackTextSize(strComments+event.dataTransfer.getData("Text"));		
	}
	if(!bCheckDropedTextSize)
	{
		event.dataTransfer.setData("Text","");
		return false;
	}
}







function fnCheckTextEntered()
{
//debugger;
	var bCheckFeedbackTextSize = false;
	
	if(fnCheckLanguage())
	{
		var strComments = document.getElementById('txtComments').value;
		bCheckFeedbackTextSize = fnCheckFeedbackTextSize(strComments+1);
	}
	if(!bCheckFeedbackTextSize)
	{
		return false;
	}
}



//check the language (key pressed)
function fnCheckLanguage()
{

	var strHexPressedKeyCode
	
		strHexPressedKeyCode = event.keyCode; 
	
	return CheckCharLanguage (strHexPressedKeyCode);
}
function keypress(e) 
{     
	return e.keyCode
}


//check if the passed character is allowed or not
function CheckCharLanguage (strHexPressedKeyCode)
{
	try
	{
		//-- Allowed Ranges
		//edited By Haitham @ 14/11/2006
		if (((strHexPressedKeyCode >= parseInt("0x600"))  && (strHexPressedKeyCode <= parseInt("0x6FF"))) || ((strHexPressedKeyCode >= parseInt("0x30")) && (strHexPressedKeyCode <= parseInt("0x39")))|| ((strHexPressedKeyCode >= parseInt("0x20"))  && (strHexPressedKeyCode <= parseInt("0x2F"))) || ((strHexPressedKeyCode >= parseInt("0x3A"))  && (strHexPressedKeyCode <= parseInt("0x40"))) || ((strHexPressedKeyCode >= parseInt("0x5B"))  && (strHexPressedKeyCode <= parseInt("0x60"))) || ((strHexPressedKeyCode >= parseInt("0x7B"))  && (strHexPressedKeyCode <= parseInt("0x7F")))|| ((strHexPressedKeyCode >= parseInt("0x0"))  && (strHexPressedKeyCode <= parseInt("0x1F"))) || (strHexPressedKeyCode == parseInt("0x2019")) || (strHexPressedKeyCode == parseInt("0xD")))	
				{return true;}
		else
		{
			
			alert ("الرجاء إدخال التعليق باللغة العربية!!!");
			
		return false;
		}
		
		
	}
	catch (eX)
	{
		// do nothing 
	}
}

// Take the whole text pasted and check if there is any not allowed charcters
function fnCheckLanguagePast (strText)
{
	try 
	{
		var bCheckCharLanguage;
		for (i =0; i < strText.length; i++)
		{
			bCheckCharLanguage = CheckCharLanguage (strText.charCodeAt(i));
			if (!(bCheckCharLanguage))
			{return false;}
		}
		return true;
	}
	catch (ex)
	{
		//do nothing
	}
}

//Get the file name (post guid) and store it in hidden control)
function fillPostGiud()
{
	var postGuid = location.pathname.substring(location.pathname.lastIndexOf("/")+1,location.pathname.length); 
	if (document.getElementById('hdnPostGUID'))
		document.getElementById('hdnPostGUID').value = postGuid.substring(0,postGuid.lastIndexOf(".htm")) ;	
}



