//flashdetection
//thanks to http://code.google.com/p/doctype/wiki/ArticleDetectFlash
function getFlashVersion(desc) {
    var matches = desc.match(/[\d]+/g);
    matches.length = 3;
    return matches.join('.');
}

var hasFlash = false;
var flashVersion = '';

if (navigator.plugins && navigator.plugins.length) {
	var plugin = navigator.plugins['Shockwave Flash'];
    if (plugin) {
      	hasFlash = true;
     	if (plugin.description) {
        	flashVersion = getFlashVersion(plugin.description);
      	}
    }
    if (navigator.plugins['Shockwave Flash 2.0']) {
      hasFlash = true;
      flashVersion = '2.0.0.11';
    }

} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
    var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
    hasFlash = mimeType && mimeType.enabledPlugin;
    if (hasFlash) flashVersion = getFlashVersion(mimeType.enabledPlugin.description);
} else {
	try {
		// Try 7 first, since we know we can use GetVariable with it
		var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
		hasFlash = true;
		flashVersion = getFlashVersion(ax.GetVariable('$version'));
	} catch (e) {
		// Try 6 next, some versions are known to crash with GetVariable calls
		try {
			var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
			hasFlash = true;
			flashVersion = '6.0.21';  // First public version of Flash 6
		} catch (e) {
			try {
				// Try the default activeX
				var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
				hasFlash = true;
				flashVersion = getFlashVersion(ax.GetVariable('$version'));
			} catch (e) {
			  // No flash
			}
		}
	}
}

//indicator image
var indicator=new Image();
indicator.src="../image/indicator.gif";



//main javascript for awrc4ct.org
function mId(c){
    return document.getElementById(c);
}

var cH=1;
function rotateHeadLine(nH){
	if (typeof(cH) == 'undefined');
    cO = mId('headline_'+ cH);
	j0 = mId('womenettitle_' + cH);
    if (cO){
		if (!nH) nH = ((cH * 1) + 1);
		if (nH > 4) nH = 1;
		nO = mId('headline_'+ nH);
		nj0 = mId('womenettitle_'+ nH);
		
		cO.style.display='none';
		j0.style.display='none';
		
		nO.style.display='';
		nj0.style.display='';
		
		ctO = mId('headline_footer_'+cH);
		ntO = mId('headline_footer_'+nH);
		
		ctO.style.backgroundColor='#F9E8F9';
		ntO.style.backgroundColor='#fff';
		cH = nH;
    }
}

function writePlImage(dv, id,url){
    dvx = mId(dv + '_div_' + id);
    ct = mId(dv + '_ctr_' + id);
    dvx.innerHTML = '<img src="'+url+'" name="' + dv + id +'" />';
    dvx.style.display='';
    ct.innerHTML = 'close image';
}

function preloadImg(id, url, dv){
    dvx = mId(dv + '_div_' + id);
    ct = mId(dv + '_ctr_' + id);
    if (dvx){
        if (dvx.style.display=='none'){
            cEval = 'oT=window.plimg' + id;
            eval(cEval);
            if (!oT){
                ct.innerHTML='<img src="image/indicator.gif" name="indicator" /> Wait, is loading...'; 
                cEval = dv + id + '= new Image()';
                eval(cEval);
                cEval = dv + id + '.onload= function(evt){writePlImage(\''+ dv + '\',' + id + ',\'' + url + '\');}';
                eval(cEval);
                cEval = dv + id + '.src = \'' +  url + '\'';
                eval(cEval);
            } else {
                dvx.style.display='';
            }
        } else {
            dvx.style.display='none';
            ct.innerHTML='show image';
        }
    }
}

function writeFlash(fl,pre,post,w,h,id,q,wm,l,p,a){
	if (!q) q='high';
	if (!wm) wm='transparent';
	if (!l) l='true';
	if (!p) p='true';
	
	if (hasFlash){
		if (pre) document.write(pre);
		document.write(' <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write('     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ');
		document.write('     NAME="' + id + '" ID="' + id  + '" WIDTH="' + w + '" HEIGHT="' + h + '">');
		document.write('    <PARAM NAME=movie VALUE="' + fl + '">');
		document.write('    <PARAM NAME="quality" VALUE="' + q + '">');
		document.write('    <PARAM NAME="wmode" VALUE="' + wm + '">');
		document.write('    <PARAM NAME="Loop" VALUE="' + l + '">');
		document.write('    <PARAM NAME="play" VALUE="' + p + '">');
		document.write(' 	<EMBED src="' + fl + '" quality="' + q + '" wmode="' + wm + '" loop="' + l + '" play="' + p + '"');
		document.write('        swLiveConnect="FALSE" WIDTH="' + w + '" HEIGHT="' + h + '" NAME="' + id + '"');
		document.write('        TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
	 	document.write('    </EMBED>');
		document.write(' </OBJECT>');
		if (post) document.write(post);
	} else {
		if (!a){
				document.write('<span class="noflashs1">here should a flash movie, but cannot displayed because <b>you have no</b> installed plugin or a <b>version lower than expected</b> or you have <b>disable</b> it. if you did not disabled it, klik <a href="http://www.macromedia.com/go/getflashplayer" target="_blank">here</a>. you need to reload this page after all process done</span>');
		} else document.write(a);
	}
}
