function print_r(obj) {
    var mess = "";
    if(typeof(obj)=='object') {
        for(var i in obj) {
            mess += i+" : "+obj[i]+"\n";
        }
    }
    alert(mess);
}

function myprintln(s){
    document.writeln(s);
}

function myprint(s) {
    document.write(s);
}

function detectOS(){
	if(navigator.userAgent.indexOf('Win') == -1) {
		OS = 'Macintosh';
	} else {
		OS = 'Windows';
	}
	return OS;
}

function detectBrowser(){
	if(navigator.appName.indexOf('Netscape') == -1) {
		browser = 'IE';
	} else {
		browser = 'Netscape';
	}
	return browser;
}

function checkIframe(redir, minW, minH) {
    var frameWidth  = 0;
    var frameHeight = 0;
    var frameCount  = parent.frames.length;

    if(frameCount && redir != '') {
        if (self.innerWidth)
        {
        	frameWidth = self.innerWidth;
        	frameHeight = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientWidth)
        {
        	frameWidth = document.documentElement.clientWidth;
        	frameHeight = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
        	frameWidth = document.body.clientWidth;
        	frameHeight = document.body.clientHeight;
        }

        if(frameWidth < minW || frameHeight < minH) {
            document.location.href = redir;
        }
    }
}


function checkApp(){
    var tab_app = {
            'ie8': 'MSIE 8.0',
            'ie7': 'MSIE 7.0',
            'ie6': 'MSIE 6.0',
            'ff': 'Firefox',
            'saf': 'Safari',
            'ope': 'Opera'
    };
    var agent = navigator.userAgent;
    nav = '';

    for( var p in tab_app ){

        var regex = new RegExp(tab_app[p]);
        var result = regex.test(agent);

        if(!result) continue;
        else{
            nav = p;
        }
    }

    if(nav.length == 0) nav = 'any';
    return nav;
}


function setSize(intWidth,intHeight){
	var app = checkApp();
    var w=0;
    var h=0;
	if(app && window.opener!=null) {
	    switch(app.toLowerCase()){
	        case "ff":
	        	w=window.innerWidth;
                h=window.innerHeight;
                deltaw = Math.abs(window.outerWidth - window.innerWidth);
                deltah = Math.abs(window.outerHeight - window.innerHeight);
                w += intWidth - w + deltaw;
        	    h += intHeight - h + deltah;
                self.resizeTo(w,h);
	        	break;
	        case "ope":
                w=window.innerWidth;
                h=window.innerHeight;
                deltaw = Math.abs(window.outerWidth - window.innerWidth);
                deltah = Math.abs(window.outerHeight - window.innerHeight);
                w += intWidth - w;
        	    h += intHeight - h + deltah;
                self.resizeTo(w,h);
	            break;
	        case "ie6":
	        case "ie7":
	        case "ie8":
                w=document.body.clientWidth;
                h=document.body.clientHeight;
                if(app=='ie6'){
                    deltaw = Math.abs( w - document.body.offsetLeft );
                    deltah = Math.abs( h - document.body.offsetTop );
            	    w = intWidth - w + deltaw;
            	    h = intHeight - h + deltah+35;
                    self.resizeTo(w,h);
                }
                else{
                    w = intWidth - w;
            	    h = intHeight - h;
                    self.resizeBy(w,h);
                }
	            break;
	        case "saf":
                w=window.innerWidth;
                h=window.innerHeight;

                deltaw = Math.abs(window.outerWidth - window.innerWidth);
                deltah = Math.abs(window.outerHeight - window.innerHeight);
                w += intWidth - w + deltaw;
        	    h += intHeight - h + deltah;
                self.resizeTo(w,h);
	            break;
	        default:
                w=window.innerWidth;
                h=window.innerHeight;

                deltaw = Math.abs(window.outerWidth - window.innerWidth);
                deltah = Math.abs(window.outerHeight - window.innerHeight);

                w += intWidth - w;
        	    h += intHeight - h + deltah;
                self.resizeTo(w,h);
	            break;
	    }
	}
}

/*
function setSize(intWidth,intHeight){
	var frameDetected = parent.frames.length;
	var NS = (navigator.appName=="Netscape")? true : false;
	var IE = !(document.getElementById);
	iWidth = (NS)?window.innerWidth:document.body.clientWidth;
	iHeight = (NS)?window.innerHeight:document.body.clientHeight;
	iWidth= intWidth - iWidth;
	iHeight = intHeight - iHeight;
	self.resizeBy(iWidth, iHeight);
	//self.resizeTo(intWidth, intHeight);
}
*/

function setTop(){
	self.moveTo(0,0);
}

function setCenter(){
	var NS = (navigator.appName=="Netscape")? true : false;
	iWidth = (NS)?window.innerWidth:document.body.clientWidth;
	iHeight = (NS)?window.innerHeight:document.body.clientHeight;
	windowX = (window.screen.width-iWidth)/2;
	windowY = (window.screen.height-iHeight)/2;
	if(window.moveTo) window.moveTo(windowX,windowY);
}
/*replace alt @*/
function InNewWindow(uri){	var r = window.open(uri);	return ((r)? false : true );}

function showElement(idImg, typeElement){
    if(document.getElementById(idImg) != null) {
        document.getElementById(idImg).style.display = typeElement;
    }
    return false;
}

function hideElement(idImg, delay){
    if(document.getElementById(idImg) != null) {
        if(delay > 0) {
            setTimeout("document.getElementById('"+idImg+"').style.display = 'none';", delay);
        }
        else{
            document.getElementById(idImg).style.display = 'none';
        }
    }
    return false;
}

function displayCenter(div, w, h){
    var posX = (gb_posX-w)/2;
    var posY = (gb_posY-h)/5*1;
    document.getElementById(div).style.left = posX+'px';
    document.getElementById(div).style.top  = posY+'px';
}


/**
 * STOCKCODE
 */

/**
 * Gets inner dimmentions
 * Finding the size of the browser window
 * http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
 */
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}

/**
 * Gets the scrolling offsets
 * Finding how far the window has been scrolled
 * http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
 */
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
