﻿
function popupWindow( url ) {
	alert( url );
}

function checkBrowser() { var value = navigator.userAgent; return value; }

// Browsers detection ////////////////////////

var is_ie = ((navigator.appVersion.match(/\bMSIE\b/))?true:false);
var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
var is_ie6 =(rslt != null && (Number(rslt[1]) < 7));
var is_ie7 =(rslt != null && (Number(rslt[1]) >= 7));
var is_safari = ((navigator.appVersion.match(/\bSafari\b/))?true:false);
var is_firefox = ((navigator.userAgent.toLowerCase().match(/\bfirefox\b/))?true:false);

// Mobile device detection ///////////////////

is_mobile = false;

var mobile_keywords = new Array("iPod", "iPhone", "Windows CE", "PalmOS", "Symbian OS", "PSP", "IEMobile", "Opera Mini", "MIDP", "embedix", "EPOC", "PalmSource", "Android");

for(var i=0;i<mobile_keywords.length;i++) {
	if(navigator.userAgent.toLowerCase().indexOf(mobile_keywords[i].toLowerCase())>=0) is_mobile = true;	
}
//////////////////////////////////////////////

function isIn(string, array){
	for(var i=0;i<array.length;i++){
		if(	array[i] == string) return true;
	}
	return false;
}

function openURL($url, $width, $height){
	window.open($url, "popup", 'toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no, width=' + $width + ', height=' + $height );
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) return window[movieName];
    else return document[movieName];
}

function getViewportSize() {
	var size = [0, 0];
	if (typeof window.innerWidth != "undefined") {
		size = [window.innerWidth, window.innerHeight];
	}
	else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
		size = [document.documentElement.clientWidth, document.documentElement.clientHeight];
	}
	else {
		size = [document.getElementsByTagName("body")[0].clientWidth, document.getElementsByTagName("body")[0].clientHeight];
	}
	return size;
}

function setCookie(name, value, expires) {
    // expires unit : day
    if (expires != null) {
        var date = new Date();
        date.setTime(date.getTime() + (expires * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toGMTString();
    } else expires = "";
    document.cookie = name + "=" + escape(value) + expires;
}

function getCookie(name) {
    var cookies = document.cookie.split(';');
    for (var cookieIterator = 0; cookieIterator < cookies.length; cookieIterator++) {
        var cookieElement = cookies[cookieIterator].split('=');
        if (trim(cookieElement[0]) == name) return unescape(cookieElement[1]);
    }
    return null;
}


function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    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 eraseCookie(name) {
    setCookie(name, "", -1);
}

function areCookiesEnabled() {
    var r = false;
    setCookie("testing", "Hello", 1);
    if (readCookie("testing") != null) {
        r = true;
        eraseCookie("testing");
    }
    return r;
}

function isItNokia() {
    if (/(Series60|Nokia|SymbianOS)/i.test(navigator.userAgent)) {
        return true;
    } else {
        return false;
    }
}


var deviceS60 = "series60";
var deviceSymbian = "symbian";
var engineWebKit = "webkit";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// Detects if the current browser is the S60 Open Source Browser.
// Screen out older devices and the old WML browser.
function DetectS60OssBrowser() {
    if (uagent.search(engineWebKit) > -1) {
        if ((uagent.search(deviceS60) > -1 || uagent.search(deviceSymbian) > -1))
            return true;
        else
            return false;
    }
    else
        return false;
}

