<!--
// JavaScript Document By Saied Nobakht [saiednt@yahoo.com]
// My Special JavaScript Code Scroller
function showIt(elID) {
	var el = document.getElementById(elID);
	el.scrollIntoView(true);
}

function initScroller() {
	//scrollablediv 2
	var scroller2 = new Bs_ScrollableDiv();
	scroller2.init('divContainer_2', 'contentdivs');
	var sliderObj2 = new Bs_Slider();
	sliderObj2.attachOnChange(Bs_ScrollableDiv_sliderChange);
	sliderObj2.width          = 16;
	sliderObj2.height         = 'auto';
	sliderObj2.arrowMouseOver = true;
	sliderObj2.direction      = 1;
	sliderObj2.imgDir         = 'template/scrollbar/';
	sliderObj2.setBackgroundImage('scroll_ln.gif', 'repeat');
	sliderObj2.setSliderIcon('scroll_knob.gif', 16, 19);
	sliderObj2.setArrowIconLeft('scroll_up.gif', 16, 16);
	sliderObj2.setArrowIconRight('scroll_dn.gif', 16, 16);
	sliderObj2.useInputField = 1;
	scroller2.setSliderObject(sliderObj2, 'sliderDiv2');
	scroller2.setSlideSpeed(50, 'pixel'); //50 pixel per second
	scroller2.setWheelSpeed(20, 'pixel'); //20 pixel per tick
}
// Header News Scroller
function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 80)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}

function openImage(the_img, the_width, the_height)
{
	winDef = 'status=no,resizable=yes,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes, width='+ the_width +', height='+ the_height;
	winDef = winDef.concat(',top=').concat((screen.height - the_height)/2 - 30);
	winDef = winDef.concat(',left=').concat((screen.width - the_width)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<html><title>News Picture</title><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', the_img, '" alt="Close" border=0 align="center"></a>');
	newwin.document.writeln('</body></html>');

	return false;
}

//Specify affected tags. Add or remove from list:
var tagsElement = new Array( 'div','table','td','tr','p','span','strong','center');

//Specify spectrum of different font sizes:
var listFontSize = new Array( 'x-small','small','medium','large','x-large' );
var startFontSize = 1;

function changeFontSize(target, inc) {
	if (!document.getElementById) return
	var doc = document, targetEl = null, inSize = startFontSize, i, j, contentTags;
	
	inSize += inc;
	if ( inSize < 0 ) inSize = 0;
	if ( inSize > 4 ) inSize = 4;
	startFontSize = inSize;
		
	if ( !( targetEl = doc.getElementById( target ) ) ) targetEl = doc.getElementsByTagName( target )[ 0 ];

	targetEl.style.fontSize = listFontSize[ inSize ];

	for ( i = 0 ; i < tagsElement.length ; i++ ) {
		contentTags = targetEl.getElementsByTagName( tagsElement[ i ] );
		for ( j = 0 ; j < contentTags.length ; j++ ) contentTags[ j ].style.fontSize = listFontSize[ inSize ];
	}
}

function disableSelection(target){
	if (typeof target.onselectstart!="undefined") //IE route
		target.onselectstart=function(){return false}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
		target.style.MozUserSelect="none"
	else //All other route (ie: Opera)
		target.onmousedown=function(){return false}
	target.style.cursor = "default"
}

function forbiddenCtrlKey(e) {
    //list all CTRL + key combinations you want to disable
    var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'p');
    var key;
    var isCtrl;

    if(window.event) {
        key = window.event.keyCode; //IE
        if(window.event.ctrlKey)
            isCtrl = true;
        else
            isCtrl = false;
    }
	else {
        key = e.which; //Firefox
        if(e.ctrlKey)
            isCtrl = true;
        else
            isCtrl = false;
    }
    //if ctrl is pressed check if other key is in forbidenKeys array
    if(isCtrl) {
        for(i=0; i<forbiddenKeys.length; i++) {
            //case-insensitive comparation
            if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase()) {
//	        alert('Key combination CTRL + ' + String.fromCharCode(key) + ' has been disabled.');
	            copyIntoClipboard('Sorry! this news only view in Jomhoriyat.Com');
                return false;
            }
        }
    }
    return true;
}

function copyIntoClipboard(text) {  
    if(window.clipboardData) {  
       window.clipboardData.setData('text',text);  
    }
    return true;  
}

function initContextMenu(allow) {
	if(allow==false) {
		document.body.oncontextmenu = function() {return false;};
	} else {
		document.body.oncontextmenu = function() {return true;};		
	}
}
//-->
