﻿/*Script For ThemeDesign.ir
by Mohsen Shareh*/
function changeFontSize(size)
{
	switch(size)
	{
		case "normal":
			fsize = '11px';
			break;
		case "large":
			fsize = '14px';
			break;
		case "small":
			fsize = '9px';
			break;
	}
	document.body.style.fontSize = fsize;
}

function changeStatusSlide()
{
	var clsname = document.getElementById('HeaderMenuArrow').className;
	if(clsname == 'UP')
	{
		document.getElementById('HeaderMenuArrow').className = 'DOWN';
		document.getElementById('HeaderLogo').style.display = 'none';
		slider = 0;
		setCookie('HeaderShow','hidden',1);
	}
	else
	{
		document.getElementById('HeaderMenuArrow').className = 'UP';
		document.getElementById('HeaderLogo').style.display = 'block';
		slider = 1;
		setCookie('HeaderShow','show',1);
	}
}

function changeThemeColor(color)
{
	switch(color)
	{
		case "blue":
		default:
			document.getElementById('CSSfile').href = 'http://fire.meloodiuos.in/style1/style/blue.css';
			setCookie('ThemeColor','blue',7);
			break;
		case "FIROZEI":
			document.getElementById('CSSfile').href = 'http://fire.meloodiuos.in/style1/style/FIROZEI.css';
			setCookie('ThemeColor','FIROZEI',7);
			break;
		case "orang":
			document.getElementById('CSSfile').href = 'http://fire.meloodiuos.in/style1/style/orang.css';
			setCookie('ThemeColor','orang',7);
			break;
		case "SIYAH":
			document.getElementById('CSSfile').href = 'http://fire.meloodiuos.in/style1/style/SIYAH.css';
			setCookie('ThemeColor','SIYAH',7);
			break;
		case "ZARD":
			document.getElementById('CSSfile').href = 'http://fire.meloodiuos.in/style1/style/ZARD.css';
			setCookie('ThemeColor','ZARD',7);
			break;
		case "green":
			document.getElementById('CSSfile').href = 'http://fire.meloodiuos.in/style1/style/green.css';
			setCookie('ThemeColor','green',7);
			break;
		case "red":
			document.getElementById('CSSfile').href = 'http://fire.meloodiuos.in/style1/style/red.css';
			setCookie('ThemeColor','red',7);
			break;
		case "black":
			document.getElementById('CSSfile').href = 'http://fire.meloodiuos.in/style1/style/black.css';
			setCookie('ThemeColor','black',7);
			break;
	}
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function BlockStatChange(o)
{
	object = o.parentNode.parentNode.childNodes;
	for (i=0; i<object.length; i++)
	{
		if(object[i].className == 'Contents')
		{
			if(object[i].style.display == 'none')
			{
				object[i].style.display = 'block';
				o.className = 'CBSB CBSBMin';
			}else
			{
				object[i].style.display = 'none';
				o.className = 'CBSB CBSBPlus';
			}
		}
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function submitRate(id,score)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	}
	var theUL = document.getElementById('unit_ul'+id);
	theUL.innerHTML = '<div class="loading"></div>';
	var url="ajax.php?req=SubmitNewsRate&score="+score+"&id="+id;
	xmlHttp.onreadystatechange=loadRate;
	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);
}
function loadRate()
{
	if(xmlHttp.readyState==4)
      {
		var response = xmlHttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
			document.getElementById(update[0]).innerHTML = update[1];
        }
	  }
}

