/* Developed by EverMedia

JSMASTER

Version 2.0

*/



/*DETECTA PLUGIN DO FLASH ************************************************************/

/* START: GLOBAL VARS */

var flashDir = "/webapp/wcs/stores/EUKDLX/flash/";

/* Default Flash version supported,

Flash Write function can override this if passed a different version as the last argument*/

var flash_ver = 8;


function fDetect() {
	/* detect which version of Flash installed, either  */

	fPlug= (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if (fPlug) {
		fPlug = parseInt(fPlug.description.substring(fPlug.description.indexOf(".")-2));
	}
	
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && navigator.userAgent.indexOf("Windows")>=0 ) {
		
		document.writeln('<script language="vbscript" type="text/vbscript">');
		
		document.writeln('on error resume next');
		
		document.writeln('fPlug = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+flash_ver+'")))');
		
		document.writeln('</script>');
		
		if (fPlug>0) {fPlug=flash_ver;}
	}
		
	if (fPlug<flash_ver) {
		document.location.href = "/internas/detect_plugin.shtm"
	}

}
fDetect();





/* ESCREVE FLASH ***********************************************************/

/* escreve flash - header internas ***********************************************************/

function escreveFlash(a,b){
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flash_ver + '" width="100%" height="98" id="header" style="float:left">');

	document.writeln('	<param name="movie" value="/images/master/header.swf?varMenu=' + a + '&varSub=' + b + ' " />');

	document.writeln('	<param name="quality" value="high" />');

	document.writeln('	<param name="bgcolor" value="#FFFFFF" />');
	
	document.writeln('	<param name="wmode" value="transparent" />');

	document.writeln('	<embed src="/images/master/header.swf?varMenu=' + a + '&varSub=' + b + '" quality="high" bgcolor="#FFFFFF" width="100%" height="98" name="header" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />');

	document.writeln('</object>');
	}



/* escreve flash - header hammerite ***********************************************************/

function escreveFlashhammerite(a,b){
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flash_ver + '" width="100%" height="98" id="header" >');

	document.writeln('	<param name="movie" value="/images/master/header_hamm.swf?varMenu=' + a + '&varSub=' + b + '" />');

	document.writeln('	<param name="quality" value="high" />');

	document.writeln('	<param name="bgcolor" value="#38A7DD" />');
	
	document.writeln('	<param name="wmode" value="transparent" />');

	document.writeln('	<embed src="/images/master/header_hamm.swf?varMenu=' + a + '&varSub=' + b + '" quality="high" bgcolor="#38A7DD"  width="100%" height="98" name="header" align="" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />');

	document.writeln('</object>');
	}



/* escreve flash - width, height ***********************************************************/

function flash_wh (url, width, height) {
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flash_ver + '" width="' + width + '" height="' + height + '" style="float:left">');
	
	document.writeln('<param name="movie" value="' + url + '"/>');
	
	document.writeln('<param name="quality" value="high" /> ');
	
	document.writeln('<param name="wmode" value="transparent" />');
	
	document.writeln('<embed src="' + url + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent" ></embed>');
	
	document.writeln('</object>');
	}



/* escreve flash - width, height, transparent ***********************************************************/

function flash_whwm (url, width, height, wmode) {
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flash_ver + '" width="' + width + '" height="' + height + '" style="float:left">');
	
	document.writeln('<param name="movie" value="' + url + '"/>');
	
	document.writeln('<param name="quality" value="high" /> ');
	
	document.writeln('<param name="WMODE" value="' + wmode + '"/>');
	
	document.writeln('<embed src="' + url + '"  width="' + width + '" height="' + height + '" wmode="' + wmode +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
	
	document.writeln('</object>');
	}


/* escreve flash - url ***********************************************************/

function flash_ (url) {
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flash_ver + '">');
	
	document.writeln('<param name="movie" value="' + url + '"/>');
	
	document.writeln('<param name="quality" value="high" /> ');
	
	document.writeln('<embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
	
	document.writeln('</object>');
	}



/* escreve Flash - página de produto dinâmica ***********************************************************/

function flash_prod_header (base_url, surface_pic, prod_pic_path, prod_desc) {
	var prod_desc = URLencodeUTF8(prod_desc);

	var flash_url = base_url + '?surfacePicture=' + surface_pic + '&thumbPicturePath=' + prod_pic_path + '&description=' + prod_desc;
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flash_ver + '" width="554" height="140">');
	
	document.writeln('<param name="movie" value="' + flash_url + '"/>');
	
	document.writeln('<param name="quality" value="high" /> ');
	
	document.writeln('<embed src="' + flash_url + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="554" height="140"></embed>');
	
	document.writeln('</object>');
	}	





/* Check BROWSER - páginas dinâmicas ***********************************************************/

function checkBrowser()
	{

/* Detect IE5.5+ */

	version=0
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE");
		version=parseFloat(temp[1]);
	}

	if (version>=6.0) //NON IE browser will return 0
		('');

	}

/* --- */

function URLEncode(to_encode)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = to_encode;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '"
                        + ch
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
}

function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}


function toHex(n) {

var hexchars = "0123456789ABCDEF";

  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

function URLencodeUTF8(s) {

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~*'()";

  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}





/* ESCREVE CSS COM A COR - alteração de cores do site ***********************************************************/

	varQual = getCookie('cor');
	if (varQual != null) {
	document.writeln('<link type="text/css" rel="stylesheet" href="/css/color' + varQual+ '.css" />');
	}
	else{
	document.writeln('<link type="text/css" rel="stylesheet" href="/css/color1.css" />');
	}


/* define cookie */

function setCookie(name,value)
	{
	var o_cookie = value + ";";
	document.cookie = "cor="+o_cookie;
	}


/* recupera cookie */

function getCookie(name)
	{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else{
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
	}





/* POPUP - Idea Cards ***********************************************************/

	function abrir(pagina,largura,altura) {


w = screen.width;
h = screen.height;


meio_w = w/2;
meio_h = h/2;


altura2 = altura/2;
largura2 = largura/2;
meio1 = meio_h-altura2;
meio2 = meio_w-largura2;


window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+'');
}





/* função de abrir popup  ***********************************************************/

	function openPopUpGeral (url, name, scrollbar, width, height) {
		pop = window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copy,history=no,top=0,left=0,scrollbars=' + scrollbar + ',width=' + width + ',height=' + height);
	}
