﻿
var pr_Url = "http://p2p.volcom.com/";

<!--
/* OS / Browser Detect. Written by Joe McCormack. www.virtualsecrets.com */
function wbrowsertype() {
/*
__ m_net_browser flag values based on OS/Browser __
0 = Undetermined OS / Browser
17 = Undetermined OS / Browser
MAC OS:
2 = Unknown Browser
3 = Internet Explorer
4 = Safari
5 = Firefox
6 = Netscape
7 = Opera
8 = Camino
9 = Firebird
26 = Google Chrome
WINDOWS OS:
10 = Unknown Browser
11 = Internet Explorer
12 = Firefox
13 = Netscape
14 = Opera
15 = Camino
16 = Firebird
25 = Google Chrome
28 = Safari
UNKNOWN OS:
17 = Unknown Browser
18 = Safari
19 = Internet Explorer
20 = Firefox
21 = Netscape
22 = Opera
23 = Camino
24 = Firebird
27 = Google Chrome
*/
var m_net_browser = 0;
var btfound = 0; browser_detect = navigator.userAgent.toLowerCase();
if ((browser_detect.indexOf("konqueror") + 1)) { btfound = 1; m_net_browser = 1; }
if ((browser_detect.indexOf("mac_powerpc") + 1)) { btfound = 1; m_net_browser = 3; }
if (btfound == 0) {
// MAC OS
if ((browser_detect.indexOf("macintosh") + 1)) {
if ((browser_detect.indexOf("safari") + 1)) { btfound = 1; m_net_browser = 4; }
else if ((browser_detect.indexOf("firefox") + 1)) { btfound = 1; m_net_browser = 5; }
else if ((browser_detect.indexOf("netscape") + 1)) { btfound = 1; m_net_browser = 6; }
else if ((browser_detect.indexOf("opera") + 1)) { btfound = 1; m_net_browser = 7; }
else if ((browser_detect.indexOf("camino") + 1)) { btfound = 1; m_net_browser = 8; }
else if ((browser_detect.indexOf("firebird") + 1)) { btfound = 1; m_net_browser = 9; }
else if ((browser_detect.indexOf("chrome") + 1)) { btfound = 1; m_net_browser = 26; }
else { btfound = 1; m_net_browser = 2; }
}
// Windows OS
if ((browser_detect.indexOf("windows") + 1) && btfound == 0) {
if ((browser_detect.indexOf("msie") + 1)) { btfound = 1; m_net_browser = 11; }
else if ((browser_detect.indexOf("firefox") + 1)) { btfound = 1; m_net_browser = 12; }
else if ((browser_detect.indexOf("netscape") + 1)) { btfound = 1; m_net_browser = 13; }
else if ((browser_detect.indexOf("opera") + 1)) { btfound = 1; m_net_browser = 14; }
else if ((browser_detect.indexOf("camino") + 1)) { btfound = 1; m_net_browser = 15; }
else if ((browser_detect.indexOf("firebird") + 1)) { btfound = 1; m_net_browser = 16; }
else if ((browser_detect.indexOf("chrome") + 1)) { btfound = 1; m_net_browser = 25; }
else if ((browser_detect.indexOf("safari") + 1)) { btfound = 1; m_net_browser = 28; }
else { btfound = 1; m_net_browser = 10; }
}
// Unknown OS
if (btfound == 0) {
if ((browser_detect.indexOf("safari") + 1)) { m_net_browser = 18; }
else if ((browser_detect.indexOf("msie") + 1)) { m_net_browser = 19; }
else if ((browser_detect.indexOf("firefox") + 1)) { m_net_browser = 20; }
else if ((browser_detect.indexOf("netscape") + 1)) { m_net_browser = 21; }
else if ((browser_detect.indexOf("opera") + 1)) { m_net_browser = 22; }
else if ((browser_detect.indexOf("camino") + 1)) { m_net_browser = 23; }
else if ((browser_detect.indexOf("firebird") + 1)) { m_net_browser = 24; }
else if ((browser_detect.indexOf("chrome") + 1)) { m_net_browser = 27; }
else { m_net_browser = 17; }
}
}
/* In most cases, Google Chrome will behave the same as Firefox. If not you can remove these value overwrites. */
//if (m_net_browser == 25) { m_net_browser = 12; }
//else if (m_net_browser == 26) { m_net_browser = 5; }
//else if (m_net_browser == 27) { m_net_browser = 20; }

return m_net_browser;
}
//-->