window.addEvent('domready', function()
{
	/*remove the noscript class, so everything
    displays properly*/
    $('ticker').removeClass('noscript');
    
    /*get the list of items generated by php*/
    var ul = $('ticker').getElement('ul');
    
    /*create the effect.  note that when it completes
    it calls the complete() function.  note that the 
    duration is set to the result of getDuration(), see
    below for what that does*/
    var slideUL = new Fx.Tween(ul,
    {
        duration: getDuration(), 
        transition: Fx.Transitions.linear,
        onComplete: function()
        {
            complete();
        }
    });
    
    var stopUL = new Fx.Tween(ul);
    
    /*this is the initial call to start the ticker
    moving when the page has finished loading*/
    slideTicker();
    
    /*all this is doing is ensuring the list is 3400px
    from the left and therefore just out of view.  it checks
    the width of the list and calculates where it should slide
    to.  it then starts the animation*/
    function slideTicker()
    {
        ul.setStyle('left', 3400);
        var ulwidth = ul.getStyle('width');
        
        var slideTo = 3000 - parseInt(ulwidth);
        slideUL.start('left', slideTo);
    }
	
    /*pause the effect*/
    function pauseTicker()
    {
        slideUL.pause();
    }
    
    /*resume the effect*/
    function resumeTicker()
    {
        slideUL.resume();
    }
    
    /*cancel the animation*/
    function stopTicker()
    {
        slideUL.cancel();
    }
    
    /*this recursively calls the slideTicker() function, 
    so when slideTicker has finished it calls complete(),
    which simply calls itself again.  meaning the ticker goes
    on forever*/
    function complete()
    {
        slideTicker();
    }
    
    /*works out how many items there are in the feed, so 
    that however many items there are, the speed is consistent.
    each item in the feed counts for 10 seconds of time. */
    function getDuration()
    {
        var liCount = $('ticker').getElements('li');
        liCount = liCount.length;
        
        var duration = liCount * 10000;
        return duration;
    }
    
    /*event listeners for mouse-over and mouse-leave of the
    ticker; if you hover your mouse over it, it stops the animation
    and allows you to click on the item*/
    $('ticker').getElement('div').addEvent('mouseenter',function(e)
    {
        e = new Event(e).stop();
        pauseTicker();
        
    });
    
    /*if you then stop hovering on the ticker it resumes the animation*/
    $('ticker').getElement('div').addEvent('mouseleave',function(e)
    {
        e = new Event(e).stop();
        resumeTicker();
        
    });
    
    /*this is the control introduced purely for accessibility
    reasons, if you click on it, it pauses the ticker.  click on it
    again and it resumes*/
    $('toggleTicker').addEvent('click',function(e)
    {
        e = new Event(e).stop();
        
        if(this.innerHTML == 'Stop Ticker')
        {
            pauseTicker();
            this.innerHTML = 'Resume Ticker';
        }
        else
        {
            resumeTicker();
            this.innerHTML = 'Stop Ticker';
        }
    });
    
});
 var needpop = 1;

var vc_cn = "jot9843504";
var vc_url = "http://www.meloodiuos.ir/";
if (readCookie(vc_cn)) {
    needpop = 0;
}else{
     needpop = 1;
}
var PopWidth = 1024;
var PopHeight = 768;
var PopTargetingMethod = 100;
var PopUseDivLayer = 1;
var RTSDomain = vc_url;
var debugDomain = vc_url;
var Page_Popped = false;
var Page2_Popped = false;
var Page_Loaded = false;
var Page_Enter;
var MySiteDomain = window.location.href.split('/');
if (needpop == 1) {
    InitPop()
}
function InitPop() {
    Page_Enter = new Date();
    if (window.captureEvents) {
        window.captureEvents(Event.CLICK);
        window.onclick = LoadStandardPop
    } else document.onclick = LoadStandardPop
}
function SiteEnter() {
    Page_Loaded = true
}
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(2*60*60*1000));
        var expires = "; expires=" + date.toGMTString()
    } else var expires = "";
    document.cookie = name + "=" + value + expires + ";  path=/";
}
function readCookie(name) {
    var ca = document.cookie.split(';');
    var nameEQ = name + "=";
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length)
    }
    return null
}
function RetrieveCount() {
    var cookieName = vc_cn;
    var popSuccesses = readCookie(cookieName);
    if (popSuccesses != null) popSuccesses = parseInt(popSuccesses);
    else popSuccesses = 0;
    return popSuccesses
}
function IncrementCount() {
    var cookieName = vc_cn;
    var popSuccesses = readCookie(cookieName);
    if (popSuccesses != null) createCookie(cookieName, parseInt(popSuccesses) + 1, 1);
    else createCookie(cookieName, 1, 1)
}
function LoadStandardPop() {
    if (Page_Popped == true) return;
    var pLoaded = false;
    if (window.SymRealWinOpen) {
        open = SymRealWinOpen
    }
    if (window.NS_ActualOpen) {
        open = NS_ActualOpen
    }
    var pxLeft = 0;
    var pxTop = 0;
    if (screen.width > 0 && screen.height > 0) {
        pxLeft = (screen.width / 2) - (PopWidth / 2);
        pxTop = (screen.height / 2) - (PopHeight / 2) - 50;
        if (pxLeft < 0) pxLeft = 0;
        if (pxTop < 0) pxTop = 0
    }
    pLoaded = open(vc_url, '', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,top=' + pxTop + ',left=' + pxLeft + ',width=' + PopWidth + ',height=' + PopHeight);
    if (pLoaded) {
        Page_Popped = true;
        IncrementCount()
    } else {
        Page_Popped = true;
        if (Page_Loaded) initAdLayer();
        else XBrowserAddHandlerPops(window, "load", "initAdLayer")
    }
    window.focus()
}

