var rotatecount=1;
function Promo(refreshTime, width, height, altText, start, random){

	this.objName = "PromoBanner" + (Promo.count++);
	eval(this.objName + "=this");
	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000;
	if (!width) this.width = 421; else this.width = width;
	if (!height) this.height = 150; else this.height = height;
	if (random == null) this.random = 1; else this.random = random;
	this.altText = altText;
	this.Banners = [];
	this.defaultfirst = 0;  /* whether the first banner is fixed */
	if (start) {
		this.currentBanner = start-1;
		this.defaultfirst = 1;
	} else {
		start = null;
	}
	this.mySize = 0;

	this.Banner = function(src, href, target, mouseover) {
		if (src.indexOf(".swf") >= 0) {  
			this.Banners[this.mySize] = new Object();
			var Banner = this.Banners[this.mySize];
			Banner.src = src;
			if (typeof(target) == "undefined" || target == null) Banner.target = "_self"; else Banner.target = target;
			Banner.href = href;
			Banner.mouseover = mouseover;
			this.mySize++;
		} else {
			var tempImage = new Image();
			tempImage.src = src;
			this.Banners[this.mySize] = new Object();
			var Banner = this.Banners[this.mySize];
			Banner.src = src;
			if (typeof(target) == "undefined" || target == null) Banner.target = "_self"; else Banner.target = target;
			Banner.href = href;
			Banner.mouseover = mouseover;
			this.mySize++;
		}
	}

	this.link = function(){
		var	Banner = this.Banners[this.currentBanner];
		if (Banner.target == "_self"){
			location.href = Banner.href;
		}
		else if (Banner.target == "_blank" || Banner.target == "_new"){
			open(Banner.href,this.objName + "Win");

		}
		else top.frames[Banner.target].location.href = Banner.href;
	}

	this.showStatus = function(){
		var Banner = this.Banners[this.currentBanner];
		if (Banner.mouseover) status = Banner.mouseover;
		else status = Banner.href;
	}

	this.randomBanner = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentBanner);
		this.currentBanner = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentBanner == null) this.randomBanner();
			if (this.currentBanner >= this.mySize) this.currentBanner = this.mySize - 1;

			var strsrc = this.Banners[this.currentBanner].src;
			var loadpage_target = '0';
			if (strsrc.indexOf(".swf") >= 0) {   
				var Banner = this.Banners[this.currentBanner];
				loadpage_target = '1';
				if (Banner.target == '_self') {
					loadpage_target = '0';
				}
				var fo = new FlashObject(strsrc +"?clickTAG=`"+ Banner.href +"`;`Home`;`"+ loadpage_target +"`;`null`;`null`;`null`", "movie", this.width, this.height, "6", "#000000");
				fo.addParam("quality", "high");
				fo.addParam("movie", strsrc +"?clickTAG=`"+ Banner.href +"`;`Home`;`"+ loadpage_target +"`;`null`;`null`;`null`");
				fo.write(global_divid);
			} else {
				tempCode = '<a href="javascript:'+this.objName+'.link();"';
				tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
				tempCode += ' onMouseOut="status=\'\';return true">';
				tempCode += '<img src="' + strsrc + '" width="' + this.width;
				tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
				if (this.altText) tempCode += 'alt="'+this.altText + '" ';
				tempCode += 'border="0" /></a>';
				document.getElementById(global_divid).innerHTML = tempCode;
			}
		} else document.write("Error: two Promos must be defined for the script to work.");
	}

	this.newBanner = function(){
		if (!this.random){	
			this.currentBanner++;
			if (this.currentBanner >= this.mySize)
			   this.currentBanner = 0;
		}
		else {
			if (this.defaultfirst == 1) {
				this.defaultfirst = 0;
			} else {
				this.randomBanner();
			}
		}
		this.output();
		this.nextBanner();
	}

	this.nextBanner = function(){
		setTimeout(this.objName+'.newBanner()',this.refreshTime);
	}
}
Promo.count = 0;