/******************************************************************
 * Copyright(c)  Suzsoft DotNet Group
 * Description   : 
 * CreateDate    : 2007-07-09
 * Creater       : Waver Shi
 * LastChangeDate: 
 * LastChanger   : Waver Shi
 * Version Info  : 1.0
 * ******************************************************************/
/******************************************************************
    Class Name: pr_PopupWindow.
    
    Usage Example:
      pr_popupWindow.BaseURL = pr_Url; 
      pr_popupWindow.TitleBackgroundImage = "Images/bg.jpg'";
      pr_popupWindow.ButtonCloseImageOut = "Images/Close.bmp";
      pr_popupWindow.ButtonCloseImageOver = "Images/Close1.bmp";    
      pr_popupWindow.TitleHeight = 54;
       
      pr_popupWindow.Create("Volcom", 750, 500);    
      pr_popupWindow.SetInnerHTML("")
      pr_popupWindow.AddInnerHTML("")
* ******************************************************************/

// Single instance.
var pr_popupWindow = new pr_PopupWindow();

function pr_PopupWindow()
{
        // Assure whole system only one instance of pr_PopupWindow exist.
        if (pr_popupWindow != null) return pr_popupWindow;

        // Properties.
        this.name = "";
        this.width = 450;
        this.height = 400;
        this.BaseURL = "";
        
       this.TitleBackgroundImage = this.BaseURL + "Images/bg.jpg'";
       this.ButtonCloseImageOut = this.BaseURL + "Images/Close.bmp";
       this.ButtonCloseImageOver = this.BaseURL + "Images/Close1.bmp";
        
        this.TitleHeight = 24;
        this.CloseImageWidth = 35;
        
        // Public methods.
        this.AddInnerHTML =  function(str)
        {
            var oContent = document.getElementById("w_divContent");
           if (oContent !=  null)
           {
                oContent.innerHTML += str;
           } 
        }
        
        this.SetInnerHTML =  function(str)
        {
            var oContent = document.getElementById("w_divContent");
           if (oContent !=  null)
           {
                oContent.innerHTML = str;
           } 
        }
        
        this.Destroy = function()
        {
            this.RemoveMask();
            var obj = document.getElementById("w_divWindow"); 
           
            if (obj != null)
           {
                document.body.removeChild(obj);
           }   
        }
        
        this.Mask = function()
        {            
            var sWidth,sHeight;
           
//           var browsername=navigator.appName;
//           var browseragent=navigator.userAgent;
//           var firefoxindex = browseragent.indexOf('Firefox');
//           if(browsername != 'Netscape' || firefoxindex <= 0)
//           {
//                document.body.style.overflow = "hidden"; 
//                document.documentElement.style.overflow = "hidden";
//           }

            sWidth = document.body.clientWidth;
            sHeight = document.body.clientHeight;
           // sWidth = screen.availWidth;
           // sHeight = screen.availHeight;

            var bgObj=document.createElement("div");
            bgObj.setAttribute('id','w_divMask');
            bgObj.style.position="absolute";
            bgObj.style.top="0";
            bgObj.style.background="#777";
           if (document.all)
           {
                bgObj.style.filter="alpha(opacity=25)";
           } 
           else 
           {
                bgObj.style.MozOpacity=0.25;
           }
            bgObj.style.opacity="0.6";
            bgObj.style.left="0";
            bgObj.style.width=sWidth + 'px';
            bgObj.style.height=sHeight + 'px';
            bgObj.style.zIndex = "899";
            document.body.appendChild(bgObj);
         }

        this.RemoveMask = function()
        {  			            
           var browsername=navigator.appName;
           var browseragent=navigator.userAgent;
           var firefoxindex = browseragent.indexOf('Firefox');
           if(browsername != 'Netscape' || firefoxindex <= 0)
           {
                document.body.style.overflow = "auto";
                document.documentElement.style.overflow = "auto";
           }
	            var objMask = document.getElementById("w_divMask");
	            if (objMask != null)
	            {
                        document.body.removeChild(objMask);        
                }
        }               
        
        this.pr_disableSelection = function(target)
        {
            if  (typeof target.onselectstart != "undefined") //IE 
	            target.onselectstart = function(){return false}
            else if (typeof target.style.MozUserSelect != "undefined") //Firefox 
	            target.style.MozUserSelect = "none"
            else //Others (ie: Opera)
	            target.onmousedown = function(){return false}
       }
        
        // Create
       this.Create = function(name, width, height) {
           this.name = name;
           this.width = width;
           this.height = height;

           this.Mask();

           var oDiv = document.getElementById("w_divWindow");

           if (oDiv == null) {
               var width = document.body.clientWidth;
               if (document.documentElement.clientWidth > 0 && width > document.documentElement.clientWidth) {
                   width = document.documentElement.clientWidth;
               }
               var left = (width - this.width) / 2;
               //var left = (document.body.clientWidth - this.width)/2;
               
               var scrollTop = document.body.scrollTop;
               if (wbrowsertype() == 3 || wbrowsertype() ==5 || wbrowsertype() == 11 || wbrowsertype() ==12 || wbrowsertype() == 19 || wbrowsertype() ==20)
               {
                    scrollTop = document.documentElement.scrollTop;
               }
               //var top = 60 + scrollTop;
		//var top = (document.body.clientHeight - this.height)/2;
		var top = ((document.documentElement.clientHeight > document.body.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight) - this.height)/2;


               oDiv = document.createElement("DIV");
               oDiv.id = "w_divWindow";
               oDiv.style.position = "absolute";
               oDiv.style.left = left + "px";
               oDiv.style.top = top + "px";
               oDiv.style.width = this.width + "px";
               oDiv.style.height = this.height + "px";
               oDiv.style.visibility = 'visible';
               oDiv.style.backgroundColor = '#fafafa';
               oDiv.style.border = "solid #868686 1px";
               oDiv.style.zIndex = '900';
               oDiv.style.paddingTop = '10px';
               oDiv.style.paddingLeft = '10px'; //'20px';
               oDiv.style.paddingRight = '10px';
               oDiv.style.paddingBottom = '20px';

               document.body.appendChild(oDiv);

               // Add the Dragbar.
               //oDiv.innerHTML += "<div class='innerTopDiv'><table width='100%' cellpadding='0' cellspacing='0' border='0' height='" + this.TitleHeight + "'><tr><td  id='w_divTitle' valign='top' style='FONT-SIZE: 9pt;COLOR: #000000;FONT-FAMILY: Verdana, Arial, Helvetica;FONT-WEIGHT:bold;' background='" + this.TitleBackgroundImage + "' onselectstart='return false;'>"+this.name+"</td><td width='"+this.CloseImageWidth+"' style='padding-right:0px;' background='" + this.TitleBackgroundImage + "' align='right' valign='top'><img border='0' onmouseover='this.src=\""+this.ButtonCloseImageOver+"\"' onmouseout='this.src=\""+this.ButtonCloseImageOut+"\"'  onclick='if (pr_popupWindow != null)pr_popupWindow.Destroy();' src='" + this.ButtonCloseImageOut + "' /></td></tr></table></div>"  
               oDiv.innerHTML += "<div class='innerTopDiv'><table width='100%' cellpadding='0' cellspacing='0' border='0' height='" + this.TitleHeight + "'><tr><td id='w_divTitle' width='100%' style='padding-right:0px;' background='" + this.TitleBackgroundImage + "' align='right' valign='top'><img border='0' onmouseover='this.src=\"" + this.ButtonCloseImageOver + "\"' onmouseout='this.src=\"" + this.ButtonCloseImageOut + "\"'  onclick='if (pr_popupWindow != null)pr_popupWindow.Destroy();' src='" + this.ButtonCloseImageOut + "' /></td></tr></table></div>"

               oDiv.innerHTML += "<div id='w_divContent' style='width:100%;height: " + (this.height - this.TitleHeight) + "px; overflow: hidden;' class='innerBottomDiv'></div>";
           }

           //this.pr_disableSelection(document.body); 
       }
}

