﻿/* Script para verificar o idioma corrente e se o site está sendo acessado de um celular.*/

window.onload = function Mobile(){
var url = location.href; //pega endereço que esta no navegador
url = url.split("/");
// Indentifica o User Agent do navegador cliente
var ua = navigator.userAgent.toLowerCase();
var uMobile = '';
// === REDIRECIONAMENTO PARA iPhone, Windows Phone, Android, NokiaE71, Pocket etc. ===
// Lista de substrings a procurar para ser identificado como mobile WAP
uMobile = '';
uMobile += 'iphone;ipod;windows ce;wince;ipaq;windows phone;android;iemobile 8;nokiae71;midp;240x320;blackberry;netfront;nokia;panasonic;portalmmm;sharp;sie-;sonyericsson;symbian;benq;mda;mot-;opera mini;philips;pocket pc;sagem;samsung;sda;sgh-;vodafone;xda;palm;iphone';
// Sapara os itens individualmente em um array
v_uMobile = uMobile.split(';');
//alert(window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'));
//alert (ua); 

//alert(window.location.href.slice(window.location.href.indexOf('?',0)+1));
// percorre todos os itens verificando se eh mobile
var boolMovel = false;
for (i=0;i<=v_uMobile.length;i++)
{
    if (ua.indexOf('gt-p1000l') != -1) 
	{
		boolMovel = false;
	}
	else if ((ua.indexOf(v_uMobile[i]) != -1) && window.location.href.slice(window.location.href.indexOf('?') + 1).split('&') != 'vip=1')
	{
		boolMovel = true;
	}
}
if (boolMovel == true)
	 {
	 switch (url[3]){
	 case('pt-br'):
	 document.getElementById("lnkYoutube").href = 'http://75.125.136.98/~vmundo/mobile/?lingua=en';
	 break;
	 case('en-us'):
	 document.getElementById("lnkYoutube").href = 'http://www.youtube.com/valeglobal';
	 break;
	 }	
	 }
	 
else{
	 switch (url[3]){
	 case('pt-br'):
	 document.getElementById("lnkYoutube").href = 'http://www.youtube.com/Vale';
	 break;
	 case('en-us'):
	 document.getElementById("lnkYoutube").href = 'http://www.youtube.com/valeglobal';
	 break;
	 }	
	 }
}

