﻿//******Cookies********

function GetCookie( name ) 
{
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
{
	return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function SetCookie( name, value ) 
{
document.cookie = name + "=" +escape( value ) + ";path=/;domain=.ca.com";
}

//*******Popup*********
function openPopup(popURL, popHeight, popWidth)
{
var popLeft = (screen.width / 2) - (popWidth / 2);
var popTop = (screen.height / 2) - (popHeight / 2);
var popSettings = 'height=' + popHeight + ',width=' + popWidth + ',top=' + popTop + ',left=' + popLeft + ',titlebar=no,toolbar=no,resizable=no,scrollbars=no,menubar=no,resize=no';
window.open(popURL, 'popWin', popSettings)
}

//******MyDocs*******

function OnModifyCart(a) 
{          
    WebService.MyDocumentWebService.ModifyCart(a, document.getElementById('hGUID').value, OnCompleteModifying);             
}

function HasItems(result) 
{   
    document.getElementById('cartitems').innerHTML = result;                
	SetCookie("MyDocCount", result);
}  
    
function OnMaximumComplete(result)
{
    if(result == 10)
    {
        var message = "";
        message = strRMmyDocumentsMaximum;    
        alert(message);
    } 
} 

function OnCompleteModifying(result) 
{   
   WebService.MyDocumentWebService.MaximumLimit(document.getElementById('hGUID').value, OnMaximumComplete);       
   WebService.MyDocumentWebService.HasCartItems(document.getElementById('hGUID').value, HasItems);
}
   
    
    
    
    