/******************************************************************
 * Copyright(c)  Suzsoft DotNet Group
 * Description   : 
 * CreateDate    : 2007-07-09
 * Creater       : Waver Shi
 * LastChangeDate: 
 * LastChanger   : Waver Shi
 * Version Info  : 1.0
 * ******************************************************************/
/******************************************************************
     Useage Note: 
     
     Step 1: include this file in your page.
     Step 2: invoke RegisterMovingListener() to add the mouse movement caputer listener.   
* ******************************************************************/

// PopupWindowMovableDecorator.js
// Drag.
// Declare the global variables
var pr_down = false; 
var pr_thelayer = null;
var pr_startX = 0; pr_startY = 0; pr_startLeft = 0; pr_startTop = 0; 
var pr_ListenerRegistered = false;

function pr_UpMouse()
{ 
    if (pr_down == true)
    {
        pr_down = false; 
        
         var divMove = document.getElementById("w_divMove");         
         // Move the layer.
        if (pr_thelayer != null)
        {
           pr_thelayer.style.left = parseInt(divMove.style.left) + "px";
           pr_thelayer.style.top = parseInt(divMove.style.top) + "px";            
        }
        
        if (divMove != null) document.body.removeChild(divMove);       
        
	    // Unmask the layer.
	    var objContent = document.getElementById("w_divContent");
	    if (objContent != null)
	    {
	        objContent.style.visibility = "visible";
         }     
	}
} 