if(typeof com == "undefined") var com = new Object();
if(typeof com.deconcept == "undefined") com.deconcept = new Object();
if(typeof com.deconcept.util == "undefined") com.deconcept.util = new Object();
if(typeof com.deconcept.FlashObjectUtil == "undefined") com.deconcept.FlashObjectUtil = new Object();
com.deconcept.FlashObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
  if (!document.createElement || !document.getElementById) return;
  this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
  this.skipDetect = com.deconcept.util.getRequestParameter(this.DETECT_KEY);
  this.params = new Object();
  this.variables = new Object();
  this.attributes = new Array();
  this.useExpressInstall = useExpressInstall;

  if(swf) this.setAttribute('swf', swf);
  if(id) this.setAttribute('id', id);
  if(w) this.setAttribute('width', w);
  if(h) this.setAttribute('height', h);
  if(ver) this.setAttribute('version', new com.deconcept.PlayerVersion(ver.toString().split(".")));
  this.installedVer = com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
  if(c) this.addParam('bgcolor', c);
  var q = quality ? quality : 'high';
  this.addParam('quality', q);
  var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
  this.setAttribute('xiRedirectUrl', xir);
  this.setAttribute('redirectUrl', '');
  if(redirectUrl) this.setAttribute('redirectUrl', redirectUrl);
}
com.deconcept.FlashObject.prototype = {
  setAttribute: function(name, value){
    this.attributes[name] = value;
  },
  getAttribute: function(name){
    return this.attributes[name];
  },
  addParam: function(name, value){
    this.params[name] = value;
  },
  getParams: function(){
    return this.params;
  },
  addVariable: function(name, value){
    this.variables[name] = value;
  },
  getVariable: function(name){
    return this.variables[name];
  },
  getVariables: function(){
    return this.variables;
  },
  createParamTag: function(n, v){
    var p = document.createElement('param');
    p.setAttribute('name', n);
    p.setAttribute('value', v);
    return p;
  },
  getVariablePairs: function(){
    var variablePairs = new Array();
    var key;
    var variables = this.getVariables();
    for(key in variables){
      variablePairs.push(key +"="+ variables[key]);
    }
    return variablePairs;
  },
  getFlashHTML: function() {
    var flashNode = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { 
      if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
      flashNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
      flashNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
      var params = this.getParams();
       for(var key in params){ flashNode += [key] +'="'+ params[key] +'" '; }
      var pairs = this.getVariablePairs().join("&");
       if (pairs.length > 0){ flashNode += 'flashvars="'+ pairs +'"'; }
      flashNode += '/>';
    } else { 
      if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
      flashNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
      flashNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
      var params = this.getParams();
      for(var key in params) {
       flashNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
      }
      var pairs = this.getVariablePairs().join("&");
      if(pairs.length > 0) {flashNode += '<param name="flashvars" value="'+ pairs +'" />';}
      flashNode += "</object>";
    }
    return flashNode;
  },
  write: function(elementId){
    if(this.useExpressInstall) {
      var expressInstallReqVer = new com.deconcept.PlayerVersion([6,0,65]);
      if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
        this.setAttribute('doExpressInstall', true);
        this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        this.addVariable("MMdoctitle", document.title);
      }
    } else {
      this.setAttribute('doExpressInstall', false);
    }
    if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
      var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
      n.innerHTML = this.getFlashHTML();
    }else{
      if(this.getAttribute('redirectUrl') != "") {
        document.location.replace(this.getAttribute('redirectUrl'));
      }
    }
  }
}

com.deconcept.FlashObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
  var PlayerVersion = new com.deconcept.PlayerVersion(0,0,0);
  if(navigator.plugins && navigator.mimeTypes.length){
    var x = navigator.plugins["Shockwave Flash"];
    if(x && x.description) {
      PlayerVersion = new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
    }
  }else{
    try{
      var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      for (var i=3; axo!=null; i++) {
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
        PlayerVersion = new com.deconcept.PlayerVersion([i,0,0]);
      }
    }catch(e){}
    if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; 
    if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
      try{
        PlayerVersion = new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
      }catch(e){}
    }
  }
  return PlayerVersion;
}
com.deconcept.PlayerVersion = function(arrVersion){
  this.major = parseInt(arrVersion[0]) || 0;
  this.minor = parseInt(arrVersion[1]) || 0;
  this.rev = parseInt(arrVersion[2]) || 0;
}
com.deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
  if(this.major < fv.major) return false;
  if(this.major > fv.major) return true;
  if(this.minor < fv.minor) return false;
  if(this.minor > fv.minor) return true;
  if(this.rev < fv.rev) return false;
  return true;
}
com.deconcept.util = {
  getRequestParameter: function(param){
    var q = document.location.search || document.location.hash;
    if(q){
      var startIndex = q.indexOf(param +"=");
      var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
      if (q.length > 1 && startIndex > -1) {
        return q.substring(q.indexOf("=", startIndex)+1, endIndex);
      }
    }
    return "";
  }
}

if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

var getQueryParamValue = com.deconcept.util.getRequestParameter;
var FlashObject = com.deconcept.FlashObject;



var global_divid = 'bannercont';

