function popup(URLStr , width, height , scrollbars )
{
  var popUpWin=0;
  
  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollbars+',resizable=no,copyhistory=yes,width='+width+',height='+height+'');

}

// JavaScript Document

function show( obj )
{
	obj.style.display = 'block';	
}


 function addF() 
 {

 title = "Webpage Title"; 
  // Blogger - Replace with <$BlogItemTitle$> 
  // MovableType - Replace with <$MTEntryTitle$>

 url = "Webpage URL";
  // Blogger - Replace with <$BlogItemPermalinkURL$> 
  // MovableType - Replace with <$MTEntryPermalink$>
  // WordPress - <?php bloginfo('url'); ?>
	if( window.external ) 
	{ // IE Favorite
		window.external.AddFavorite( url, title); 
	}else 
	if (window.sidebar)
	{ // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} 
	
	else if(window.opera && window.print) 
	{ // Opera Hotlist
		return true; 
	}
 }






function get_From_Server(request,object){
		try{ 
			Answer = new XMLHttpRequest();
		}catch(error)
		{
		try{
			Answer = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(error){ Answer = null; return false;
			}
		}

		Answer.onreadystatechange = change_when_have_info;
		Answer.object = object;
		Answer.open("POST", request);
		//Answer.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		Answer.send(null);
	}

	function change_when_have_info(object){
		if (Answer.readyState == 4){
			if(Answer.status == 200){
					document.getElementById(Answer.object).innerHTML = Answer.responseText;
			}
		}
	}

function ResizeThem()
{
  var maxheight = 1000;
  var maxwidth = 500;
  var imgs = document.getElementsByTagName("img");

  for ( var p = 0; p < imgs.length; p++ )
  {
    if ( 1 )
    {
	
      var w = parseInt( imgs[p].width );
      var h = parseInt( imgs[p].height );
      if ( w > maxwidth )
      {
	var newcontent = document.createElement('div');
	newcontent.id = 'syndicated-content';
	newcontent.className = "alert";
	newcontent.appendChild(document.createTextNode('الصورة مصغرة - اضغط على الصورة لعرض الحجم الطبيعي'));
	
	imgs[p].parentNode.insertBefore(newcontent, imgs[p]);
	
        imgs[p].style.cursor = "pointer";
        imgs[p].onclick = function( )
        {
          var iw = window.open ( this.src, 'ImageViewer','resizable=1' );
          iw.focus();
        };
        h = ( maxwidth / w ) * h;
        w = maxwidth;
        imgs[p].height = h;
        imgs[p].width = w;
      }
      if ( h > maxheight )
      {
        imgs[p].style.cursor="pointer";
        imgs[p].onclick = function( )
        { 
          var iw = window.open ( this.src, 'ImageViewer','resizable=1' );
          iw.focus( );
        };
        imgs[p].width = ( maxheight / h ) * w;
        imgs[p].height = maxheight;
      }
    }
  }
}

function sendForm(form,link) 
{
		
		if( $(form+'_loading') )
		{
			$('#'+form+'_loading').append("<img src='images/loading.gif' id='"+form+"_loading_img'/>");
		}
		
		doSomething = function DS( data )
		{
			 showResponse( form , data );
		}
		
		$.post(link, $('#'+form).serialize() , doSomething );
}

function showResponse(form , data){

	if( data.substr(0,6) == "msgBox" )
	{
		alert( data.substr(6,data.length-6) );
	}
	else if( data.substr(0,7) == 'refresh' )
	{
		alert( data.substr(7,data.length-6) );
		window.location.reload( false );
	}
	else
	{
		alert(data);	
	}

	$('#'+form+'_loading_img').remove();
}