function pr_MoveLayer(evt)
{ 
    if (pr_down)
    { 		
        // Support FireFox and IE.    
        evt = evt ? evt : (window.event ? window.event : null);
        if (document.all ? evt.button != 1 : evt.button != 0) pr_UpMouse();
            		
	   pr_MoveLayerCore(evt.clientX,  evt.clientY);
    }
} 

function pr_MoveLayerCore(x, y)
{
    if (pr_thelayer != null)
    {
        var divMove = document.getElementById("w_divMove"); 
        
         // Move the layer.
        if (divMove != null)
        { 
            if (pr_startLeft - pr_startX + x > 0) divMove.style.left = pr_startLeft - pr_startX + x + "px";
            if (pr_startTop - pr_startY + y > 0) divMove.style.top = pr_startTop - pr_startY + y + "px"; 
        }
    } 
}

function pr_HandleChildMove(evt)
{	    
    if (pr_down)
    { 	
            evt = evt ? evt : (window.event ? window.event : null);
          
          if (document.all ? evt.button != 1 : evt.button != 0) pr_UpMouse();
            
            var objFrame = document.getElementById("volcomFrame");
            if (objFrame != null)
            {
               var left = objFrame.offsetLeft + parseInt(pr_thelayer.style.left) + evt.clientX;
               var top = objFrame.offsetTop + parseInt(pr_thelayer.style.top) + evt.clientY;      
                
                pr_MoveLayerCore(left, top);                   
            }
       } 
}

function pr_DownMouse(evt){ 
    // Support FireFox and IE.    
    evt = evt ? evt : (window.event ? window.event : null);
    var srcElement = evt.target ? evt.target : event.srcElement;

    if (srcElement.id == "w_divTitle")
    {
	    //pr_thelayer = event.srcElement; 
	    pr_thelayer = document.getElementById("w_divWindow"); 
	    pr_down = true; 

	    // Set the start status of the layer.
	    pr_startX = evt.clientX; 
	    pr_startY = evt.clientY; 
	    pr_startLeft = parseInt(pr_thelayer.style.left); 
	    pr_startTop = parseInt(pr_thelayer.style.top); 
	    
	    // Create the moving layer.
	    var objWindow = document.getElementById("w_divWindow");
	    if (objWindow != null)
	    {
	        var divMoving = document.createElement("DIV"); 
	       divMoving.id = "w_divMove";  
           divMoving.style.position   =   "absolute";  
           if (document.all)
           {
                divMoving.style.filter="alpha(opacity=25)";
           } 
           else 
           {
                divMoving.style.MozOpacity=0.25;
           }
           divMoving.style.left = parseInt(objWindow.style.left) + "px";
           divMoving.style.top = parseInt(objWindow.style.top)+ "px";
           divMoving.style.width = parseInt(objWindow.style.width) + 6  + "px";
           divMoving.style.height = parseInt(objWindow.style.height) + 6  + "px";
           divMoving.style.visibility = 'visible'; 
           divMoving.style.backgroundColor = '#fafafa';
           divMoving.style.border = "1px solid #9999aa";
           divMoving.style.zIndex = '1001';
            
            document.body.appendChild(divMoving);          
	    }	    
	    
	    // Mask the layer.
	    var objContent = document.getElementById("w_divContent");
	    if (objContent != null)
	    {
	        objContent.style.visibility = "hidden";
         }           
    } 
} 