function flash_loadpage(strparam) {
	strparam = strparam.replace(/`/gi, "");
	var ar_params = strparam.split(";");
	top.Loadpage(ar_params[0], ar_params[1], ar_params[2], ar_params[3], ar_params[4], ar_params[5]);
}

function MM_reloadPage(init) {  
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function directingto(path, tabId, target, external, height, width)
{

	height = ( (height == "") || (height == "null") || (!height) )?"534" :height;
	width =  ( (width  == "") || (width  == "null") || (!width)  )?"650" :width;
	tabId =  ( (tabId == "" ) || (tabId == "null" ) || (!tabId)  )?"home":tabId

	if (target == "1" || target == "2") {
		var param =     "left=95,top=11,scrollbars=yes,resizable=yes,width="+width+",height="+height;
		if(target == "2") {
				param += ",location=yes,status=yes,toolbar=yes,menubar=yes";
		}
		window.open(path, "_blank", param);
	}
}

function get_random(maxNum)
{
	if (Math.random && Math.round) {
		var ranNum= Math.round(Math.random()*(maxNum-1));
		ranNum+=1;
		return ranNum;
	} else {
		today= new Date();
		hours= today.getHours();
		mins=   today.getMinutes();
		secn=  today.getSeconds();
		if (hours==19) hours=18;
		var ranNum= (((hours+1)*(mins+1)*secn * Math.round(Math.random()*1000) )%maxNum)+1;
		return ranNum;
	}
}

function callrotate(value)
{
	if (value == 1)
	{
		Rotate01BannerImage('Main01')
	}
	if (value == 2)
	{
		Rotate02BannerImage('Main02')
	}
	if (value == 3)
	{
		Rotate03BannerImage('Main03')
	}
	if (value == 4)
	{
		Rotate04BannerImage('Main04')
	}
}

function getCurrentCookie1(name)
{
	if (document.cookie.length>0)
	  {
		
	  c_start=document.cookie.indexOf(name + "=");
	  if (c_start != -1)
		{ 
		c_start=c_start + name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	  }
	return "";
}

function setCookie1(name,value,expiredays)
{
	var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
document.cookie=name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function checkcookie1()
{
	var currentCookie1 = getCurrentCookie1('currentCookie');

if (currentCookie1!=null && currentCookie1!="")
  {
	cookie_sub_promo = currentCookie1.split(",");
  }
  else 
  {
	currentCookie1="Main01Promo1,Main02Promo1,Main03Promo1,Main04Promo1";
	cookie_sub_promo[0] = "Main01Promo1";
	cookie_sub_promo[1] = "Main02Promo1";
	cookie_sub_promo[2] = "Main03Promo1";
	cookie_sub_promo[3] = "Main04Promo1";
  if (currentCookie1!=null && currentCookie1!="")
    {
    setCookie1('currentCookie',currentCookie1,365);
    }
  }
}

function setransubbanner(bannervalue,arraycount)
{
	var maxnum,loopmax, kj;
	maxnum = 0; loopmax= 1000;
	for (kj=1; kj<=loopmax; kj++) {
		if (document.frmHome.elements[bannervalue+'Promo'+ kj]) {
		} else {
			break;  
		}
	}
	maxnum = kj - 1;

	var randnum = get_random(maxnum);
	cookiebann_value += bannervalue+'Promo'+ randnum;
	if (arraycount != '3')
	{
		cookiebann_value += ',';
	}
	return(document.frmHome.elements[bannervalue+'Promo'+ randnum].value);
}

function getbannvalue(mainbanncnt,arraycount)
{
	var bannerobjvalue;
	if (document.frmHome.elements[mainbanncnt+'SpecialPromo'])
	{
		if (cookie_sub_promo[arraycount].match(/SpecialPromo/))
		{
			if (document.frmHome.elements[mainbanncnt+'Promo1'])
			{
				if (setrandombanner)
				{  
					bannerobjvalue=setransubbanner(mainbanncnt,arraycount);
					return bannerobjvalue;
				}
			}
			else
			{
				bannerobjvalue= document.frmHome.elements[mainbanncnt+'SpecialPromo'].value;
				cookiebann_value += mainbanncnt+'SpecialPromo';
				if (arraycount != '3')
				{
					cookiebann_value += ',';
				}
				return bannerobjvalue;
			}

		}
		else
		{
			bannerobjvalue= document.frmHome.elements[mainbanncnt+'SpecialPromo'].value;
			cookiebann_value += mainbanncnt+'SpecialPromo';
			if (arraycount != '3')
			{
				cookiebann_value += ',';
			}
			return bannerobjvalue;
		}
	}
	else
	{
		bannerobjvalue= setransubbanner(mainbanncnt,arraycount);
		return bannerobjvalue;
	}
}

var cookiebann_value="";
var cookie_sub_promo = new Array();
var setrandombanner = true;

function newwindow(linkpath,win_target,win_param)
{
	window.open(linkpath,win_target,win_param);
}

function writeimage(bannerObj1)
{
	var myArray = bannerObj1.split('||');
	var size = myArray.length;
	var path		=	myArray[0];
	var imageName	=   myArray[1];
	var alttext		=   myArray[2];

	document.write('<a href='+path+'>');
	document.write('<img src=' +'"'+imageName + '"' +'alt='+'"'+alttext+'"'+'width="180" height="100"'+'hspace='+'"0"'+'border='+'"0"'+'/>' );
	document.write('</a>');

	rotatecount++;
}

function Rotate01BannerImage(mainbanncount)
{
	
	checkcookie1();
	var bannerObj = getbannvalue(mainbanncount,'0');
	writeimage(bannerObj);
}

function Rotate02BannerImage(mainbanncount)
{
	var setrandombanner = true;
	checkcookie1();	
	var bannerObj = getbannvalue(mainbanncount,'1')
	writeimage(bannerObj);
}

function Rotate03BannerImage(mainbanncount)
{
	var setrandombanner = true;
	checkcookie1();	
	var bannerObj = getbannvalue(mainbanncount,'2');
	writeimage(bannerObj);
}

function Rotate04BannerImage(mainbanncount)
{
	var setrandombanner = true;
	checkcookie1();	
	var bannerObj = getbannvalue(mainbanncount,'3');
	writeimage(bannerObj);

	if (cookiebann_value!=null && cookiebann_value!="")
	{
		setCookie1('currentCookie',cookiebann_value,365);
	}

}


function DeleteCookie (name) {

var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = getCookie(name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var Nav = navigator, Ag = Nav.userAgent;
var bIE = (Ag.indexOf('MSIE') >= 0), bMacIE = false;
var bNC = (navigator.appName == "Netscape");
var bOpera = (Ag.indexOf('Opera') >= 0);
var nVer = 0, sTmp = "";

if (bIE) {
	sTmp = Ag.substring(Ag.indexOf("MSIE") + 5, Ag.length);
	nVer = Math.floor (sTmp.substring(0, sTmp.indexOf(";")));
	if (nVer >= 4 && !document.all) nVer = 0;
	if (Ag.indexOf("Mac") >= 0) bMacIE = true;
}

if (bNC) nVer = Math.floor (Nav.appVersion.substring (0, Nav.appVersion.indexOf (" ") ) );
bDynamic = (document.all || document.layers) ? true : false;

var iStartCounter = 500;
var iResetCounter = iStartCounter;	
nMenuYPos = 80;
nYDelta = 25;
nPrevScrollPos = 0;

function populateFloatLayer() {
    if (bNC && nVer >= 4) {
		if (window.pageYOffset < nMenuYPos - nYDelta) nNeededPos = nMenuYPos;
		else nNeededPos = window.pageYOffset + nYDelta;
		nCurrentPos = document.getElementById("divFloat").offsetTop;
		//alert(nCurrentPos);
		if (nNeededPos == nCurrentPos) return;
		nCurrentPos += Math.round ( (nNeededPos - nCurrentPos) / 4);
		document.getElementById("divFloat").style.top = nCurrentPos+'px';
	}
	if (bIE && nVer >= 4 && !bMacIE) {
		if (document.body.scrollTop < nMenuYPos - nYDelta) nNeededPos = nMenuYPos;
		else nNeededPos = document.body.scrollTop + nYDelta;
		nCurrentPos = document.all["divFloat"].offsetTop;
		if (nNeededPos == nCurrentPos){
			iResetCounter--;
			if (iResetCounter < 0 ) {
				clearInterval(iInt); 
				iResetCounter = iStartCounter;
				loadFloatLayer();
			}
			return;
		}
		nDelta = (nNeededPos - nCurrentPos) / 6;
		if (nDelta > 0 && nDelta < 0.5) {
			nCurrentPos += nNeededPos - nCurrentPos;
		}else{
			if (nDelta < 0 && nDelta >= -0.5) nCurrentPos --;
			else nCurrentPos += Math.round (nDelta);
		}
		pnt = document.all ["divFloat"].style.top = nCurrentPos;
	}
}
function loadFloatLayer() {
    if (bNC && nVer >= 4) iInt = setInterval ("populateFloatLayer()", 20);
	else if (bIE && nVer >= 4 && !bMacIE) iInt = setInterval("populateFloatLayer()", 20);
}
