﻿var gAutoPrint = true; // Call print function
function printxt()
{
 if (document.getElementById != null)
 {
  var html = '<html>\n<head><link rel="stylesheet" type="text/css" href="/Style Library/ar-sa/style.css">';
  

  if (document.getElementsByTagName != null)
  {
   var headTags = document.getElementsByTagName('head');
   if (headTags.length > 0)
    html += headTags[0].innerHTML;
  }

  html += '\n</head>\n<body style="background-color:#ffffff;background-image:none;">\n';
  html += '\n<table border="0" class="PrintTable" align="center"><tr><td style="text-align:center;display:none;"><img src="/images/main/logo.gif" /></td></tr><tr><td>&nbsp;</td></tr>';
  html += '<tr><td style="width:100%;">\n';

  var printReadyElem = document.getElementById("printContent");
  
  if (printReadyElem != null)
  {
    html += printReadyElem.innerHTML;
  }
  else
  {
   alert('There is nothing to Print');
   return;
  }
  html += '\n</td></tr><tr><td><hr /></td></tr>';
  html += '<tr><td class="PrintCopyRight">&copy; مشروع الملك عبد الله بن عبد العزيز لتطوير التعليم العام</td></tr></table>';

  html += '\n</body>\n</html>';
  
  var printWin = window.open('','printxt');
  printWin.document.open();
  printWin.document.write(html);
  printWin.document.close();
  if (gAutoPrint)
   printWin.print();
 }
 else
 {
  alert("Your Browser Doesn't Support This Feature");
 }
}

// use this function to open send to friend window
function SendToFriend()
{
	var pageTitle = document.title;
	var pageURL = document.location.href;
	window.open('/Pages/SendToFriend.aspx?title=' + pageTitle + '&link=' + pageURL, '_blank','menubar=0,toolbar=0,resizable=1,location=0,status=1,scrollbars=1,width=500,height=300')
}

/*function AddToFavorite()
{
	var title = document.title;
	var url = document.location.href;
	
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print)
	{ 	// opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all) // ie
		window.external.AddFavorite(url, title);
}*/


function AddToFavorite()
{
                var title = document.title;
                var url = document.location.href;
                var msg = "لاضافة الصفحة الى المفضلة اضغط على ctrl+D";
                if (window.sidebar) // firefox
                                alert(msg);
                else if(window.opera && window.print)
                {              // opera
                                var elem = document.createElement('a');
                                elem.setAttribute('href',url);
                                elem.setAttribute('title',title);
                                elem.setAttribute('rel','sidebar');
                                elem.click();
                } 
                else if(document.all) // ie
				{
                                window.external.AddFavorite(url, title);
				}
				else if( navigator.userAgent.toLowerCase().indexOf('chrome')>-1)
				{
						alert(msg);
				}
				else
					alert(msg);
				
}




function ChangePassword()
{
	var url = window.location.toString();
	if (url.indexOf('tatweer.edu.sa') == -1)
	{
		window.open('http://www.net.edu.sa/Pages/shared/changePassword.aspx', '_blank','menubar=0,toolbar=0,resizable=0,location=0,status=1,scrollbars=1,width=420,height=350');
	}
	else
	{
		window.open('http://www.tatweer.edu.sa/Pages/shared/changePassword.aspx', '_blank','menubar=0,toolbar=0,resizable=0,location=0,status=1,scrollbars=1,width=420,height=350');
	}
}

function ResetPassword()
{
	window.open('http://www.net.edu.sa/Pages/shared/ResetPassword.aspx', '_blank','menubar=0,toolbar=0,resizable=0,location=0,status=1,scrollbars=1,width=420,height=350');
}

function Complain()
{
	var pageTitle = document.title;
	var pageURL = document.location.href;
	window.open('http://www.net.edu.sa/Pages/shared/Complain.aspx?title=' + pageTitle + '&link=' + pageURL, '_blank','menubar=0,toolbar=0,resizable=0,location=0,status=1,scrollbars=1,width=420,height=350');
}

function ContentComments()
{
	var pageTitle = document.title;
	var pageURL = document.location.href;
	window.open('http://www.net.edu.sa/Pages/shared/ContentComments.aspx?title=' + pageTitle + '&link=' + pageURL, '_blank','menubar=0,toolbar=0,resizable=1,location=0,status=1,scrollbars=1,width=500,height=300')
}

function Trim(str)
{
   	//trim leding spaces
	while(true)
    {
    	if(str.charAt(0) == ' ')
        	str = str.substr(1);
		else
        	break;
	}
    //trim trailing spaces
    while(true)
    {
    	if(str.charAt(str.length-1) == ' ')
        	str = str.substr(0,str.length-1);
		else
        	break;
	}
    return(str);
}

function ConfirmDelete()
{
	return confirm('هل متأكد من حذف العنصر؟');
}