function RegisterMovingListener()
{   
    if (pr_ListenerRegistered) return;
    
       // attach the events.   
       if (document.all)
       {
            document.body.attachEvent("onmousedown", pr_DownMouse);
            document.body.attachEvent("onmousemove", pr_MoveLayer);
            document.body.attachEvent("onmouseup", pr_UpMouse);
       }
       else
       {
            document.body.addEventListener("mousedown", pr_DownMouse, false);
            document.body.addEventListener("mousemove", pr_MoveLayer, false);
            document.body.addEventListener("mouseup", pr_UpMouse, false);
       } 
     
        pr_ListenerRegistered = true;
}

function UnRegisterMovingListener()
{
        if (!pr_ListenerRegistered) return;
        
       // detach the events.   
       if (document.all)
       {
            document.body.detachEvent("onmousedown", pr_DownMouse);
            document.body.detachEvent("onmousemove", pr_MoveLayer);
            document.body.detachEvent("onmouseup", pr_UpMouse);
       }
       else
       {
            document.body.removeEventListener("mousedown", pr_DownMouse, false);
            document.body.removeEventListener("mousemove", pr_MoveLayer, false);
            document.body.removeEventListener("mouseup", pr_UpMouse, false);
       } 
     
        pr_ListenerRegistered = false;    
}

//window.onload = RegisterEventListener;
 
// Show popup window. 
function ShowPOPWithSize(url,style,popwidth,popheight)
{
    if (pr_popupWindow == null) alert("Script of 'pop-up window' loading failed.\n\n If the page loading finished, please reload again, or else please wait until page loading finished.");

    // Set the properties.
   pr_popupWindow.BaseURL = pr_Url; 
   pr_popupWindow.TitleHeight = 10;
   pr_popupWindow.TitleBackgroundImage = ""
   pr_popupWindow.ButtonCloseImageOut = pr_Url + "Images/Close.bmp";
   pr_popupWindow.ButtonCloseImageOver = pr_Url + "Images/Close1.bmp";
   pr_popupWindow.CloseImageWidth = 40
    
   // Create the popup window. 
   //pr_popupWindow.Create("<img src='"+pr_Url+"/Images/Podium.gif' border=0 align='center' />", 600, 450);  
   pr_popupWindow.Create("<img id='PopupImage' border=0 align='center' alt='Loading' />", popwidth, popheight);   
   pr_popupWindow.SetInnerHTML("<iframe name='volcomFrame' id='volcomFrame' frameborder=0 src='"+url+"/index.aspx?styleId="+style+"&baseurl=" + url + "&fromp2p=1' width='100%' height='100%' scrolling='no' />"); 
   
   // Add the movable function.
   RegisterMovingListener();
}
function  ShowPOP(url, style) {
   ShowPOPWithSize(url,style,600,450) 
}

function  ShowPOPDialog(url, style)
{
     window.showModalDialog(url+"/index.aspx?styleId="+style+"&baseurl="+url,"", "dialogHeight: 450px; dialogWidth: 600px;  edge: Raised; center: Yes; help: No; resizable: No; status: no;unadorned:yes;scroll:no;");
}

// Add scripts to current page.        
function pr_RegisterScript(url)
{       
    // Create a script.
    var script = document.createElement('script');
    
    script.language = 'javascript';
    script.type = 'text/javascript';
    script.src = url;
    
   // Add to the DOM. 
    document.getElementsByTagName('head')[0].appendChild(script);
}
