/**
 *  Initalisieren
 */
var gallery_open = 0;
var session_name = '';
var session_id = '';
var webroot = '';
var wcip = ''

function init(_session_name,_session_id,_webroot,_wcip)
{
    // Bilder der Menüpunkte vorladen
    document.init = new Array('btn_register_low.jpg','btn_register_high.jpg',
                              'btn_gallery_low.png','btn_gallery_high.png',
                              'btn_updates_low.png','btn_updates_high.png',
                              'btn_tour_low.png','btn_tour_high.png',
                              'btn_guestbook_low.png','btn_guestbook_high.png',
                              'btn_contact_low.png','btn_contact_high.png',
                              'btn_login_low.png','btn_login_high.png',
		      				  'btn_casting_low.png','btn_casting_high.png',
                              'btn_video_low.png','btn_video_high.png',
							  'btn_lnk_fav.jpg','btn_lnk_sets.jpg',
							  'btn_lnk_mod');
    if (document.images)
    {
        for(var i = 0; i < init.arguments.length; i++)
        {
            document.init[i] = new Image();
            document.init[i].src = init.arguments[i];
        }
    }

    session_name = _session_name;
    session_id = _session_id;
    webroot = _webroot;
    wcip = _wcip;
    if (wcip) {
        wcipf();
    }
/*
    $('html').keypress(function (e) {
		document.title = String.fromCharCode(e.which);
    });
*/

}

function showAdminUserInfo(id) {
    if ($('#info'+id).css('display') != 'block') {
        $('#info'+id).css('display','block');
    } else {
        $('#info'+id).css('display','none');
    }
}

function getWindowSize() {
	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;
	}
	return [ myWidth, myHeight ];
}


function changemenupic(flag,id)
{
    if (flag)
        document.getElementById('btn_'+id).src = 'gfx/btn_'+id+'_high.jpg';
    else
        document.getElementById('btn_'+id).src = 'gfx/btn_'+id+'_low.jpg';
}

function opengallery()
{
    document.getElementById('gallery').style.display = 'block';
    if (gallery_open == 0)
    {
        document.getElementById('gallery_iframe').src = 'http://www.purenudes.de/lookPortal/flash/index.php';
        gallery_open = 1;
    }
}

function closegallery()
{
    document.getElementById('gallery').style.display = 'none';
}

function delay(prmSec)
{
	prmSec *= 1000;
	var eDate = null;
	var eMsec = 0;
	var sDate = new Date();
	var sMsec = sDate.getTime();

	do {
	  eDate = new Date();
	  eMsec = eDate.getTime();

	} while ((eMsec-sMsec)<prmSec);
}


function zoomOpenPicture(pictureId,width,height) {

	var strPicLink = webroot+'includes/zoom.inc.php?'+session_name+'='+session_id+'&pictureId='+pictureId;
	var strFakeLink = webroot+'gfx/transparent.gif';
	$('#zoomPicture').attr('src',strFakeLink);
	$('#zoomPicture').width(width);
	$('#zoomPicture').height(height);
	$('#zoomPictureDiv').css("background-image","url('"+strPicLink+"')");
	$('#zoomPictureDiv').css("background-repeat","no-repeat");
	$('#zoomPictureDiv').css("background-position","50% 50%");

	$('#area').fadeOut("normal");
	$('#zoomPictureBackground').fadeIn("normal");
}

function zoomClosePicture(pictureId) {
	$('#area').fadeIn("normal");
	$('#zoomPictureBackground').fadeOut("normal");
}

function zoomOpenInWindow(pictureId,width,height,size) {
	var winObj;
	var strWindowLink = webroot+'includes/zoomWindow.inc.php?'+session_name+'='+session_id+'&pictureId='+pictureId+'&showSize='+size;
	strWindowLink = strWindowLink.replace(/includes\/includes/,'includes/');
	winObj = window.open(strWindowLink,'','left=0,top=0,width='+screen.availWidth+',height='+screen.availHeight+',toolbar=0,directories=0,menubar=0,status=0,resizable=0,scrollbars=1');
    /*
	var posLeft = (screen.availWidth / 2) - (width / 2);
    var posTop  = 20; //(screen.availHeight / 2)- (height / 2);
    width = width + 30;
    if (size == 'original') {
		winObj = window.open(strWindowLink,'','left='+posLeft+',top='+posTop+',width='+width+',height='+height+',toolbar=0,directories=0,menubar=0,status=0,resizable=0,scrollbars=1');
    } else {
		winObj = window.open(strWindowLink,'','left='+posLeft+',top='+posTop+',width='+width+',height='+height+',toolbar=0,directories=0,menubar=0,status=0,resizable=0,scrollbars=0');
	}
	*/
	winObj.focus();
}

function clickCancel() {
	if (document.getElementById('player')) {
		$f('player').getClip().update({autoBuffering:false});
		$f('player').stop();
	}
}

function openVideo(strLink) {
    win = window.open(strLink,"Video","width=650,height=380,status=no,scrollbars=no,resizable=no");
    win.focus();
    return false;
}

/**
 *  Setzt/Löscht einen Cookie
 */
function setCookie(name,value,time) {
    var expDays = time;
    var exp = new Date();
    exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
    document.cookie = name + "=" + value + "; expires=" + exp.toGMTString();
}

function removeCookie(name) {
    document.cookie = name + '=delete; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}


function wcipf() {
    if ($('#cArea').length > 0) {
        strText = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="480" height="385">'
        strText+= '<param name="movie" value="http://'+wcip+':86/nchplayer.swf?host='+wcip+':1935&scope=BroadCam&streamName=live&bandwidth=1&src=1&autostart=true">'; 
        strText+= '<param name="allowfullscreen" value="true">'; 
        strText+= '<param name="quality" value="high">'; 
        strText+= '<embed src="http://'+wcip+':86/nchplayer.swf?host='+wcip+':1935&scope=BroadCam&streamName=live&bandwidth=1&src=1&autostart=true" width="480" height="385" allowfullscreen="true" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"/></object>';
        $('#cArea').html(strText); 
    }  
} 

