/**
* =========================================================== FLASH ASSETS CONTROL =====================================================
* THIS THREE METHODS ARE MANDATROY FOR ALL FLASH APPPLICATIONS TO RUN 
* getAssetPath()
* getDataPath()
* getVideoPath()
* ======================================================================================================================================
*/
var isAddLinksEnabled = true; //Set true or false to show or remove Add links
var isProdRegLinkEnabled = true; //Set true or false to show or remove ProdReg links
var supportCheck=window.location.toString();
	if(supportCheck.indexOf("/support/") > -1 && supportCheck.indexOf("/systemupdates/") <= -1 && supportCheck.indexOf("/support/termsofuse/") <= -1 && supportCheck.indexOf("/support/privacypolicy/") <= -1)
	{
 	var bIsAndroid = navigator.userAgent.toLowerCase().indexOf('android') != -1;
 	var bIsBB = navigator.userAgent.toLowerCase().indexOf('blackberry') != -1;
 	var bIsIP = navigator.userAgent.toLowerCase().indexOf('iphone') != -1;
	 var bIsPalm = navigator.userAgent.toLowerCase().indexOf('webos') != -1;
	 var bIsPS3 = navigator.userAgent.toLowerCase().indexOf('playstation 3') != -1;
	 

	if (bIsAndroid.toString()=="true" || bIsBB.toString()=="true" || bIsIP.toString()=="true" || bIsPalm.toString()=="true"  || bIsPS3.toString()=="true" )
	 {
	window.location.href="http://playstation.custhelp.com";
 	 }
	}

$(document).ready(function() {
	if(trimString(document.body.innerHTML)==""){
		window.location=window.location;
	}	
	
	if(isProdRegLinkEnabled.toString()=="true"){
	}else{
		var footerString="<li class=\"first\"><a style=\"border-top: 1px solid rgb(210, 210, 210);\" onclick=\"javascript:ClickOmniTrack(this,'event37','Knowledge_Center'); \" href=\"/support/index.htm\" target=\"_parent\">Knowledge Center/Support</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Warranty_Information');\" href=\"/support/warranties/index.htm\" target=\"_parent\">Warranty Information</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Product_Manuals');\" href=\"/support/manuals/index.htm\" target=\"_parent\">Product Manuals</a></li><li class=\"last\"><a onclick=\"javascript:ClickOmniTrack(this,'event37','Contacting_Support');\" href=\"/support/contact_options/index.htm\" target=\"_parent\">Contacting Support</a></li>";
		$(".FooterUpper .community:first ul").html(footerString);
	}
		
	//var footerString="<div class=\"community\"><h3>Support</h3><ul><li class=\"first\"><a style=\"border-top: 1px solid rgb(210, 210, 210);\" onclick=\"javascript:ClickOmniTrack(this,'event37','Knowledge_Center'); \" href=\"/support/index.htm\">Knowledge Center/Support</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Warranty_Information');\" href=\"/support/warranties/index.htm\">Warranty Information</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Product_Manuals');\" href=\"/support/manuals/index.htm\">Product Manuals</a></li><li class=\"last\"><a onclick=\"javascript:ClickOmniTrack(this,'event37','Contacting_Support');\" href=\"/support/contact_options/index.htm\">Contacting Support</a></li></ul></div>"
	//footerString = footerString+"<div class=\"community\"><h3>Corporate</h3><ul><li class=\"first\"><a style=\"border-top: 1px solid rgb(210, 210, 210);\" onclick=\"javascript:ClickOmniTrack(this,'event37','About_SCEA');\" href=\"/corporate/about/index.htm\">About SCEA</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Contact_Us');\" href=\"/corporate/contactus/index.htm\">Contact Us</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Careers');\" href=\"/corporate/about/careers/index.htm\">Careers</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Press_Releases');\" href=\"/corporate/about/press-release/index.htm\">Press Releases</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Consumer_Alert');\" href=\"/news/consumeralerts/index.htm\">Consumer Alerts</a></li></ul></div>";
   // footerString = footerString+"<div class=\"community\"><h3>Community</h3><ul><li><a onclick=\"javascript:ClickOmniTrack(this,'event21','Forums');pageTracker._trackPageview('/CTR/PSHome/Community/Forums');\" href=\"http://community.us.playstation.com/\" target=\"_parent\">Forums</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event3','PlayStation_Blog');pageTracker._trackPageview('/CTR/PSHome/Community/PlayStationBlog');\" href=\"http://blog.us.playstation.com/\" target=\"_parent\">PlayStation<sup>&reg;</sup> Blog</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','PlayStation_Home');\" href=\"/psn/playstation-home/index.htm\">PlayStation<sup>&reg;</sup> Home</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','RSS_Feeds');pageTracker._trackPageview('/CTR/PSHome/Community/RSSFeeds');\" href=\"/news/rss/index.htm\">RSS Feeds</a></li><li><a onclick=\"javascript:ClickOmniTrack(this,'event37','Events');\" href=\"/psn/events/index.htm\">Events</a></li></ul></div>";
   // footerString = footerString+"<div class=\"network paddingTopimage\"><a onclick=\"javascript:pageTracker._trackPageview('/CTR/PSHome/PS3_SystemUpdate');\" href=\"/support/systemupdates/ps3/index.htm\"><img border=\"0\" title=\"PlayStation?3 System Software Update\" alt=\"PlayStation?3 System Software Update\" src=\"http://webassetsi.scea.com/pscomauth/groups/public/documents/webasset/ps3_update_img.jpg\"></a><a onclick=\"javascript:pageTracker._trackPageview('/CTR/PSHome/PSP_SystemUpdate');\" href=\"/support/systemupdates/psp/index.htm\" target=\"_parent\"> <img border=\"0\" src=\"http://webassetsj.scea.com/pscomauth/groups/public/documents/webasset/psp_update_img.jpg\" title=\"PSP? System Software Update\" alt=\"PSP? System Software Update\"></a></div>";
	//$(".FooterUpper").html(footerString);
	
});

/* For mobile redirection to mobi.us.playstation.com  */
/*
var deviceBB = "blackberry";
var deviceAndroid = "android";
var devicepsp = "psp";
var devicepspo = "PLAYSTATION PORTABLE";
var uagent = navigator.userAgent.toLowerCase();
if (navigator.userAgent && ( navigator.userAgent.indexOf("iPad") > -1 || navigator.userAgent.indexOf("iPhone") > -1 )) {

}else if ((uagent.search(devicepsp) > -1) || (uagent.search(devicepspo) > -1)){
	window.location="http://mobi.us.playstation.com";
}else if ((uagent.search(deviceBB) > -1) || screen.width <= 600) {
	window.location="http://mobi.us.playstation.com";
}
*/
/* END For mobile redirection to mobi.us.playstation.com  */ 

	
	
//var ucmroot = "/ucm/";
//Mobi Code Starts
/*
if(navigator.userAgent.toLowerCase().indexOf('psp') != -1) {
	window.location="http://mobi.us.playstation.com/mobi/UserAgentDetectionServlet"; 
}
var serverName=window.location.host;	
var servletURL="http://"+serverName+"/uwps/UserAgentDetectionServlet"; 
var status=false;
$.ajax({
type: "POST",
url: servletURL,   
async:   true,
success: function(result){
if(result != '' && result != null)
window.location=result;
}
});  */
//Mobi Code Ends

var baseURL ="";
if(window.location.protocol=="https")
{
baseURL=window.location.protocol+"//"+window.location.host;
}
else
{
baseURL=window.location.protocol+"//"+"webassets.scea.com";
}

var enableRBH = false; 
var hostName = window.location.host;
var flashBaseURL = ""
var gameSKUId ="";
var floodLightShow="FloodLight1";
//var ucmroot = "/pscomauth/";
if(window.location.protocol.indexOf('https')!=-1 )
	flashBaseURL=window.location.protocol+"//"+window.location.host+ucmroot+"groups/public/documents/";
else if((hostName.indexOf("stagea.us.playstation.com")!=-1) || (hostName.indexOf("stage.us.playstation.com")!=-1))
	flashBaseURL= "http://stage-webassets.scea.com"+ucmroot+"groups/public/documents/";
else if((hostName.indexOf("us.playstation.com")!=-1) || (hostName.indexOf("qa.playstation.com")!=-1))
	flashBaseURL= "http://webassets.scea.com"+ucmroot+"groups/public/documents/";
else
	flashBaseURL=ucmroot+"groups/public/documents/";


 
function getAssetPath(){	return flashBaseURL+"webasset/";}
function getDataPath() {	return flashBaseURL +"webcontent/";}
function getHttpVideoPath(){return flashBaseURL +"video/"; }
function getVideoPath(){  
	//return flashBaseURL +"video/";
	return "rtmp://sceafs.fplive.net/scea/pscomauth/groups/public/documents/video/"
}

function getUcmInstanceName(){
    var ucmName = ucmroot;
    return ucmName;
}
function getAssesBase(){
    var insName = getUcmInstanceName();
    var baseUrl = window.location.protocol+"//"+window.location.host+insName;
    return baseUrl; 
}
function getPageURL(){return window.location.toString();}
function getBaseURL(){
    var siteName="/usplaystation";
    var urlString = "";
    urlString = window.location.toString();
    if(urlString.indexOf(siteName)==-1){
        siteName="";
    }
    return window.location.protocol+"//"+window.location.host+siteName;
}

function getHostURL(){
    return window.location.protocol+"//"+window.location.host+"/";
} 



function getOmnitureAccount(){
 /*var browserUrl = document.URL;	 
	 var omnitureValue=""
	 if(browserUrl.indexOf("us.playstation.com")!=-1)
	 omnitureValue="sceaplaystationprod";
	 else	
	 omnitureValue="sceaplaystationdev";*/	 
return s_account;
}

function hideMarqueeControls(){ getMovieName("marquee").hideControls(); }
function showMarqueeControls(){ getMovieName("marquee").showControls(); }
function notifyPageChange(){/*TODO*/};

/**
* =========================================================== MAIN NAVIGATION ==========================================================
* THIS REQUIRES ALL THE FOLLOWING FUNCTIONS AND JS FILES TO BE AVAILABLE BEFORE THE FOLLOWING SCRIPT EXECUTES.
* getAssetPath()
* getDataPath()
* ======================================================================================================================================
*/
var ucmWebRoot=ucmroot;
var expandedSection = ""; 
var subSection="";
var loc=window.location.toString();
        
if(loc.indexOf("systems/") > -1)                    subSection = "systems";
else if(loc.indexOf("techspecs") > -1)              subSection = "systems";
else if(loc.indexOf("/att/faq") > -1)               subSection = "";
else if(loc.indexOf("faq/") > -1)                    subSection = "systems";
else if(loc.indexOf("accessories/sony-playstation-3d-display-ps3/faq.html") > -1)            subSection = "accessories";
else if(loc.indexOf("accessories") > -1)            subSection = "accessories";
else if(loc.indexOf("features") > -1)               subSection = "features";
else if(loc.indexOf("/livechat/wipeout") > -1)      subSection = "gamesmedia";
else if(loc.indexOf("/livechat/soundshapes") > -1)      subSection = "gamesmedia";
else if(loc.indexOf("/livechat/gravityrush") > -1)      subSection = "gamesmedia";
else if(loc.indexOf("/livechat/hotshots") > -1)      subSection = "gamesmedia";
else if(loc.indexOf("/livechat/escapeplan") > -1)      subSection = "gamesmedia";
else if(loc.indexOf("/livechat/realityfighters") > -1)      subSection = "gamesmedia";
else if(loc.indexOf("/livechat/modnation-vita") > -1)      subSection = "gamesmedia";
else if(loc.indexOf("games-and-media/games/") > -1)                 subSection = "games";

else if(loc.indexOf("site=support")> -1 ||loc.indexOf("/support") > -1)                subSection = "support";
else if(loc.indexOf("site=PlayStation_Blog")> -1)                subSection = "PlayStation_Blog";
else if(loc.indexOf("site=PlayStation_com")> -1)                subSection = "PlayStation_com";
else if(loc.indexOf("site=Forums")> -1 )                subSection = "Forums";
else if(loc.indexOf("site=All")> -1 )                subSection = "All";
else if(loc.indexOf("store") > -1)                  subSection = "store";
else if(loc.indexOf("playstation-plus") > -1)       subSection = "plus";
else if(loc.indexOf("gaming") > -1)                 subSection = "gaming";
//else if(loc.indexOf("events") > -1)                 subSection = "events";
else if(loc.indexOf("psn/original-programming") > -1)   subSection = "originalprogramming";
else if(loc.indexOf("home") > -1)                   subSection = "home";
else if(loc.indexOf("add-ons") > -1)                subSection = "addons";
else if(loc.indexOf("demos") > -1)                  subSection = "demos";
else if(loc.indexOf("movies") > -1)                 subSection = "movies";
else if(loc.indexOf("shows-and-tv-series") > -1)    subSection = "tvseries";
else if(loc.indexOf("games-and-media") > -1)        subSection = "gamesmedia";

else if(loc.indexOf("games_and_media") > -1)        subSection = "gamesmedia";

else if(loc.indexOf("/community/") > -1)              subSection = "community";   
else if(loc.indexOf("playstation-move") > -1)       subSection = "ps_move"; //Added by ASR to select the subsection
else if(loc.indexOf("move-community") > -1)       subSection = "ps_move"; //Added by ASR to select the subsection
else if(loc.indexOf("product-information") > -1)       subSection = "ps_move"; //Added by ASR to select the subsection
else if(loc.indexOf("/playstation-move/games/") > -1)       subSection = "ps_move"; //Added by ASR to select the subsection
else if(loc.indexOf("spring-fever") > -1)       subSection = "gamesmedia"; //Added by ASR to select the subsection
else if(loc.indexOf("/music-unlimited/") > -1)       subSection = "musicunltd"; //Added by ASR to select the subsection
else if(loc.indexOf("/apps/") > -1)       subSection = "app";
/* Added for the PSVITA Left navigation Start */


	else if(loc.indexOf("/psvita/") > -1)      			 subSection = "psv_nav"; 
	else if(loc.indexOf("/psvita/features") > -1)       	 subSection = "psv_nav"; 
	else if(loc.indexOf("/psvita/systems") > -1)      	 subSection = "psv_nav"; 
	else if(loc.indexOf("/psvita/accessories") > -1)       subSection = "psv_nav"; 
	else if(loc.indexOf("/psvita/apps") > -1)            subSection = "psv_nav"; 
	else if(loc.indexOf("/psvita/games-and-media") > -1)   subSection = "psv_nav"; 
/* Added for the PSVITA Left navigation End */

//Check for Browser and OS
var sBrowserFF = navigator.userAgent.toLowerCase().indexOf('firefox') != -1;
var sBrowserSa = navigator.userAgent.toLowerCase().indexOf('safari') != -1;
var sBrowserGC = navigator.userAgent.toLowerCase().indexOf('chrome') != -1;
var sOS = navigator.platform.toLowerCase().indexOf('mac') != -1;


if(window.location.toString().indexOf("/search/") < 0){

if(window.location.toString().indexOf("games-and-media/psn-spring-fever-2010-games/") > -1){
 
    if(window.location.toString().indexOf("id=")==-1)
    {
        expandedSection = "games_media_nav";
        subSection="All";
    }
    else 
    {expandedSection = "";  
    }
} 
//for new browse all
else if(window.location.toString().indexOf("BrowseGames") > -1){
    if(window.location.toString().indexOf("id=")==-1)
        expandedSection = "games_media_nav";
    else expandedSection = "";  
}
else if(window.location.toString().indexOf("BrowseAllHardware") > -1){
    if(window.location.toString().indexOf("id=")==-1)
        expandedSection = "games_media_nav";
    else expandedSection = "";  
}
else if(window.location.toString().indexOf("SearchMovies") > -1){
    if(window.location.toString().indexOf("id=")==-1)
        expandedSection = "games_media_nav";
    else expandedSection = "";  
}

//end of browse all
 
else if(window.location.toString().indexOf("psn/original-programming/") > -1){
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "games_media_nav";
    }
    else expandedSection = "";  
}

else if(window.location.toString().indexOf("games-and-media/games/") > -1){
    if(window.location.toString().indexOf("id=")==-1)
        expandedSection = "games_media_nav";
    else expandedSection = "";  
}
 else if(window.location.toString().indexOf("psn") > -1 || window.location.toString().indexOf("playstation_network") > -1) {

    if(window.location.toString().indexOf("id=")==-1)
        expandedSection = "psn_nav";
    else
        expandedSection = "";
}      
 
else if(window.location.toString().indexOf("/psvita/") > -1){
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "psv_nav";
    }
    else expandedSection = "";  
}
 
else if(window.location.toString().indexOf("/livechat/") > -1){
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "psv_nav";
    }
    else expandedSection = "";  
}
else if(window.location.toString().indexOf("games-and-media/add-ons/") > -1){
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "games_media_nav";
    }
    else expandedSection = "";  
}

else if(window.location.toString().indexOf("/music-unlimited/") > -1){
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "games_media_nav";
    }
    else expandedSection = "";  
}

else if(window.location.toString().indexOf("games-and-media/shows-and-tv-series/") > -1){
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "games_media_nav";
    }
    else expandedSection = "";  
}
else if(window.location.toString().indexOf("games-and-media/movies/") > -1){
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "games_media_nav";
    }
    else expandedSection = "";  
}

else if(window.location.toString().indexOf("games-and-media") > -1) {
    if(window.location.toString().indexOf("id=")==-1){
        if(window.location.toString().indexOf("ps3") > -1 || window.location.toString().indexOf("playstation3") > -1 || window.location.toString().indexOf("playstation 3") > -1){      
				expandedSection = "ps3_nav";	 
        }
        else if(window.location.toString().indexOf("psp") > -1){
            expandedSection = "psp_nav";
        }
        else if(window.location.toString().indexOf("ps2") > -1 || window.location.toString().indexOf("playstation2") > -1 || window.location.toString().indexOf("playstation 2") > -1){
            expandedSection = "ps2_nav";
        }
        else{
            expandedSection = "games_media_nav";
        }
    }
    else
        expandedSection = "";   
}

else if(window.location.toString().indexOf("games_and_media") > -1){
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "games_media_nav";
    }
    else expandedSection = "";  
}


else if(window.location.toString().indexOf("ps3") > -1 || window.location.toString().indexOf("playstation3") > -1 || window.location.toString().indexOf("playstation 3") > -1) {
    if(window.location.toString().indexOf("id=")==-1){
        if(window.location.toString().indexOf("/support/systemupdates/ps3/") > -1) {    	 expandedSection = "support_nav";}
        else{
        	expandedSection = "ps3_nav";
        }
    	if(window.location.toString().indexOf("playstation-move/faq") > -1){subSection = "ps_move";}
    	
    }
    else{
        expandedSection = "";
        }
}
else if(window.location.toString().indexOf("ps3") > -1 || window.location.toString().indexOf("playstation3") > -1 || window.location.toString().indexOf("playstation 3") > -1) {
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "ps3_nav";
    	if(window.location.toString().indexOf("/playstation-move/move-community/") > -1){subSection = "ps_move";}
    	
    }
    else{
        expandedSection = "";
        }
}
else if(window.location.toString().indexOf("ps3") > -1 || window.location.toString().indexOf("playstation3") > -1 || window.location.toString().indexOf("playstation 3") > -1) {
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "ps3_nav";
    	if(window.location.toString().indexOf("/playstation-move/product-information/") > -1){subSection = "ps_move";}
    	
    }
    else{
        expandedSection = "";
        }
}
else if(window.location.toString().indexOf("ps3") > -1 || window.location.toString().indexOf("playstation3") > -1 || window.location.toString().indexOf("playstation 3") > -1) {
    if(window.location.toString().indexOf("id=")==-1){
        expandedSection = "ps3_nav";
    	if(window.location.toString().indexOf("/playstation-move/games/") > -1){subSection = "ps_move";}
    	
    }
    else{
        expandedSection = "";
        }
}

else if(window.location.toString().indexOf("psp") > -1) {
    if(window.location.toString().indexOf("id=")==-1){
    	if(window.location.toString().indexOf("/support/systemupdates/psp/") > -1){expandedSection = "support_nav"}
    	else{
      	expandedSection = "psp_nav";
      	}
    }
    else expandedSection = "";
}
else if(window.location.toString().indexOf("ps2") > -1 || window.location.toString().indexOf("playstation2") > -1 || window.location.toString().indexOf("playstation 2") > -1) {

    if(window.location.toString().indexOf("id=")==-1) {  expandedSection = "ps2_nav"; }
    else  { expandedSection = ""; } 
}

else if(window.location.toString().indexOf("support") > -1 ) {

    if(window.location.toString().indexOf("id=")==-1) {  
    expandedSection = "support_nav"; 
    if(window.location.toString().indexOf("/support/answer/list/") > -1){subSection = "knowledgecenter_nav";}
     if(window.location.toString().indexOf("/support/contact_options/") > -1) {     	 subSection = "contactsupport_nav";}
	  if(window.location.toString().indexOf("/support/systemupdates/psp/") > -1){expandedSection = "support_nav"}
     if(window.location.toString().indexOf("/support/systemupdates/ps3/") > -1) {     	 expandedSection = "support_nav";}
    //if(window.location.toString().indexOf("/support/answer/") > -1){expandedSection = "support_nav"}	
    
    }
    else  { expandedSection = "support_nav"; } }

	else if(window.location.toString().indexOf("events") > -1 ) {

    if(window.location.toString().indexOf("id=")==-1) {  expandedSection = "experienceps_nav"; 
    if(window.location.toString().indexOf("/events/getthegoods/") > -1)     {subSection = "getthegoods_nav";}
     if(window.location.toString().indexOf("/events/liveevents/") > -1) {     	 subSection = "liveevents_nav";}
     if(window.location.toString().indexOf("/events/tournaments/") > -1) {     	 subSection = "tournaments";}
    	
    
    }
    else  { expandedSection = ""; } 
}

else{
    expandedSection = "";
}

}/* Close of search check */


var params = {  
    allowscriptaccess: "always",   
    wmode:"transparent",
    swLiveConnect:"true",
    allowNetworking:"all"
};

if(loc.indexOf("usplaystation")> 0){
    var flashvars = {navXML: "ps_main_navigation.xml",expandedSection: expandedSection,selectedSubSection: subSection};
}

else if(loc.indexOf("np.us.playstation")> 0){
    var flashvars = {navXML: "np_ps_main_navigation.xml",expandedSection: expandedSection,selectedSubSection: subSection};
}
else{
    var flashvars = {navXML: "ps_main_navigation_pub.xml",expandedSection: expandedSection,selectedSubSection: subSection};
}
var attributes = {id: "navswf", name: "navswf"};
var navSwfPath;  
navSwfPath=getAssetPath()+"ps_mainnav.swf"  ;       
//swfobject.embedSWF(navSwfPath, "navdiv", "130", "755", "9.0.47", ucmWebRoot+"groups/public/documents/webasset/ps_expressinstall.swf", flashvars, params, attributes);
//swfobject.embedSWF(navSwfPath, "navdiv", "267", "755", "9.0.47", ucmWebRoot+"groups/public/documents/webasset/ps_expressinstall.swf", flashvars, params, attributes);

if( (sOS.toString()=="true") ){
	if( (sBrowserSa.toString()=="true") && (sBrowserGC.toString()=="false") || (sBrowserFF.toString()=="true") && (sBrowserGC.toString()=="false") ){
		$(function(){
			BuildNav();
		});
	}
	else{
		swfobject.embedSWF(navSwfPath, "navdiv", "267", "755", "9.0.47", ucmWebRoot+"groups/public/documents/webasset/ps_expressinstall.swf", flashvars, params, attributes);
	}
}
else{
	swfobject.embedSWF(navSwfPath, "navdiv", "267", "755", "9.0.47", ucmWebRoot+"groups/public/documents/webasset/ps_expressinstall.swf", flashvars, params, attributes);
}

/* end of navigation*/


var xmlHttp;   
function createXmlHttpRequest(){
    if(window.ActiveXObject){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest){
        xmlHttp=new XMLHttpRequest();
    }
}
createXmlHttpRequest();

function fetchFriendsList(){    
    var serverName=window.location.host;  
    var servletURL=window.location.protocol+"//"+serverName+"/uwps/FetchFriendsList";  
    var status=false;
    $.ajax({
    type: "POST",
    url: servletURL,   
    async:   true,
    success: function(result){  
        getMovieName("profile_login").updateProfile(); 
    }
    });  
    return status;
}              
function createCookie(name,value,days) {
	
    var expires="";
    if(readCookie(name)){ return; }
    else{
    
    
        var date = new Date();
        date.setTime(date.getTime()+(7*24*60*60*1000));
        expires = "; expires="+date.toGMTString();        
        var domainName=".playstation.com";
        var domainIs = "";
        if(name.toString()=="APPLICATION_SITE_URL") {
        domainIs = "domain="+domainName;
        }
        document.cookie = name+"="+value+expires+"; path=/;"+domainIs;       
    }
}

function createSessionCookie(name,value,days) {

	
    var expires="";
	var domainName=".playstation.com";
    if(readCookie(name)){ return; }
    else{  
		var serverName=window.location.host+"";
		if(serverName.indexOf("playstation.com") != -1)
		{
			domainName=".playstation.com";
		}
		else
		{
		var domainName=".playstation.sony.com";
		}
        document.cookie = name+"="+value+"; path=/; domain="+domainName;       
    }
}

function getCookieValueFromServer(cookieName){  
    var cookieValue="";
    var serverName=window.location.host;
    var servletURL=window.location.protocol+"//"+serverName+"/uwps/CookieHandler";
    xmlHttp.open("POST", servletURL, false);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(null);
    return xmlHttp.responseText; 
}

function overwriteCookie(name,value,days) {
    var expires="";
    var date = new Date();
    date.setTime(date.getTime()+(7*24*60*60*1000));
    expires = "; expires="+date.toGMTString();
    var domainName=".playstation.com";
    var domainIs = "";
    if(name.toString()=="APPLICATION_SITE_URL") {
        domainIs = "domain="+domainName;
    }
    if(!days){
        document.cookie = name+"="+value+expires+"; path=/;"+domainIs;
    }
    else{
        document.cookie = name+"="+value+"; path=/;"+domainIs;
    }
}
 
function readCookie(name) {
	var cookieValue="";
	var serverName=window.location.host;
	var servletURL=window.location.protocol+"//"+serverName+"/uwps/PSNLoginCookie?cookieName="+name+"&id="+Math.random();
	
	if((navigator.appVersion.indexOf("MSIE 6")!=-1)||(navigator.appVersion.indexOf("MSIE 7")!=-1)){
		cookieValue = $.ajax({type: "POST",url: servletURL,async: false}).responseText;
		return cookieValue;
	}else{
    	var nameEQ1 = name + "=";    
    	var ca1 = document.cookie;
    	var ca= ca1.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(nameEQ1) == 0){
                	return  unescape(c.substring(nameEQ1.length,c.length)) ;
        	}
    	}
    }
    return false;
}

function eraseCookie(name) {
    var date = new Date();
    date.setTime(-1);
    var expires = "; expires="+date.toGMTString();
    var domainName=".playstation.com";
    var domainIs = "";
    if(name.toString()=="APPLICATION_SITE_URL") {
        domainIs = "domain="+domainName;
    }
    document.cookie = name+"="+""+expires+"; path=/;"+domainIs;
}

function getXmlHttpRequestObject() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest(); //Not IE
    } 
    else if(window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP"); //IE
    } 
    else {
        //Display your error message here. 
        //and inform the user they might want to upgrade
        //their browser.
    }
 }
    
if (typeof DOMParser == "undefined") {
    DOMParser = function () {}
    DOMParser.prototype.parseFromString = function (str, contentType) {
        if (typeof ActiveXObject != "undefined") {
            var d = new ActiveXObject("MSXML.DomDocument");
            d.loadXML(str);
            return d;
        }
        else if (typeof XMLHttpRequest != "undefined") {
            var req = new XMLHttpRequest;
            req.open("GET", "data:" + (contentType || "application/xml") +
                            ";charset=utf-8," + encodeURIComponent(str), false);
            if (req.overrideMimeType) {
            req.overrideMimeType(contentType);
            }
            req.send(null);
            return req.responseXML;
        }
    }
}

function setIFrameHeightToCookie(cookieValue,iframeId){
    var formHeight = readCookie(cookieValue);   
    var iFrame = document.getElementById(iframeId); 
    if(iFrame == null){
        iFrame=parent.document.getElementById(iframeId);
    }
    if (formHeight != null ){   
        iFrame.height = parseInt(formHeight) + 30;
        if(iFrame.height=='NaN' || iFrame.height=='0'){
            iFrame.height = '600px';
        }
    } 
    else{
        if(iFrame != null)  iFrame.height = '600px';
    }
}

function queryString(parameter) { 
  var loc = location.search.substring(1, location.search.length);
  var param_value = false;

  var params = loc.split("&");
  for (i=0; i<params.length;i++) {
      param_name = params[i].substring(0,params[i].indexOf('='));
      if (param_name == parameter) {
          param_value = params[i].substring(params[i].indexOf('=')+1)
          
      }
  }
  if (param_value) {
      return param_value;
  }
  else {
      return false; //Here determine return if no parameter is found
  }
}

function getParam(param){
    var loc = location.search.substring(1, location.search.length);     
    var param_name="";
    var name="";
    var params = loc.split("&");
    for (i=0; i<params.length;i++) {
        name = params[i].substring(0,params[i].indexOf('='));
        param_name="";
        if(name && name==param){
            param_name = name;
            break;
        }   
    }
    return param_name;
}
function trimString(stringToTrim){
if(stringToTrim=='undefined')  return "";
    return stringToTrim.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function checkMultipleEmails(c_s_list,seperator){
    if(c_s_list.lastIndexOf(",")+1==c_s_list.length)
        c_s_list=c_s_list.substring(0,c_s_list.length-1);
    var arr = c_s_list.split(seperator); 
    for (var i = 0, l = arr.length; i < l; i++){ 
        var str = trimString(arr[i]); 
        if(!emailIdCheckOne(str)) return false;                  
    }
    return true;
}
    
function emailIdCheckOne(str) {
    var at="@";
    var dot=".";
    var lat=str.indexOf(at);
    var lstr=str.length;
    var ldot=str.indexOf(dot);
    if (str.indexOf(at)==-1){
       return false
    }
    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)   {return false}
    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){return false}
    if (str.indexOf(at,(lat+1))!=-1){return false }
    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        return false;
    }   
    if (str.indexOf(dot,(lat+2))==-1){
        return false;
    }   
    if (str.indexOf(" ")!=-1){
        return false;
    }   
    return true;                    
}
    
    /*date_arr and days_arr variables are also used by psn store sign up*/
    
var date_arr = new Array;
var days_arr = new Array;

date_arr[0]=new Option("MM",31);
date_arr[1]=new Option("01",31);
date_arr[2]=new Option("02",28);
date_arr[3]=new Option("03",31);
date_arr[4]=new Option("04",30);
date_arr[5]=new Option("05",31);
date_arr[6]=new Option("06",30);
date_arr[7]=new Option("07",31);
date_arr[8]=new Option("08",31);
date_arr[9]=new Option("09",30);
date_arr[10]=new Option("10",31);
date_arr[11]=new Option("11",30);
date_arr[12]=new Option("12",31);

function fill_select(f){        
    document.writeln("<SELECT class='drop_down_month' name=\"months\"  id=\"months\" onchange=\"update_days(frmAgeGate)\" >");
    //document.writeln("<option value='MM'>MM</option>");
	for(x=0;x<13;x++)
        document.writeln("<OPTION value=\""+date_arr[x].value+"\">"+date_arr[x].text);
        document.writeln("</SELECT>");
        document.writeln("<span style='font-size:14px;color:#525252;margin-right:5px;'>/</span>")
        document.writeln("<SELECT class='drop_down_day' style=\"width:48px;\" name=\"days\" id=\"days\"><option value='DD'>DD</option>")
                
        for(x=1;x<=31;x++)
        { 
			document.writeln("<OPTION value=\""+x+"\">"+x);
        }
        document.writeln("</SELECT>");
        document.writeln("<span style='font-size:14px;color:#525252;margin-right:5px;'>/</span>")
        selection=f.months[f.months.selectedIndex].value;
}



function update_days(f){
	        temp=f.days.selectedIndex;
        
        for(x=days_arr.length;x>0;x--){
       
            days_arr[x]=null;
            f.days.options[x]=null;
        }
       
      
        selection=parseInt(f.months[f.months.selectedIndex].value);
        ret_val = 0;
        if(f.months[f.months.selectedIndex].value == 28){
            year=parseInt(f.years.options[f.years.selectedIndex].value);
            if(year==2000)
               ret_val=1;
            else if (year % 4 != 0 || year % 100 == 0 ) ret_val=0;
            else if (year % 400 == 0)  ret_val=1;
                else
                ret_val=1;
        }
        selection = selection + ret_val;
        
        for(x=1;x < selection+1;x++){
      
            days_arr[x]=new Option(x);
            f.days.options[x]=days_arr[x];
        }
        if (temp == -1) {f.days.options[0].selected=true;}
        else {
		if(temp == 29)	{
			if(f.months.selectedIndex == 2){
			
				if(year % 4 == 0 || year % 400 == 0){
					f.days.options[temp].selected=true;
				}
				else if(f.years.selectedIndex % 4 == 0){
				
					if(year % 4 != 0 || year % 400 != 0){
						f.days.options[28].selected=true;
					}else {
						f.days.options[temp].selected=true;
					}
				}
				else{
					f.days.options[28].selected=true;
				}
			
			} 
			else{
				f.days.options[temp].selected=true;
			}
		} else if(temp > 29) {
		
				if(f.months.selectedIndex == 2){
					f.days.options[28].selected=true;
				} else if(f.months.selectedIndex == 4 || f.months.selectedIndex == 6 || f.months.selectedIndex == 9 || f.months.selectedIndex == 11){
					f.days.options[30].selected=true;
			  	} else {
			  		f.days.options[temp].selected=true;
			  	}
		}
		else{
			f.days.options[temp].selected=true;
			}
		}


}
function year_install(f){
        var d = new Date();
        var curr_year = d.getFullYear();
        document.writeln("<SELECT class='drop_down_month' name=\"years\" id=\"years\" onchange=\"update_days(frmAgeGate)\">")
        document.writeln("<option value='YYYY'>YYYY</option>");
        for(x=curr_year;x>1900;x--) document.writeln("<OPTION value=\""+x+"\">"+x);
        document.writeln("</SELECT>");
         var bIsPS3 = navigator.userAgent.toLowerCase().indexOf('playstation') != -1;
        if (bIsPS3.toString()!="true")
       	{ 
       		update_days(f)
       	}
}
function loadOtherParamData(paramType,paramValue){
    $("#hiddenOtherParamText").get(0).innerHTML=paramType;
    $("#hiddenOtherParamValue").get(0).innerHTML=paramValue;
}


function checkBlankLink(linkText){
    if(linkText == ""){        
        document.getElementById("moreLinks").style.display="none";
    }
    else{        
        document.getElementById("moreLinks").style.display="block";
    }
}

//This Function is for Browing each tab and redirecting the link according to the tab seleted 
function redirectMoreLinks(strUrl){
     var consoleType="";
    var redirectPlatform=document.getElementById("hiddenPlatform").innerHTML;
      
    var redirectType=trimString(document.getElementById("hiddenType").innerHTML);
    
      
     if(strUrl == "PSP" || strUrl == "psp"){					
		consoleType = "pspgo,psp3000";				
	}else{
	consoleType=redirectPlatform.toLowerCase();
	}
      
     
      
    var redirectOtherParamType ="";
    var redirectOtherParamValue ="";
    if(document.getElementById("hiddenOtherParamText") != null){
        redirectOtherParamType=trimString(document.getElementById("hiddenOtherParamText").innerHTML);
    }
    if(document.getElementById("hiddenOtherParamValue") != null){
         redirectOtherParamValue=trimString(document.getElementById("hiddenOtherParamValue").innerHTML);
    }
    var subCategoryType="console"; 
   
   
  
    
    if(redirectType != null  && redirectType == "Accessory"){
        if(strUrl == "ps3"){
            window.location=location.protocol +"//"+ window.location.host + globalSiteName+"ps3/accessories/index.htm";
        }
        else if(strUrl == "ps2"){
            window.location=location.protocol +"//"+ window.location.host + globalSiteName+"ps2/accessories/index.htm";
        }
        else if(strUrl == "psp"){
            window.location=location.protocol +"//"+ window.location.host + globalSiteName+"psp/accessories/index.htm?redirectPlatform="+redirectPlatform;
        }
    
    }
    
    else if (redirectOtherParamType != null && redirectOtherParamType != "" ){
        if(redirectType=="movies")
        window.location =location.protocol +"//"+window.location.host+"/uwps/SearchMovies?category=movies&"+redirectOtherParamType+"="+redirectOtherParamValue+"&beginsWith=Any";	
        else
        window.location =location.protocol +"//"+window.location.host+"/uwps/SearchMovies?console="+consoleType+"&"+redirectOtherParamType+"="+redirectOtherParamValue+"&beginsWith=Any";	
        //window.location =location.protocol +"//"+window.location.host+globalSiteName+"games-and-media/gameslist/index.htm?type="+redirectType+"&subCategoryType="+subCategoryType+"&subCategoryValue="+redirectPlatform+"&"+redirectOtherParamType+"="+redirectOtherParamValue; 
    }
    else{
        window.location =location.protocol +"//"+window.location.host+"/uwps/BrowseGames?console="+consoleType+"&beginsWith=Any";	
        //window.location =location.protocol +"//"+window.location.host+globalSiteName+"games-and-media/gameslist/index.htm?type="+redirectType+"&subCategoryType="+subCategoryType+"&subCategoryValue="+redirectPlatform;    
    }  
    if(redirectType != null  && redirectType == "store"){
     redirectStoreLinks();
    }
}
var globalSiteName="/usplaystation/";
if(window.location.toString().indexOf("usplaystation")==-1)
    globalSiteName="/";
 
function redirectNarrowLinks(){
    var redirectPlatform=document.getElementById("hiddenPlatform").innerHTML;narrowBy
    var redirectType=document.getElementById("hiddenType").innerHTML;
    var narrowBy=document.getElementById("narrowBy").innerHTML;
    var subCategoryType="console"; 
    window.location =location.protocol +"//"+window.location.host+globalSiteName+"games-and-media/gameslist/index.htm?type="+redirectType+"&narrow="+narrowBy+"&subCategoryType="+subCategoryType+"&subCategoryValue="+redirectPlatform;    
}

function redirectSupportLinks(strLink){
    if(strLink != null){
        window.location=location.protocol +"//"+window.location.host+globalSiteName+strLink;    
    }
}

function redirectNarrowLinkFullFeatured(){
 
 
    window.location =location.protocol +"//"+window.location.host+"/uwps/BrowseGames?console=pspgo,psp3000&beginsWith=Any";   
}

function HideIEDropDown(){
    if($.browser.msie && $.browser.version=="6.0"){
        var anchors = document.getElementsByTagName("select");
        for (var anchor = 0; anchor<anchors.length;anchor++){
            var item = anchors[anchor];
            item.style.visibility='hidden';
        }
    }
}

function ShowIEDropDown(){      
    if($.browser.msie && $.browser.version=="6.0"){
        var anchors = document.getElementsByTagName("select");
        for (var anchor = 0; anchor<anchors.length;anchor++){
            var item = anchors[anchor];
            item.style.visibility='visible';
        }
    }
}

function removeOptionsByValue(selectName, value, frmAgeGate) {
  for (var i=selectName.options.length-1; i>=0; i--) {
    if (selectName.options[i].value == value) {
      selectName.options[i] = null;
    }
  }
  update_days(frmAgeGate);
}

function openOverlay(div1, div2){
    $('.'+div1).toggle();
    $('#'+div2).toggle();
}

function openCIOverlay(skuid, rgid){
    $('.share-this3').toggle();
    $('#black_overlay11').toggle();
    document.getElementById('ciOverlayFrame').src="http://sony.links.channelintelligence.com/pages/prices.asp?sSKU="+skuid+"&nRGID=1864";
}
function openCIOverlayFlBuy(){
    $('.share-this3').toggle();
    $('#black_overlay11').toggle();
    document.getElementById('ciOverlayFrame').src="http://sony.links.channelintelligence.com/pages/prices.asp?cii_nIID=69770527&cii_sSort=vendor&cii_sSortOrder=asc&cii_nRGID=1864&cii_nRID=0&cii_sCT=&cii_sCData=";
}

function openFlashOverlay(div1, div2, url){
    $('.'+div1).toggle();
    $('#'+div2).toggle();
    $('#iframeFlashOverlay').attr("src",url);   
}


function blankFun(){}

function getRequestParameter(){
    var current_URL=window.location.toString();
    var ind=current_URL.indexOf("?");
    var paramValue="";
    if (current_URL.indexOf('?') != -1) {
        var param= current_URL.substring(current_URL.indexOf('?')+1);
         paramValue=current_URL.substring(current_URL.indexOf('=')+1);
    }
    return paramValue;
}

function isTicketCookiesExists(){
    var ticketCookie=readCookie("TICKET");   
	 var s2sTicketCookie=readCookie("PSNS2STICKET");
    if(ticketCookie && s2sTicketCookie)
        return true;
    else
        return  false; 
}

function viewLargeScreenshot(url){  
     if(document.cookie.indexOf('Screenshot') >= 0){
        document.getElementById("agreeDisaree").style.display="none";
        document.getElementById("agreeDisareeBox").style.display="none";
        window.open(url)
        document.getElementById('hiddenField').value=url;
    }
    else{    
        document.getElementById("agreeDisaree").style.display="block";
        document.getElementById("agreeDisareeBox").style.display="block";
        document.getElementById("agreeDisareeBox").style.zIndex="1";
        document.getElementById("agreeDisaree").style.zIndex="9";
        document.getElementById('hiddenField').value=url;
    }
}

function agreescreenshot(){
	var domainName=".playstation.com";
	var domainIs = "";
    if(name.toString()=="APPLICATION_SITE_URL") {
        domainIs = 'domain='+domainName;
    }
    document.cookie ='Screenshot=popup; expires=Fri, 27 Jul 2010 02:47:11 UTC; path=/;'+domainIs;
    var openwindow=document.getElementById('hiddenField').value;
    window.open(openwindow);
    document.getElementById("agreeDisaree").style.display="none";
    document.getElementById("agreeDisareeBox").style.display="none";    
}

function openDownloadWallpaper(url){

var desc="filename="+url;
    if(document.cookie.indexOf('Wallpaper') >= 0){
        document.getElementById("agreeDisareeWall").style.display="none";
        document.getElementById("agreeDisareeBox").style.display="none";
        window.open(url)
        document.getElementById('hiddenField1').value=url;
    }
    
    else{    
        document.getElementById("agreeDisareeWall").style.display="block";
        document.getElementById("agreeDisareeBox").style.display="block";
        document.getElementById("agreeDisareeWall").style.zIndex="9";
        document.getElementById("agreeDisareeBox").style.zIndex="1";            
        document.getElementById('hiddenField1').value=url;
     }
        logeventRequest("130","301",desc);
}

function agree(){
	var domainName=".playstation.com";
	var domainIs = "";
    if(name.toString()=="APPLICATION_SITE_URL") {
        domainIs = 'domain='+domainName;
    }
    document.cookie ='Wallpaper=popup; expires=Fri, 27 Jul 2010 02:47:11 UTC; path=/;'+domainIs; 
    var openwindow1=document.getElementById('hiddenField1').value;
    window.open(openwindow1)
    document.getElementById("agreeDisareeWall").style.display="none";
    document.getElementById("agreeDisareeBox").style.display="none";
}
function removeOptionsByValue_psn(selectName, value, frm) {


  for (var i=selectName.options.length-1; i>=0; i--) {
  
    if (selectName.options[i].value == value) {
      selectName.options[i] = null;
    }
  }
  
  for(x=frm.days.options.length;x>0;x--)
  {
            frm.days.options[x]=null;
   }
  update_days_psn(frm);
}


function fill_select_psn(f){        
 //document.writeln("<SELECT  name=\"months\" style=\"width:50px;\" id=\"months\" onclick=\" removeOptionsByValue_psn(this.form.months,'MM' ,SignUpUpdate)\"  onchange=\"update_days_psn(SignUpUpdate)\">");
 document.writeln("<SELECT style=\"width:50px;\" name=\"months\"  id=\"months\"  onchange=\"update_days_psn(SignUpUpdate)\" >");
      //  document.writeln("<option value='MM'>MM</option>")
        for(x=0;x<13;x++)
                document.writeln("<OPTION value=\""+date_arr[x].value+"\">"+date_arr[x].text);
        document.writeln("</SELECT>");
            document.writeln("<span style='font-size:14px;color:#525252;margin-right:5px;'>/</span>")
                document.writeln("<SELECT  style=\"width:48px;\" name=\"days\" id=\"days\"><option value='DD'>DD</option>")
                
                 for(x=1;x<=31;x++)
                 { document.writeln("<OPTION value=\""+x+"\">"+x);
                 }
                document.writeln("</SELECT>");
                   document.writeln("<span style='font-size:14px;color:#525252;margin-right:5px;'>/</span>")
        
             selection=f.months[f.months.selectedIndex].value;
}
/*Particular code for NGP*/
function fill_select_ngp(f){        
	//document.writeln("<SELECT style=\"width:50px;\" name=\"months\"  id=\"months\" onclick=\" removeOptionsByValue_psn(this.form.months,'MM' ,SignUpUpdate)\"  onchange=\"update_days_psn(SignUpUpdate)\" >"); 
	document.writeln("<SELECT style=\"width:50px;\" name=\"months\"  id=\"months\"  onchange=\"update_days_psn(SignUpUpdate)\" >");
   // document.writeln("<option value='MM'>MM</option>");
    for(x=0;x<13;x++)
		document.writeln("<OPTION value=\""+date_arr[x].value+"\">"+date_arr[x].text+"</OPTION>");
		document.writeln("</SELECT>");
		document.writeln("<span style='font-size:14px;color:#525252;margin-right:5px;'>&nbsp;</span>");
		document.writeln("<SELECT style=\"width:48px;\" name=\"days\" id=\"days\">");
		document.writeln("<option value='DD'>DD</option>");
    for(x=1;x<=31;x++)
    	document.writeln("<OPTION value="+x+">"+x+"</OPTION>");
        document.writeln("</SELECT>");
    	document.writeln("<span style='font-size:14px;color:#525252;margin-right:5px;'>&nbsp;</span>");   			
   		selection=f.months[f.months.selectedIndex].value;
}
/*Particular code for NGP*/

function update_days_psn(f){
        temp=f.days.selectedIndex;
        
        for(x=days_arr.length;x>0;x--){
       
            days_arr[x]=null;
            f.days.options[x]=null;
        }
       
      
        selection=parseInt(f.months[f.months.selectedIndex].value);
        ret_val = 0;
        if(f.months[f.months.selectedIndex].value == 28){
            year=parseInt(f.years.options[f.years.selectedIndex].value);
            if(year==2000)
               ret_val=1;
            else if (year % 4 != 0 || year % 100 == 0 ) ret_val=0;
            else if (year % 400 == 0)  ret_val=1;
                else
                ret_val=1;
        }
        selection = selection + ret_val;
        
        for(x=1;x < selection+1;x++){
      
            days_arr[x]=new Option(x);
            f.days.options[x]=days_arr[x];
        }
        if (temp == -1) {f.days.options[0].selected=true;}
        else {
		if(temp == 29)	{
			if(f.months.selectedIndex == 2){
				if(f.years.selectedIndex % 4 == 0){
					f.days.options[temp].selected=true;
				}
				else{
					f.days.options[28].selected=true;
				}
			
			}
			else{
				f.days.options[temp].selected=true;
			}
		}
		else{
			f.days.options[temp].selected=true;
			}
		}
}
function year_install_psn(f){
    var d = new Date();
    var curr_year = d.getFullYear();
    document.writeln("<SELECT  style=\"width:80px;\" name=\"years\" id=\"years\" onchange=\"update_days_psn(SignUpUpdate)\">")
    document.writeln("<option value='YYYY'>YYYY</option>");
    for(x=curr_year;x>=1900;x--) document.writeln("<OPTION value=\""+x+"\">"+x);
    document.writeln("</SELECT>");
    update_days_psn(f)
}
/*Particular code for NGP*/
function year_install_ngp(f){
    var d = new Date();
    var curr_year = d.getFullYear();
    document.writeln("<SELECT  style=\"width:80px;\" name=\"years\" id=\"years\" onchange=\"update_days_psn(SignUpUpdate)\">")
    document.writeln("<option value='YYYY'>YYYY</option>");
    for(x=curr_year;x>=1900;x--) document.writeln("<OPTION value=\""+x+"\">"+x);
    document.writeln("</SELECT>");
    update_days_psn(f)
}
            
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

function isValidDate(month,year,day) {
    if(isNaN(month) || isNaN(year) || isNaN(day)){
        return false;
    }
    else{
        return true;
    }
}

var xmlhttp;
var vtitleLength = 30;
var vdescriptionLength = 180;
var htitleLength = 25;
var hdescriptionLength = 85;
var prefix="";
function showBlogs(feedurl, count, type, omni, prefix){
    if(feedurl==""||feedurl=="#"){
        $("#news").hide();
        $(".header_with_links").hide();
        
    }
    else{
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null){
        //alert ("Your browser does not support AJAX!");
        return;
    }
    var url="/uwps/UsplaystationBlogs";
    url=url+"?url="+feedurl;
    url=url+"&count="+count;
    url=url+"&type="+type;  
    if(omni != "undefined" && prefix != "undefined") {
     url=url+"&omni="+omni;
     url=url+"&prefix="+prefix;
    }  
    url=url+"&sid="+Math.random();
    /*if(type=='H'){
        xmlhttp.onreadystatechange=horizontalBlogesChanged;
    }else if(type=='V'){
        xmlhttp.onreadystatechange=verticalBlogsChanged;
    }*/
    xmlhttp.onreadystatechange=putBlogs;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
    }
}

var isBlogh2Replaced;

function putBlogs(){

    if (xmlhttp.readyState==4)
    {
        var returnStr = xmlhttp.responseText;
        if (isBlogh2Replaced == "true"){
         returnStr = returnStr.replace("<h4>"," ");
        returnStr = returnStr.replace("</h4>"," "); 
       	returnStr = returnStr.replace("<em>"," ");
	returnStr = returnStr.replace("</em>"," ");
       	returnStr = returnStr.replace('<div style="text-align: justify;">'," ");
       
        }
        if(trimString(returnStr.toString())!="No News items available"){

       	returnStr = returnStr.replace('<div style="text-align: justify;">'," ");

		if(document.getElementById("news"))
            {
            document.getElementById("news").innerHTML = returnStr;
            }
        }else{
            $("#news").hide();
            $(".header_with_links").hide();
        }
    }
}
function horizontalBlogesChanged(){
    if (xmlhttp.readyState==4) {
        var returnStr = "";
        returnStr = returnStr + "<div class=\"grid\"><div class=\"gridInner\">";
        var xmlDoc=xmlhttp.responseXML;
        var items = xmlDoc.getElementsByTagName("item");
        for(itemIndex = 0; itemIndex < items.length; itemIndex=itemIndex+1){
            var lastItem = "";
            if(itemIndex == items.length-1){
                lastItem = " last";
            }
            var title = xmlDoc.getElementsByTagName("title")[itemIndex].childNodes[0].nodeValue;
            var link = xmlDoc.getElementsByTagName("link")[itemIndex].childNodes[0].nodeValue;
            var description = xmlDoc.getElementsByTagName("description")[itemIndex].childNodes[0].nodeValue;
            if(title.length > htitleLength){
                title = title.substring(0, htitleLength)+"...";
            }
            if(description.length > hdescriptionLength){
                description = description.substring(0, hdescriptionLength)+"...";
            }
            returnStr = returnStr + "<div class=\"item"+lastItem+"\"><div class=\"itemInner\">"
                        +"<div class=\"top\"><h4>"+title+"</h4>"
                        +"<p>"+description+"</p><a class=\"read\" href=\""+link+"\">Read</a>"
                        +"</div><div class=\"byline\"><h5><a href=\""+link+"\">PlayStation Blog</a></h5><p>JUN 18, 2009</p>"
                        +"</div></div></div>";
        }
        returnStr = returnStr + "</div></div>";
        document.getElementById("news").innerHTML = returnStr;
    }
}

function verticalBlogsChanged(){
    if (xmlhttp.readyState==4){
        var returnStr = "<h3>Latest PlayStation<span class='reg'>&reg;</span> News</h3>";
        var xmlDoc=xmlhttp.responseXML;
        var items = xmlDoc.getElementsByTagName("item");
        var count = 0;
        for(itemIndex = 0; itemIndex < items.length; itemIndex=itemIndex+1){
            var title = xmlDoc.getElementsByTagName("title")[itemIndex].childNodes[0].nodeValue;
            var link = xmlDoc.getElementsByTagName("link")[itemIndex].childNodes[0].nodeValue;
            var description = xmlDoc.getElementsByTagName("description")[itemIndex].childNodes[0].nodeValue;
            if(title.length > vtitleLength){
                title = title.substring(0, vtitleLength)+"...";
            }
            if(description.length > vdescriptionLength){
                description = description.substring(0, vdescriptionLength)+"...";
            }
            returnStr = returnStr + "<div class=\"item clearfix\"><div class=\"comment\"><h6>Jun 18, 2009</h6><h4>"+title+"</h4>"
                        +"<p>"+description+"&#8230;</p></div><div class=\"location\"><span><img src=\"groups/public/documents/webasset/ps_bg_blog_logo_gif.gif\" alt=\"BLOG\"/></span>"
                        +"<h5 class=\"blog\"><a href=\""+link+"\">PlayStation Blog</a></h5><a href=\""+link+"\" class=\"link\">Read</a></div></div>";
            count+=1;
        }
        document.getElementById("news").innerHTML = returnStr;
        document.getElementById("news").style.height = count * 200+"px";
        var iCntHt = count * 200;
        document.getElementById("news").style.float= "left";
        //document.getElementById("content").style.height= 150 + iCntHt + "px";
        document.getElementById("main").style.height= 1800 + "px";
    }
}

function GetXmlHttpObject()
{
    if (window.XMLHttpRequest){
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject){
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
return null;
}

function disagreescreenshot(){
    document.getElementById("agreeDisaree").style.display="none";
    document.getElementById("agreeDisareeBox").style.display="none";
}
 function disagree(){
    document.getElementById("agreeDisareeWall").style.display="none";
    document.getElementById("agreeDisareeBox").style.display="none";
            
}
function disapear(){
    document.getElementById('agreeDisareeBox').style.display="none";
    document.getElementById('agreeDisareeBox').style.display="none";
}


function openSocialSite(siteAlias,videoId){
    var urltoShow=window.location+"?videoid="+videoId;
    switch(siteAlias){
        case "facebook":
            window.open("http://www.facebook.com/share.php?u="+ encodeURIComponent(urltoShow)+"&t=" + encodeURIComponent("Your friend has shared a video.Click here to watch."));
            break;
        case "digg":
            window.open('http://digg.com/submit?phase=2&amp;url='+window.location+"?videoid="+videoId+'&amp;bodytext='+encodeURIComponent('Explore the official website of Sony PlayStation')+'&amp;tags=&amp;title='+encodeURIComponent(document.title));
        return false;
            break;
        case "myspace":     
            window.open("http://www.myspace.com/index.cfm?fuseaction=postto&t=Your%20friend%20has%20shared%20a%20video.%20Click%20here%20to%20watch.&u="+window.location+"%3Fvideoid%3D"+ videoId);
            break;
        case "stumble":
            window.open('http://www.stumbleupon.com/submit?url='+encodeURIComponent(window.location+"?videoid="+videoId)+'&amp;title='+encodeURIComponent(document.title));
            return false;
            break;
        case "delicious":
            window.open('http://del.icio.us/post?v=2&amp;url='+encodeURIComponent(window.location+"?videoid="+videoId)+'&amp;notes='+encodeURIComponent('Explore the official website of Sony PlayStation.')+'&amp;tags=&amp;title='+encodeURIComponent(document.title));
        return false;
            break;
        case "linkedin":
            window.open('http://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(window.location+"?videoid="+videoId)+'&title='+encodeURIComponent(document.title));
            break;
        case "reddit":
            window.open('http://www.reddit.com/submit?url='+encodeURIComponent(window.location)+'&title='+encodeURIComponent(document.title));
            return false;
            break;
        case "twitter":
            window.open('http://twitter.com/home?status='+encodeURIComponent(window.location+"?videoid="+videoId));
            break;  
        default:
            break;  
    }
}

function pauseMediaPlayer(playerId){
    var isPlaying=getMovieName(playerId).isFLVPlaying();
    if(isPlaying){
        getMovieName(playerId).pausePlayBack();
    }
    else{
        return;
    }
}
function playMediaPlayer(playerId){
    var isPlaying=getMovieName(playerId).isFLVPlaying();
    if(isPlaying){
        getMovieName(playerId).playPlayBack();
    }
    else{
        return;
    }   
}
function URLDecode(psEncodeString){  
  var lsRegExp = /\+/g;
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
} 
/*mediahelper.js*/

/*ps_FSH_AGEINFO.JS*/
function createAgeGateCookie(ageLevel){
    xmlstorehttp=GetXmlHttpObject();
    if (xmlstorehttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    var storeurl="/usplaystation/uwps/CreateAgeGateCookie";
    storeurl=storeurl+"?op.anValue="+ageLevel;
    storeurl=storeurl+"&sid="+Math.random();
    xmlstorehttp.onreadystatechange=getAgeGateDetail
    xmlstorehttp.open("GET",storeurl,true);
    xmlstorehttp.send(null);
}
function getAgeGateCookie(){
    var ageGateCook=isUserAllowedAgeGate();
    if(ageGateCook=="nc"){
        ageGateCook="n";
    }
    if(ageGateCook=="true"){
        ageGateCook="m";
    }
    if(ageGateCook=="false"){
        ageGateCook="u";
    }
    return ageGateCook;
}

function setAgeGateCookie(str) {
    if(str=="m"){
        createAgeGateCookie(str)
    }
    else{
        createAgeGateCookie(str)        
    }
}

function URLDecode(psEncodeString){  
  var lsRegExp = /\+/g;
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}
/*ps_FSH_AGEINFO.JS*/

/* OnlineOpinion (S3tS v3.1.1) Supports passing domains in argument */
/* This product and other products of OpinionLab, Inc. are protected by U.S. Patent No. 6606581, 6421724, 6785717 B1 and other patents pending. */

var custom_var,
_sp = '%3A\\/\\/',
_rp = '%3A//',
_poE = 0.0,
_poX = 0.0,
_sH = screen.height,
_d = document,
_w = window,
_ht = escape(_w.location.href),
_hr = _d.referrer,
_tm = (new Date()).getTime(),
_kp = 0,
_sW = screen.width;
function _fC(_u) {
    _aT = _sp + ',\\/,\\.,-,_,' + _rp + ',%2F,%2E,%2D,%5F';
    _aA = _aT.split(',');
    for (i = 0; i < 5; i++) {
        eval('_u=_u.replace(/' + _aA[i] + '/g,_aA[i+5])')
    }
    return _u
};
function O_LC(new_domain) {
    _domain = _ht.replace('https%3A//', '').replace('http%3A//', '');
    if (typeof new_domain == 'undefined' || new_domain == '') {
        _sp = '%3A\\/\\/';
        _rp = '%3A//'
    } else {
        _sp = '%3A\\/\\/' + _domain.substr(0, _domain.indexOf('/'));
        _rp = '%3A//' + new_domain
    }
    _w.open('https://secure.opinionlab.com/ccc01/comment_card.asp?time1=' + _tm + '&time2=' + (new Date()).getTime() + '&prev=' + _fC(escape(_hr)) + '&referer=' + _fC(_ht) + '&height=' + _sH + '&width=' + _sW + '&custom_var=' + custom_var, 'comments', 'width=535,height=192,screenX=' + ((_sW - 535) / 2) + ',screenY=' + ((_sH - 192) / 2) + ',top=' + ((_sH - 192) / 2) + ',left=' + ((_sW - 535) / 2) + ',resizable=yes,copyhistory=yes,scrollbars=no')
};
function _fPe() {
    if (Math.random() >= 1.0 - _poE) {
        O_LC();
        _poX = 0.0
    }
};
function _fPx() {
    if (Math.random() >= 1.0 - _poX) O_LC()
};
window.onunload = _fPx;
function O_GoT(_p) {
    _d.write('<a href=\'javascript:O_LC()\'>' + _p + '</a>');
    _fPe()
}


/*plugins.js*/

var ucmRootDir=ucmroot;

function getGameLinks(todayDate, gameDate){
	 if (document.getElementById("addgamediv") != null){
        if(todayDate - gameDate > 0){
            document.getElementById("addgamediv").style.display="block";
        }else{
            document.getElementById("addgamediv").style.display="none";
        }
	}
}

function getStoreResponse(skuid){


    xmlstorehttp=GetStoreXmlHttpObject();
    if (xmlstorehttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var storeurl="/uwps/UsplaystationChannelIntelligence";
    storeurl=storeurl+"?skuid="+skuid;
    storeurl=storeurl+"&sid="+Math.random();
    
   

    xmlstorehttp.onreadystatechange=getStoreUrl;
    xmlstorehttp.open("GET",storeurl,true); 
   
    xmlstorehttp.send(null);
}
var xmlHttp;
function getStoreResponse_New(skuid){

	gameSKUId =skuid;
    xmlHttp=GetStoreXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var storeurl="/uwps/UsplaystationChannelIntelligence";
    storeurl=storeurl+"?skuid="+skuid;
    storeurl=storeurl+"&sid="+Math.random();
   
   

    xmlHttp.onreadystatechange=getStoreUrl_New;
    xmlHttp.open("GET",storeurl,true); 
   
    xmlHttp.send(null);
   
}

function trim(str){ 
    if(!str || typeof str != 'string')
        return null;

    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}


function getStoreUrl(){

		
	    if (xmlstorehttp.readyState == 4){
     
    
        var returnStoreStr = xmlstorehttp.responseText;
        

        	if(trim(returnStoreStr)=="true"){
        		     	
            	document.getElementById("buynowbutton").style.display="block";
            	
        	}else{
            	document.getElementById("buynowbutton").style.display="none";
       		 	}
   		 }
		
}


function getStoreUrl_New(){
	
    if (xmlHttp.readyState == 4){
    
        var returnStoreStr = xmlHttp.responseText;
        
        	if(trim(returnStoreStr)=="true"){
        		
        	   	if(document.getElementById("buynowbuttonTest") != null) {
        	  
        	   		document.getElementById("buynowbuttonTest").style.display="block";
        	   		document.getElementById("buynowbutton").style.display="block";
        	   	} else {
        	   
            		document.getElementById("buynowbutton").style.display="block";
            	}
            	openGameBuyNowOverlay(); 
        	}else{
         		  if(document.getElementById("buynowbuttonTest") != null || document.getElementById("buynowbuttonTest") != "" || document.getElementById("buynowbuttonTest") != "undefined") {
        	   		document.getElementById("buynowbuttonTest").style.display="none";
        	   		document.getElementById("buynowbutton").style.display="none";
        	   	}
            	document.getElementById("buynowbutton").style.display="none";
       		 	}
   		 }
	
	
		
}


function GetStoreXmlHttpObject(){
    if (window.XMLHttpRequest) {
    
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject){
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
return null;
}


function openOverlay(sku){
    document.getElementById("overlayLogin").style.display="block";
    document.getElementById("signin-iframe").src="http://sony.links.channelintelligence.com/pages/prices.asp?sSKU="+sku+"&nRGID=2732";
}
function disableAnchor(obj, disable){ 
		if(disable){
				var href = obj.getAttribute("href");				
				var styleV=obj.getAttribute("style");
				//alert(onclick); 
				if(href && href != "" && href != null){ 
				obj.setAttribute('href_bak', href); 
				}
				if(styleV && styleV != "" && styleV != null){ 
				obj.setAttribute('style_bak', styleV); 
				}				
				obj.removeAttribute('href');			
				obj.style.color="gray"; 
						
				var onclick = obj.getAttribute("onclick"); 
				if(onclick != null){ 
				obj.setAttribute('onclick_bak', onclick); 
				obj.setAttribute('onclick', "void(0);"); 
				}
				
				
	}
	else{ 
	if(obj.attributes['onclick_bak']!=null) 
	obj.setAttribute('onclick', obj.attributes['onclick_bak'].nodeValue); 
	if(obj.attributes['href_bak']!=null) 
	obj.setAttribute('href', obj.attributes['href_bak'].nodeValue); 
	obj.removeAttribute('style');
	} 

} 
function getChildAnchor(p_sID) {
var children = document.getElementById(p_sID).childNodes;
	for (var i=0; i < children.length; i++) {
		if (children[i].tagName == "A") {
			return children[i];
			break;
		}
	}
}

//Update Starts
function addToList(skuid){
disableAnchor(getChildAnchor('addgamediv'),true);
if(!isUserLoggedIn()){
    document.getElementById("black_overlay1").style.display="block";
    document.getElementById("overlayLogin").style.display="block";
    document.getElementById("signin-iframe").src="https://store.playstation.com/external/index.vm?returnURL=https://"+location.host+"/uwps/PSNTicketRetrievalGenericServlet";
    disableAnchor(getChildAnchor('addgamediv'),false);
}else{
	var strwishlistGame ="";
    xmlstorehttp=GetStoreXmlHttpObject();
    if (xmlstorehttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    var wishspantxt=document.getElementById("wishlistspan").innerHTML;
    var gamespantxt=document.getElementById("gamelistspan").innerHTML;
    var action="";
    if(wishspantxt=="Add to Wish List"){
        action="upsert";
    }else{
        action="delete";
    }
	var storeurl="/uwps/UpdateList?gameCollectionType=Wish_List&actionType=";
	storeurl=storeurl+action;
	storeurl=storeurl+"&gameId="+skuid;
	xmlstorehttp.open("POST",storeurl,true);
	document.getElementById("wishlistspan").innerHTML="<img src='"+getAssetPath()+"ajax-loaderbrowse.gif'/>";
	xmlstorehttp.onreadystatechange=function handleServerResponse(){  
		if(xmlstorehttp.readyState==4){
			var response = xmlstorehttp.responseText;
			var xmlobject = (new DOMParser()).parseFromString(response, "text/xml");
			var type = xmlobject.getElementsByTagName('Action')[0].firstChild.nodeValue;
			if(type=="upsert"){
				var objWishListGame = getChildAnchor('wishlistGame');                            	
				if(gamespantxt=="Remove from My Games"){  
					document.getElementById("gamelistspan").innerHTML="Add to My Games";                                	
					document.getElementById("wishlistspan").innerHTML="Remove from Wish List"; 
					if(objWishListGame!=null){ 
						document.getElementById("wishlistGame").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/REMOVE_FROM_WISH_LIST');addToList('"+skuid+"',user);ClickOmniTrack(this,'event17','REMOVE_FROM_WISH_LIST');\" href=\"javascript:void(0);\"><span id=\"wishlistspan\">Remove from Wish List</span></a>";
					}                     
				}else{   
					document.getElementById("wishlistspan").innerHTML="Remove from Wish List";
					if(objWishListGame!=null){
						document.getElementById("wishlistGame").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/REMOVE_FROM_WISH_LIST');addToList('"+skuid+"',user);ClickOmniTrack(this,'event17','REMOVE_FROM_WISH_LIST');\" href=\"javascript:void(0);\"><span id=\"wishlistspan\">Remove from Wish List</span></a>";
					} 
				
				}
			}
			if(type=="delete"){
				document.getElementById("wishlistGame").innerHTML ="<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/Addtowishlist');addToList('"+skuid+"',user);ClickOmniTrack(this,'event10','AddToWishList');\" href=\"javascript:void(0);\"><span id=\"wishlistspan\">Add to Wish List</span></a>";
			}
			disableAnchor(getChildAnchor('addgamediv'),false);
		}
		}
		xmlstorehttp.send(null);
	}
}

function addToGames(skuid){
	disableAnchor(getChildAnchor('wishlistGame'),true);
	if(!isUserLoggedIn()){
		document.getElementById("black_overlay1").style.display="block";
		document.getElementById("overlayLogin").style.display="block";
		document.getElementById("signin-iframe").src="https://store.playstation.com/external/index.vm?returnURL=https://"+location.host+"/uwps/PSNTicketRetrievalGenericServlet";
		disableAnchor(getChildAnchor('wishlistGame'),false);
	}else{
		xmlstorehttp=GetStoreXmlHttpObject();
		if (xmlstorehttp==null){
            alert ("Your browser does not support AJAX!");
            return;
        }
        var wishspantxt=document.getElementById("wishlistspan").innerHTML;
        var gamespantxt=document.getElementById("gamelistspan").innerHTML;
        var action="";
        if(gamespantxt=="Add to My Games"){       
            action="upsert";
        }
        else {       
            action="delete";
        }
		var storeurl="/uwps/UpdateList?gameCollectionType=My_Games&actionType=";
		storeurl=storeurl+action;
		storeurl=storeurl+"&gameId="+skuid;
		xmlstorehttp.open("POST",storeurl,true);
		document.getElementById("gamelistspan").innerHTML="<img src='"+getAssetPath()+"ajax-loaderbrowse.gif'/>";
		xmlstorehttp.onreadystatechange=function handleServerResponse(){  
        if(xmlstorehttp.readyState==4){
			var response = xmlstorehttp.responseText;
			var xmlobject = (new DOMParser()).parseFromString(response, "text/xml");
			var type = xmlobject.getElementsByTagName('Action')[0].firstChild.nodeValue;
			if(type=="upsert"){
				var objMyGames = getChildAnchor('addgamediv');
				if(wishspantxt=="Remove from Wish List"){
					document.getElementById("wishlistspan").innerHTML="Add to Wish List";                                		
					document.getElementById("gamelistspan").innerHTML="Remove from My Games";
					if(objMyGames!=null){ 
						document.getElementById("addgamediv").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/REMOVE_FROM_MY_GAMES');addToGames('"+skuid+"',user);ClickOmniTrack(this,'event17','REMOVE_FROM_MY_GAMES');\" href=\"javascript:void(0);\"><span id=\"gamelistspan\">Remove from My Games</span></a>";
					}
				}else{
					document.getElementById("gamelistspan").innerHTML="Remove from My Games";
					if(objMyGames!=null){ 
						document.getElementById("addgamediv").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/REMOVE_FROM_MY_GAMES');addToGames('"+skuid+"',user);ClickOmniTrack(this,'event17','REMOVE_FROM_MY_GAMES');\" href=\"javascript:void(0);\"><span id=\"gamelistspan\">Remove from My Games</span></a>";
					}
				}
			}
			if(type=="delete"){
					document.getElementById("addgamediv").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/Addtogames');addToGames('"+skuid+"',user);ClickOmniTrack(this,'event13','AddToGamesList');\" href=\"javascript:void(0);\"><span id=\"gamelistspan\">Add to My Games</span></a>";  
			}
			disableAnchor(getChildAnchor('wishlistGame'),false);
		}
		}
		xmlstorehttp.send(null);
	}
}


function checkgame(skuid){
	xmlstorehttp=GetStoreXmlHttpObject();
    if (xmlstorehttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    var storeurl="/uwps/UpdateList?gameCollectionType=Wish_List&actionType=checkgame";
	storeurl=storeurl+"&gameId="+skuid;
	xmlstorehttp.open("POST",storeurl,true);
	document.getElementById("wishlistspan").innerHTML="<img src='"+getAssetPath()+"ajax-loaderbrowse.gif'/>";
	if(document.getElementById("gamelistspan").innerHTML!=""){
		document.getElementById("gamelistspan").innerHTML="<img src='"+getAssetPath()+"ajax-loaderbrowse.gif'/>";
	}
	xmlstorehttp.onreadystatechange=function handleServerResponse(){  
		if(xmlstorehttp.readyState==4){
			var response = xmlstorehttp.responseText;
			var xmlobject = (new DOMParser()).parseFromString(response, "text/xml");
			
			var wishlist = xmlobject.getElementsByTagName('GameExist')[0].firstChild.nodeValue;
			var gamelist = xmlobject.getElementsByTagName('GameList')[0].firstChild.nodeValue;
			var released = xmlobject.getElementsByTagName('IsReleased')[0].firstChild.nodeValue;
			if(wishlist=="success"){
				if(document.getElementById("wishlistspan").innerHTML=="Remove from Wish List") {
					document.getElementById("wishlistGame").innerHTML ="<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/Addtowishlist');addToList('"+skuid+"',user);ClickOmniTrack(this,'event10','AddToWishList');\" href=\"javascript:void(0);\"><span id=\"wishlistspan\">Add to Wish List</span></a>";
					
				} else {
					document.getElementById("wishlistGame").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/REMOVE_FROM_WISH_LIST');addToList('"+skuid+"',user);ClickOmniTrack(this,'event17','REMOVE_FROM_WISH_LIST');\" href=\"javascript:void(0);\"><span id=\"wishlistspan\">Remove from Wish List</span></a>";
				}
			}
			if(wishlist=="failure"){
				document.getElementById("wishlistspan").innerHTML="Add to Wish List";   
			}
			if(released=="success"){
				if(gamelist=="success"){
					if(document.getElementById("gamelistspan").innerHTML="Remove from My Games") {
						document.getElementById("addgamediv").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/REMOVE_FROM_MY_GAMES');addToGames('"+skuid+"',user);ClickOmniTrack(this,'event17','REMOVE_FROM_MY_GAMES');\" href=\"javascript:void(0);\"><span id=\"gamelistspan\">Remove from My Games</span></a>";
					}
				}else{
					document.getElementById("gamelistspan").innerHTML="Add to My Games";
				}
			}else{
				document.getElementById("addgamediv").style.display="none";
			}
		}
	}
	xmlstorehttp.send(null);
}

function callOnload(skuid){
	var xmlstorehttp1=GetStoreXmlHttpObject();
	if (xmlstorehttp1==null){
		alert ("Your browser does not support AJAX!");
		return;
	}
	var storeurl="/uwps/UpdateList?gameCollectionType=Wish_List&actionType=checkgame";
	storeurl=storeurl+"&gameId="+skuid;
	xmlstorehttp1.open("POST",storeurl,true);
	document.getElementById("wishlistspan").innerHTML="<img src='"+getAssetPath()+"ajax-loaderbrowse.gif'/>";
	if(document.getElementById("gamelistspan")){
		if(document.getElementById("gamelistspan").innerHTML!=""){
			document.getElementById("gamelistspan").innerHTML="<img src='"+getAssetPath()+"ajax-loaderbrowse.gif'/>";
		}
	}
	xmlstorehttp1.onreadystatechange=function handleServerResponse(){  
	if(xmlstorehttp1.readyState==4){
		var response = xmlstorehttp1.responseText;
		var xmlobject = (new DOMParser()).parseFromString(response, "text/xml");
		var wishlist = xmlobject.getElementsByTagName('GameExist')[0].firstChild.nodeValue;
		var gamelist = xmlobject.getElementsByTagName('GameList')[0].firstChild.nodeValue;
		var released = xmlobject.getElementsByTagName('IsReleased')[0].firstChild.nodeValue;
		if(wishlist=="success"){
			document.getElementById("wishlistspan").innerHTML="Remove from Wish List";
			var objWishListGameCO = getChildAnchor('wishlistGame'); 
			if(objWishListGameCO!=null){                                 
				document.getElementById("wishlistGame").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/REMOVE_FROM_WISH_LIST');addToList('"+skuid+"',user);ClickOmniTrack(this,'event17','REMOVE_FROM_WISH_LIST');\" href=\"javascript:void(0);\"><span id=\"wishlistspan\">Remove from Wish List</span></a>";
			}
		}
		if(wishlist=="failure"){
			document.getElementById("wishlistGame").innerHTML ="<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/Addtowishlist');addToList('"+skuid+"',user);ClickOmniTrack(this,'event10','AddToWishList');\" href=\"javascript:void(0);\"><span id=\"wishlistspan\">Add to Wish List</span></a>";   
		}
		if(released=="success"){
			if(gamelist=="success"){
				document.getElementById("gamelistspan").innerHTML="Remove from My Games";
				var objMyGames = getChildAnchor('addgamediv'); 
				if(objMyGames!=null){ 
					document.getElementById("addgamediv").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/REMOVE_FROM_MY_GAMES');addToGames('"+skuid+"',user);ClickOmniTrack(this,'event17','REMOVE_FROM_MY_GAMES');\" href=\"javascript:void(0);\"><span id=\"gamelistspan\">Remove from My Games</span></a>";
				}
			}else{
				document.getElementById("addgamediv").innerHTML = "<a onclick=\"javascript:pageTracker._trackPageview('/CTR/GamesMedia/Games/Addtogames');addToGames('"+skuid+"',user);ClickOmniTrack(this,'event13','AddToGamesList');\" href=\"javascript:void(0);\"><span id=\"gamelistspan\">Add to My Games</span></a>";  
			}
		}else{
			document.getElementById("gamelistspan").style.display="none";
		}
	}
	}
	xmlstorehttp1.send(null);
}

//Update Ends

function isUserLoggedIn(){

var uagent = navigator.userAgent.toLowerCase();
if ((uagent.search('playstation 3') > -1)){
	return false;
}

var userinfo = readCookie("userinfo");
var s2sticket = readCookie("PSNS2STICKET");
var ticket = readCookie("TICKET"); 

	if((userinfo !='' && userinfo != 'null' ) && (s2sticket !='' && s2sticket != 'null' ) && (ticket !='' && ticket != 'null' )){
		return true;
	}
	else{
		return false;
	}
}
/*Omniture Code Function*/
function ClickWTB(obj,eventVal)

   {

      s.events=eventVal;

      s.linkTrackEvents=eventVal;
      
      s.linkTrackVars='events';
      
      

      s.tl(obj,'o','WTB');

   }
   
   	 var pageNameValHeader="";
   	    var szURL = document.URL;
		var ind = szURL.indexOf("=");            
        var splitPart = "";		 
		var indexOfQues = szURL.indexOf("?"); 	
		var indexforSearch = szURL.indexOf("/search/"); 
		var indexforgameList = szURL.indexOf("?type="); 
		var indexforcampaignSr = szURL.indexOf("?SR=");
		var indexforcampaignRef = szURL.indexOf("?ref=");
		var indexforcampaignEmc = szURL.indexOf("ATTR=PSU");
		var indexforonlinename = szURL.indexOf("?onlinename=");
		var indexforreturnUrl = szURL.indexOf("?returnURL=");
		var indexforredirectreason = szURL.indexOf("?redirectreason=");
		var indexforfeature = szURL.indexOf("?feature=");
		var indexforfeatureid = szURL.indexOf("?featureid=");
		var indexforvideoid = szURL.indexOf("?videoid=");
		var indexformeetjoemour=szURL.indexOf("meetjoemauer.html?");  				
		var indexformlbshow = szURL.indexOf("?overlayName=");
		var indexofsitemapPageName=szURL.indexOf("sitemap");
		var indexofsitemapCompainCMP=szURL.indexOf("?CMP");
		var indexofConsoletype=szURL.indexOf("?console");
		var indexofSortOrder=szURL.indexOf("?sortOrder");
		
		
				
		var doubleSlash="";
			 
	    if(ind != -1){
            var indPlus1 = ind + 1;
           //var indPlus3 = ind + 4;    
            var indPlus3 = szURL.length;       
            splitPart = szURL.substring(indPlus1,indPlus3);
            
            } 
		 
		 
		 if(indexOfQues != -1){
		 var toBReplaced = szURL.substring(indexOfQues,szURL.length);
		 szURL = szURL.replace(toBReplaced, "");		 
		 }
		 
		componentList = szURL.split('/');	
		var reqString = "";
		for(var j=componentList.length-3; j>0; j--) {
		if(reqString =="") {
		reqString = componentList[componentList.length-j];
		}
		else {
		reqString = reqString+"/"+componentList[componentList.length-j];
		}		
		}		
		var newList = reqString.split("/");		
		for(var i=newList.length; i>0; i--) {		
		}		
		var sectionName = "";
		var sectionProp6 = "";
		var sectionProp7 = "";
		var sectionProp8 = "";
		var sectionProp9 = "";
		var sectionProp56 = "";
		var pageNameVal = "";
		var pageType = "";
		var sectionProp21 = "";		
		if(newList.length !=null && newList.length >0 ){
			sectionName = newList[0];	
			sectionName=sectionName.toUpperCase();			
			if(newList[1] !=null){			
				sectionProp7 = newList[1];
				sectionProp7=sectionProp7.toUpperCase();
				pageNameVal = sectionName+"/"+sectionProp7 ;				
			}
				if(newList[2] !=null){
					sectionProp8 = newList[2];
					sectionProp8=sectionProp8.toUpperCase();
					pageNameVal = pageNameVal+"/"+sectionProp8 ;					
				}
					if(newList[3] !=null){
						sectionProp9 = newList[3];
						sectionProp9=sectionProp9.toUpperCase(); 
						pageNameVal = pageNameVal+"/"+sectionProp9 ;	 		
					}	
					
					if(newList[4] !=null){
						var temp = "";
						sectionProp56 = newList[4].toUpperCase();
						for (i=5 ; i<newList.length; i++ ){
						temp = newList[i].toUpperCase();
						sectionProp56 = sectionProp56 + "/" + temp 
						}
						pageNameVal = pageNameVal+"/"+sectionProp56 ;	 		
					}		
		}	 
			if(pageNameVal !=null){
				if(pageNameVal !=""){
					pageNameVal = "PS/"+pageNameVal;
				}
				else {
					pageNameVal = "PS";
				}	
			}
			else {
				pageNameVal = "PS";
			}			
			if(sectionProp7=="pagenotfound" || sectionName=="pagenotfound" || sectionProp8=="pagenotfound" || 
sectionProp9=="pagenotfound" || sectionProp6=="pagenotfound" ){
			pageType = "ERROR_PAGE";
			}			
			if(sectionProp7=="INDEX.HTM" || sectionName=="INDEX.HTML"){
				sectionName="PS";				
			}			
		
            pageNameVal=pageNameVal.replace("/INDEX.HTM", "");   
            if(pageNameVal.indexOf("#")!=-1){     
            pageNameVal=pageNameVal.substring(0,pageNameVal.indexOf("#"));          
            }else{
              pageNameVal=pageNameVal.replace("#", "");   
            }                                                      
            
            if(splitPart == null || splitPart == ""){
            pageNameVal = pageNameVal; 
                      
            }  
            else {                       		
            if(indexforSearch != -1 || indexforgameList!=-1 || indexforcampaignSr!=-1 || indexforcampaignRef!=-1 || indexforcampaignEmc!=-1 || indexforonlinename!=-1 || indexforreturnUrl!=-1 || indexforredirectreason!=-1 || indexforfeature!=-1 || indexforfeatureid!=-1 || indexforvideoid!=-1 || indexformeetjoemour!=-1 || indexformlbshow!=-1 || indexofsitemapCompainCMP!=-1 || indexofConsoletype!=-1 || indexofSortOrder!=-1)              
            pageNameVal = pageNameVal;            
            else             
            pageNameVal = pageNameVal+"/"+splitPart;  
            } 
                      
           if(pageNameVal.charAt(pageNameVal.length-1)=="/"){
                  pageNameVal=pageNameVal.substring(0,pageNameVal.length-1);
                  //pageNameVal=pageNameVal.replace(pageNameVal.charAt(pageNameVal.length-1), "");
                 }              						 
               doubleSlash=pageNameVal.indexOf("//"); 			 
            if(doubleSlash!= -1){
                 pageNameVal = pageNameVal.replace("//","/"); 	
             }   
            pageNameValHeader=pageNameVal.replace("#", ""); 	
		
   var prop18Val = "";
   
   function getPageName()
   {
     return pageNameValHeader;
   }
   function ClickOmniTrack(obj,eventVal,secName)

   {
   
   	
   try
   {
   		if(prop18Val !=""){
   		prop18Val = "/"+prop18Val;
   		}
      secName = secName+"/"+pageNameValHeader ;
      s.events=eventVal;

      s.linkTrackEvents=eventVal;
      
      eventValProp17 = eventVal;    
      
      s.linkTrackVars='events'; 
      
      s.pageName= secName;
      s.tl(obj,'o',secName); 
       }catch(error)
       {
      
       
       }
      
     
   }

/* For OmniExit Link  */
function ClickOmniTrackExit(obj,eventVal,secName)

   {
   
   	 
   try
   {
   		if(prop18Val !=""){
   		prop18Val = "/"+prop18Val;
   		}
      secName = secName+"/"+pageNameValHeader ;
     
      s.events=eventVal;

      s.linkTrackEvents=eventVal;
      
      eventValProp17 = eventVal;    
      
      s.linkTrackVars='events'; 
      
      s.pageName= secName;
      s.tl(obj,'e',secName); 
       }catch(error)
       {
             
       }
      
     
   }

   var pageNotFound = "";
   var titleName = "";
   var genreNameis = "";
   
   function ClickREOmni(obj,id,secName)
   {
     
   try
   {
     s.linkTrackVars='eVar33,prop41,prop43,products,events';
     s.linkTrackEvents='event42';
     secName=secName.replace(/\u2122/g,'').replace(/\u00AE/g,'').replace(/:/g,'').replace(/;/g,'').replace(/-/g,'').replace(/=/g,'').replace(/\\/g,'').replace(/\//g,'').replace(/\"/g,'').replace(/\'/g,'').replace(/\u2019/g,'');
     s.eVar33= secName;
     s.prop41= secName;
     s.prop43= pageNameValHeader;
     s.products= ';'+id;
     s.events='event42';
     s.tl(obj,'o',secName);
   }
   catch(error)
   {  
   } 
   
   }
   
   function ClickhistoryOmni(obj,eventnumber,linkUrl,secName) {
		
		try {
		secName = secName+"/"+pageNameValHeader ;
		s.linkTrackVars = 'eVar20,events,pageName';
		s.linkTrackEvents = eventnumber;
		s.eVar20 = linkUrl;
		s.events = eventnumber;
		s.pageName = secName; 
		s.tl(obj,'o',secName);
		} catch(error) {
			
	 	} 
	 }
	 
   function ClickREMoviesOmni(obj,id,secName)
   {
     
   try
   {
     s.linkTrackVars='eVar40,prop44,prop45,products,events';
     s.linkTrackEvents='event43';
     secName=secName.replace(/\u2122/g,'').replace(/\u00AE/g,'').replace(/:/g,'').replace(/;/g,'').replace(/-/g,'').replace(/=/g,'').replace(/\\/g,'').replace(/\'/g,'').replace(/\u2019/g,'').replace(/\//g,'').replace(/\"/g,'');
     s.eVar40= secName;
     s.prop44= secName;
     s.prop45= pageNameValHeader;
     s.products= ';'+id;
     s.events='event43';
     s.tl(obj,'o',secName);
   }
   catch(error)
   {  
   } 
   
   }
   
function echeck(str,emailbox){	
	var strObject=document.forms["emailForm"];
	var at="@";
	var dot=".";
	var under="_";
	var hyphen="-";
	var count=0;
	var El=str.length;
	var firstelement=str.charAt(0);	
	var lastelement=str.charAt(El-1);
	var fat=str.indexOf(at);			
	var fdot=str.indexOf(dot);	
	var funder=str.indexOf(under);		
	var fhyphen=str.indexOf(hyphen);
	var lat=str.lastIndexOf(at);	
	var ldot=str.lastIndexOf(dot);	
	var lunder=str.lastIndexOf(under);		
	var lhyphen=str.lastIndexOf(hyphen);
	
	if (!isNaN(firstelement)||firstelement=="@"||firstelement=="."||firstelement=="_"||firstelement=="-"){
		return false;
	}
	else if (!isNaN(lastelement)||lastelement=="@"||lastelement=="."||lastelement=="_"||lastelement=="-"){		
		strObject.value = "";
		return false;
	}
	else if (fat== -1 || fdot== -1){		
		strObject.value = "";
		return false;
	}
	else if (fat!==lat|| str.charAt(fdot+1)=="." || str.charAt(fhyphen+1)=="-" || str.charAt(funder+1)=="_"){
		strObject.value = "";
		return false;
	}
	else if (str.charAt(fat-1)=="."||str.charAt(fat-1)=="_"||str.charAt(fat-1)=="-" || str.charAt(fat+1)=="."||str.charAt(fat+1)=="_"||str.charAt(fat+1)=="-"){		
		strObject.value = "";
		return false;
	}
	else if (str.charAt(fat+2)=="."||str.charAt(fat+2)=="_"||str.charAt(fat+2)=="-"){		
		strObject.value = "";		
		return false;
	}
	else if (ldot ==El || ldot==El-1 || ldot<El-4){		
		strObject.value = "";
		return false;
	}
	else if (str.lastIndexOf(dot)+3 > str.length){
		strObject.value = "";		
		return false;
	}
	else if (str.lastIndexOf(dot)+3 > str.length){
		strObject.value = "";
		return false;
	}
	else{		
		for (i=lat+1; i<El; i++){
			if(!isNaN(str.charAt(i))||str.charAt(i)=="-"||str.charAt(i)=="_" ||str.charAt(i)=="." && str.charAt(i+1)=="."){
				strObject.value = "";
				return false;
			}
			else{
				if(str.charAt(i)=="."){
					count++;
					if(count==3){
						strObject.value = "";
						return false;
					}
				}
			}
		}
		for(i=0; i<lat; i++){
			if(str.charAt(i)=="." && str.charAt(i+1)=="-"||str.charAt(i)=="." && str.charAt(i+1)=="_"||str.charAt(i)=="." && str.charAt(i+1)=="."){
				strObject.value = "";
				return false;
			}
			else if(str.charAt(i)=="-" && str.charAt(i+1)=="."||str.charAt(i)=="-" && str.charAt(i+1)=="_"||str.charAt(i)=="-" && str.charAt(i+1)=="-"){
				strObject.value = "";				
				return false;
			}
			else if(str.charAt(i)=="_" && str.charAt(i+1)=="."||str.charAt(i)=="_" && str.charAt(i+1)=="-"||str.charAt(i)=="_" && str.charAt(i+1)=="_"){
				strObject.value = "";				
				return false;
			}
			
		}
	return true;					
	}
}

/* function setTitle(){
var title=document.title;
//document.write(title);
document.getElementById('title1').value = title;

}*/


	function checkMultipleEmail(c_s_list,seperator){
	var p=/[ !#~`$^%&*()+=?;{}":-]/;
	//var p1=/[ !#~`$^%&*()+=?,{}":-;]/;
    if(c_s_list.lastIndexOf(",")+1==c_s_list.length)
        c_s_list=c_s_list.substring(0,c_s_list.length-1);
    var arr = c_s_list.split(seperator); 

    for (var i = 0, l = arr.length; i < l; i++){ 
        var str = trimString(arr[i]); 
    if(!emailIdCheckOne(str))
	return false;                  
    }
	if(p.test(document.getElementById('frd').value)) {
		return false;
	}
	/*else if(p1.test(document.getElementById('Uremail').value)) {
		return false;
	}*/
    return true;
	}
	function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

function setURL(){
	var url=window.location;	
	document.getElementById('url').value = url;
}
function sform(){	
	setTitle();	
	setURL();	
	if(checkFrndEmail() == true && checkUrEmail() == true && checkName() == true){	
		var str3=document.getElementById("sname").value;
		var str1=document.getElementById("Uremail").value;
		var fr = document.getElementById("frd").value;	
		var ti = document.getElementById("title1").value;
		var ur = document.getElementById("url").value;
		var param = "frd="+fr+"&Uremail="+str1+"&sname="+str3+"&title1="+ti+"&url="+ur;
	
	
			$.ajax({
                type: "POST",
                url: "/uwps/em",
                data: param,
                cache: true,
                success: function(data){            
					document.getElementById("shareDetails_msg").style.display = "block";
					document.getElementById("emailMsg").innerHTML = data;
					document.getElementById("shareDetails").style.display = "none";
					document.getElementById("loadingsharethis").style.display = "none";
				}
                });
				document.getElementById("frd").value="";
				document.getElementById("Uremail").value="";
				document.getElementById("sname").value="";
				document.getElementById("loadingsharethis").style.display = "block";
				document.getElementById("divCont1").style.display = "none";
				document.getElementById("divCont2").style.display = "block";
	}
	}	


$(document).ready(function(){
  $("#backtoshare").click(function(){
  $("#shareDetails_msg").hide();
  $("#shareDetails").show();
  $("#divCont1").show();
  $("#divCont2").hide();
  });

  $("#overlayShare").click(function(){
  $("#black_overlay").show();
              $("#shareDetails").show();
               $("#shareDetails_msg").hide();
          $("#divCont1").show();
                
  });
});

	
function checkFrndEmail(){
	var str=document.getElementById("frd").value;
	
	var b = checkInputField(str);
	var b0=checkMultipleEmail(str,",");
	if(str.lastIndexOf(",")+1==str.length)
        str=str.substring(0,str.length-1);
    var arr = str.split(","); 
    if(arr.length>5) {
         document.getElementById('bdiv1').style.display="block";
         document.getElementById('bdiv1').innerHTML="Please check the number of email addresses(only 5 allowed at a time)";
         document.frm.frd.focus();
         return false;
    }
	
		document.getElementById('bdiv1').style.display="block";
		if(b0==false){
		     document.getElementById('bdiv1').innerHTML="Please check your Friend's Email";
		     document.frm.frd.focus();
		     return false;
		}else if(b==false){
		    document.getElementById('bdiv1').innerHTML="Please check your Friend's Email Special Characters are not allowed";
		    document.frm.frd.focus();
		    return false;
		}else{
		    document.getElementById('bdiv1').style.display="none";
		    return true;
	}
	 
}
function checkUrEmail(){
	var str1=document.getElementById("Uremail").value;
	var b1 = checkInputField(str1);
	
	var b00=isValidEmailAddress(str1);
	
	if(b00!=true || b1!=true){
		if(b00==false){
		document.getElementById('bdiv2').innerHTML="Please check Your Email";
		document.frm.Uremail.focus();}
		else if(b1==false){		
		document.getElementById('bdiv2').innerHTML="Please check Your Email Special Characters are not allowed";
		document.frm.Uremail.focus();}
		document.getElementById('bdiv2').style.display="block";
	}
	
	else{
		document.getElementById('bdiv2').style.display="none";
		return true;

	}
	
}
function checkName(){
	
	var str3=document.getElementById("sname").value;
	return checkForProfanity(str3);
	
}

function checkInputField(str){
	if(str.indexOf('<')!=-1){
		//alert("Special characters are not allowed");
		return false;
	}
	else if(str.indexOf('>')!=-1){
		//alert("Special characters are not allowed");
		return false;
	}
	else{
	//document.getElementById('bdiv1').style.display = "none";
	return true;
	}
}

function nValidate(){

	var regexNum = /\d/;
	var p=/[@!#~`$^%&*()+=?.,{}":;_-]/;
var regexLetter = /^[a-zA-z]/;
//var punct= /\! ' # S % & ' ( ) * + , - . / : ; < = > ? @ [ / ] ^ _ { | } ~/;

if(regexNum.test(document.getElementById('sname').value) || !regexLetter.test(document.getElementById('sname').value) || p.test(document.getElementById('sname').value)) {

return false;
}
return true;
}


function checkForProfanity(temp) {
var k = 20;
var isProfane = new makeArray(k);
var word = new makeArray(k);
temp = temp.toLowerCase();
word[1] = "shit";
word[2] = "nerd";
word[3] = "stupid";
word[4] = "ass";
word[5] = "cunt";
word[6] = "suck";
word[7] = "pussy";
word[8] = "cock";
word[9] = "cum";
word[10] = "penis";
word[11] = "nuts";
word[12] = "dick";
word[13] = "fuck";
word[14] = "ass";
word[15] = "fag";
word[16] = "idiot";
word[17] = "asshole";
word[18] = "bitch";
word[19] = "gimp";
word[20] = "freak";
for (var j = 1; j <= k; j++) {
isProfane[j] = temp.indexOf(word[j]);
}
for (var j = 1; j <= k; j++) {
   if (isProfane[j] != -1) {  
      document.getElementById('bdiv3').innerHTML="Please refrain from using the word \'"+word[j]+"\'.";
       alert(document.getElementById('bdiv3').innerHTML);
	  document.getElementById("sname").value = "";
      j = k + 1;
      document.getElementById("sname").focus();
      return false;
       }
  
}
return true;
}
function makeArray(n) {
   this.length = n
   for (var i = 1; i<=n; i++) {
       this[i] = new String();
   }
   return this
}

function redirectDeeplinkingUrl(urllink){
	var deeplinkname=urllink.substr(urllink.indexOf('#'),urllink.length);
	var changeUrl=urllink.substr(0,urllink.indexOf('#'));
	if(window.location.href.indexOf("usplaystation")==-1){
		if(changeUrl.indexOf("index.htm") != -1)
		{
			changeUrl= changeUrl.replace("index.htm" , "");
		}
	}
	var newurl='';
	if(deeplinkname!=''){
		var checkUrl=window.location.href;	
		newurl=changeUrl+"?feature="+deeplinkname;			
 		if(checkUrl.indexOf('/usplaystation/')!=-1){  
 			newurl="/usplaystation"+newurl;	  	 																			
			window.location=location.protocol+"//"+window.location.host+newurl;
		}
		else{
			window.location=location.protocol+"//"+window.location.host+newurl;
		}			
	}	
}
function forwardLink(linkForward){
	window.location = getBaseURL()+linkForward;
}	

	
function restoreDownloadCookie(productType,storeProductId){
	var cookieValue=readCookie('DownloadToSystem');
	if(cookieValue)
	{
		if(cookieValue == 'Yes')
		{
			document.getElementById("mediaclass").style.display="none";
			document.getElementById("black_overlay1").style.display="none";
		}
		else if(cookieValue == 'No')
		{
			document.getElementById("mediaclass").style.display="block";
			document.getElementById("black_overlay1").style.display="block";
		}
	}
	else
	{
		showMediaGo();
		
	}
}
function cookieDownSystemValue(valueSystem,productStoreId,productType){

    if(valueSystem=="Yes"){  
        document.getElementById("mediaclass").style.display="none";
		document.getElementById("black_overlay1").style.display="none";		  
		var cookieDownload=readCookie('DownloadToSystem');	
		if(cookieDownload){
			overwriteCookie('DownloadToSystem',valueSystem);
		}
		else{	
			createCookie('DownloadToSystem',valueSystem);
			window.location='psns:browse?'+productType+'='+productStoreId;					
		}
	}	
}
/*function checkCookiesDownload(storeProductId,productType){
    var cokiesCheck=readCookie("DownloadToSystem");   
    if(cokiesCheck=="Yes"){            
            document.getElementById("mediaclass").style.display="none";
			document.getElementById("black_overlay1").style.display="none"; 
			window.location ='\psns:browse?'+productType+'='+storeProductId; 									
    }else{
     showMediaGo();
     }
}*/

function checkCookiesDownload(storeProductId,productType){

var bIsPS3 = navigator.userAgent.toLowerCase().indexOf('playstation') != -1;
if (bIsPS3.toString()=="true")
{var cokiesCheck=readCookie("DownloadToSystem");   
    if(cokiesCheck=="Yes")
	{            
            document.getElementById("mediaclass").style.display="none";
			document.getElementById("black_overlay1").style.display="none"; 
			window.location ='\psns:browse?'+productType+'='+storeProductId; 									
    }else{
     showMediaGo();
     }
	
}

	else
	
	{ url="http://p0.dl.playstation.net/p0/psns/psnschk.htm?a=psns%3Abrowse%3F"+productType+"%3D"+storeProductId;
	 window.open(url);
	}



	
}
function openSystemBuyNowOverlay(skuId)
{
		

               var url=document.location.href;
                if(url.indexOf('?')!= -1)
                {
                    if(url.indexOf('=')!= -1)
                    {
                        var urlParam=url.split('?')[1].split('=')[0];
                        var urlValues=url.split('?')[1].split('=')[1].replace('#',''); 
                        if(urlValues=="ci" && urlParam == "retailerOverlay")
                        {
                       		floodLightShow = "FloodLightShow2";
                        	
                            openCIOverlay(skuId, '2732');
                            
                           
                        }
                    }
                }
 }
 
  function openGameBuyNowOverlay()
		 {
					 
					var ctaCheck = document.getElementById("buyNowText").innerHTML;
					if(ctaCheck != "")
					{
   							var url=document.location.href;
   							if(url.indexOf('?')!= -1)
   							{
   	  							if(url.indexOf('=')!= -1)
   	  							{
   	  								var urlParam=url.split('?')[1].split('=')[0];
   	  							
        							var urlValues=url.split('?')[1].split('=')[1].replace('#',''); 
           							if(urlValues=="ci" && urlParam == "retailerOverlay")
           							{
           								openCIOverlay(gameSKUId, '2732');
           								
  	       							}
  	      						}
  	    					}
  	    			}
  	    	
		 }





/*this function use in flash*/
function openShareOverlay(){
	document.getElementById("shareDetails").style.display="block";
	document.getElementById("shareDetails_msg").style.display="none";
	document.getElementById("divCont1").style.display="block";
	$('.share-this').toggle();
}

/* Code for Age Gate Redirection from Game Detail Page */
function redirectAgeGate(currentGameESRB,isAgeGated)
{ 
var check=isUserAllowedAgeGate();

if(isAgeGateRated(currentGameESRB ,isAgeGated) && check=="false")
{

	window.location=location.protocol + "//"+ window.location.host + globalSiteName+"agegate/index.htm";
}
else if(isAgeGateRated(currentGameESRB,isAgeGated) && check=="nc")
{

	overwriteCookie("ageGateReturnURL",window.location.toString());
	window.location=location.protocol + "//"+ window.location.host + globalSiteName+"agegate/index.htm";
}
}

function getUserRegistered(val){ 
	var value = val;	
	var serverName=window.location.host;
	
    var servletURL=window.location.protocol+"//"+serverName+"/uwps/UserRegisterJoinNow"; 		
    var status=false;
    $.ajax({
    type: "POST",
    url: servletURL,   
    async:   true,
    success: function(result){        
    }
    });     
}

function getTitleValidate(objectValue){
if(objectValue.indexOf("<sup>&reg;")!=-1){
 objectValue=objectValue.replace("<sup>&reg;", "<sup>&reg;</sup>");
 return objectValue;
 }else if(objectValue.indexOf("<sup>")!=-1){
 objectValue=objectValue.replace("<sup>", "<sup>&reg;</sup>");
 return objectValue;
 }else if(objectValue.indexOf("<span class='registeredClass'>")!=-1){
 objectValue=objectValue.replace("<span class='registeredClass'>", "<span class='registeredClass'>&reg;</sup>");
 return objectValue;
 }else{
 return objectValue; 
 }
}
function deleteCookie(name){
	var cookie_date = new Date();  // current date & time
	cookie_date.setTime(cookie_date.getTime() - 10);
	document.cookie = name += "=; expires=" + cookie_date.toGMTString()+"; path=/; domain=.us.playstation.com";
}

function displayblock(platform,section,sId){
	
	var consoleType=platform;		

	if((platform == "PSP" || platform == "psp") && (section=="movie" || section=="season") ){					
		consoleType = "psp";				
	}else if((platform == "PSP" || platform == "psp") && section=="game"){					
		consoleType = "pspgo,psp3000";				
	}else if((platform == "PSP" || platform == "psp") && section=="demo"){					
		consoleType = "pspgo,psp3000";				
	}else if((platform == "PSP" || platform == "psp") && section=="addon"){					
		consoleType = "pspgo,psp3000";				
	}else if((platform == "PSP" || platform == "psp") && section=="exclusivegame"){					
		consoleType = "pspgo,psp3000";				
	}else if((platform == "PSP" || platform == "psp") && section=="greatesthits"){					
		consoleType = "pspgo,psp3000";				
	}
	var quality="";
	if(platform.indexOf("own")!=-1 || platform.indexOf("Rent")!=-1 || platform.indexOf("HD")!=-1){
		section="movieownrenthd";
		consoleType="";
		if(platform.indexOf("-")!=-1){
			consoleType=platform.substring(0,3);
		}	
		if(platform.indexOf("own")!=-1){
		quality="sdown,hdown";		
		}
		if(platform.indexOf("Rent")!=-1){
		quality="sdrent,hdrent";		
		}
		if(platform.indexOf("HD")!=-1){
		quality="hdrent,hdown";
		}	
	}	
	if(section=="game"){
		if(sId !=null && sId != undefined && sId !=''){
			
			document.getElementById(sId).href="/uwps/BrowseGames?console="+consoleType+"&beginsWith=Any";
		} else {
			$(".footer a.more").attr("href","/uwps/BrowseGames?console="+consoleType+"&beginsWith=Any");					
		}		
			//document.getElementById('moreHyperLink').href="/uwps/BrowseGames?console="+consoleType+"&beginsWith=Any";	
		}				
	else if(section=="greatesthits"){
		if(sId !=null && sId != undefined && sId !=''){
			
			document.getElementById(sId).href="/uwps/BrowseGames?console="+consoleType+"&downloadableContent=GreatestHits"+"&beginsWith=Any";
		} else {
			$(".footer a.more").attr("href","/uwps/BrowseGames?console="+consoleType+"&downloadableContent=GreatestHits"+"&beginsWith=Any");										
		//document.getElementById('moreHyperLink').href="/uwps/BrowseGames?console="+consoleType+"&downloadableContent=GreatestHits"+"&beginsWith=Any";
		}
	}
	else if(section=="exclusivegame" && consoleType!=''){	
		if(sId !=null && sId != undefined && sId !=''){
			document.getElementById(sId).href="/uwps/BrowseGames?console="+consoleType+"&downloadableContent=PSoneClassics&beginsWith=Any";	
		} else {
		$(".footer a.more").attr("href","/uwps/BrowseGames?console="+consoleType+"&downloadableContent=PSoneClassics&beginsWith=Any");					
		//document.getElementById('moreHyperLink').href="/uwps/BrowseGames?console="+consoleType+"&downloadableContent=PSoneClassics&beginsWith=Any";	
		}
	}	
	
	else if(section=="exclusivegame" && consoleType==''){	
		if(sId !=null && sId != undefined && sId !=''){
			document.getElementById(sId).href="/uwps/BrowseGames?&downloadableContent=PSoneClassics&beginsWith=Any";	
		} else {
			$(".footer a.more").attr("href","/uwps/BrowseGames?&downloadableContent=PSoneClassics&beginsWith=Any");										
		//document.getElementById('moreHyperLink').href="/uwps/BrowseGames?&downloadableContent=PSoneClassics&beginsWith=Any";	
		}
	}	
				
	else if(section=="addon"){	
		if(sId !=null && sId != undefined && sId !=''){
			
			document.getElementById(sId).href="/uwps/BrowseGames?console="+consoleType+"&downloadableContent=Add_ons"+"&beginsWith=Any";	
		} else {	
		$(".footer a.more").attr("href","/uwps/BrowseGames?console="+consoleType+"&downloadableContent=Add_ons"+"&beginsWith=Any");													
		//document.getElementById('moreHyperLink').href="/uwps/BrowseGames?console="+consoleType+"&downloadableContent=Add_ons"+"&beginsWith=Any";	
		}
	}
	else if(section=="demo"){		
		if(sId !=null && sId != undefined && sId !=''){		
			
			document.getElementById(sId).href="/uwps/BrowseGames?console="+consoleType+"&downloadableContent=GameDemos"+"&beginsWith=Any";
		} else {
			document.getElementById('moreHyperLink').href="/uwps/BrowseGames?console="+consoleType+"&downloadableContent=GameDemos"+"&beginsWith=Any";
		}
	}
	else if(section=="PSoneClassics") 
	{		
		if(sId !=null && sId != undefined && sId !=''){	
		
			document.getElementById(sId).href="/uwps/BrowseGames?console=ps3&downloadableContent=PSoneClassics&beginsWith=Any";
		} else {			
			document.getElementById('moreHyperLink').href="/uwps/BrowseGames?console=ps3&downloadableContent=PSoneClassics&beginsWith=Any";
		}
	}
	else if(section=="movieownrenthd")
	{
	   if(consoleType!='')
		document.getElementById('moreHyperLink').href="/uwps/SearchMovies?category=movies&console="+consoleType+"&quality="+quality+"&beginsWith=Any";			
	   else
	   document.getElementById('moreHyperLink').href="/uwps/SearchMovies?category=movies&quality="+quality+"&beginsWith=Any";			
	}		
	else if(section=="movie"){
	if(sId !=null && sId != undefined && sId !=''){	
		//document.getElementById(sId).href="/uwps/SearchMovies?category=movies&console="+consoleType+"&beginsWith=Any";		
	
	 if(consoleType!='')
	// $(".footer a.more").attr("href","/uwps/SearchMovies?category=movies&console="+consoleType+"&beginsWith=Any");													
	      document.getElementById(sId).href="/uwps/SearchMovies?category=movies&console="+consoleType+"&beginsWith=Any";		
      else
      	//$(".footer a.more").attr("href","/uwps/SearchMovies?category=movies&beginsWith=Any");	
      	 document.getElementById(sId).href="/uwps/SearchMovies?category=movies&beginsWith=Any";
      } else {
      	 if(consoleType!='')
		 $(".footer a.more").attr("href","/uwps/SearchMovies?category=movies&console="+consoleType+"&beginsWith=Any");													
	      //document.getElementById('moreHyperLink').href="/uwps/SearchMovies?category=movies&console="+consoleType+"&beginsWith=Any";		
      else
      $(".footer a.more").attr("href","/uwps/SearchMovies?category=movies&beginsWith=Any");	
      }												
      // document.getElementById('moreHyperLink').href="/uwps/SearchMovies?category=movies&beginsWith=Any";	
	}			
	else if(section=="newreleasemovie"){
		document.getElementById('moreHyperLink').href="/uwps/SearchMovies?category=movies&console="+consoleType+"&MaxReleaseDateValue=3&MinReleaseDateValue=4&beginsWith=Any";				
	}else if(section=="newreleasegame"){
		document.getElementById('moreHyperLink').href="/uwps/BrowseGames?MaxReleaseDateValue=3&MinReleaseDateValue=4&beginsWith=Any";				
	}						
	else if(section=="season"){   
		if(sId !=null && sId != undefined && sId !=''){	   
	    if(consoleType=='')
		document.getElementById(sId).href="/uwps/SearchMovies?beginsWith=Any&category=tvseasonm";	
	    else
		document.getElementById(sId).href="/uwps/SearchMovies?beginsWith=Any&category=tvseasonm&console="+consoleType;				
		} else {
		  if(consoleType=='')
		document.getElementById('moreHyperLink').href="/uwps/SearchMovies?beginsWith=Any&category=tvseasonm";	
	    else
		document.getElementById('moreHyperLink').href="/uwps/SearchMovies?beginsWith=Any&category=tvseasonm&console="+consoleType;
	   }
	   }
	else{
		document.getElementById('moreHyperLink').href="javascript:redirectMoreLinks();";
	}
}




function displayblockSeasonAddon(platform,section,genre){

 if(section=="season"){

		document.getElementById('moreHyperLink').href="/uwps/SearchMovies?category=tvseasonm&genre="+genre+"&beginsWith=Any";				
	}

}
// L&R START

function notifyPageChange(){
	//alert("notifyPageChange");


	if(parent.document.getElementById('innerPageConfirmFlag') && parent.document.getElementById('innerPageConfirmFlag').value=="true"){
		return;
	}

	if(parent.document.getElementById('confirmDiv') && parent.document.getElementById('confirmDiv').style.display=="block"){
		parent.document.getElementById('confirmDiv').style.display="none";
	}

	if(parent.document.getElementById("validTotalHours")){
		if(parent.document.getElementById("validTotalHours").value=="false") {

			if(parent.document.getElementById("alertFlagHidden").value=="true"){
				//e.preventDefault();
				return ;
			}

			alert('Total weekly hours should be less than or equal to 168');
			//e.preventDefault();
			return ;
		} 
	}

	if(document.getElementById("setEditFlag")){
		if(parent.document.getElementById("setEditFlag").value=="true"){
			
			parent.document.getElementById('confirmDiv').style.display="block";
			parent.document.getElementById('confirmDiv').style.top="10%";
		}
		else
			getMovieName("navswf").notifyPageChangeComplete();
			
	}else{
		getMovieName("navswf").notifyPageChangeComplete();
		
	}
}


function notifyPageChange1(){
	//	alert("notifyPageChange 1 ");


	if(parent.document.getElementById('innerPageConfirmFlag') && parent.document.getElementById('innerPageConfirmFlag').value=="true"){
		return;
	}

	if(parent.document.getElementById('confirmDiv') && parent.document.getElementById('confirmDiv').style.display=="block"){
		parent.document.getElementById('confirmDiv').style.display="none";
	}

	if(document.getElementById("setEditFlag")){
		if(parent.document.getElementById("setEditFlag").value=="true"){

			parent.document.getElementById('confirmDiv').style.display="block";
			if(isLinkClicked){
				parent.document.getElementById('confirmDiv').style.top="10%";
				isLinkClicked = false;	
			}
			else{
				parent.document.getElementById('confirmDiv').style.top="90%";
			}
		}
		else
			getMovieName("navswf").notifyPageChangeComplete();
			
	}else{
		getMovieName("navswf").notifyPageChangeComplete();
		
	}
}




function notifyProfileChange(){
	//	alert("notifyProfileChange prof ");

	if(parent.document.getElementById('innerPageConfirmFlag') && parent.document.getElementById('innerPageConfirmFlag').value=="true"){
		return;
	}

	if(parent.document.getElementById('confirmDiv') && parent.document.getElementById('confirmDiv').style.display=="block"){
		parent.document.getElementById('confirmDiv').style.display="none";
	}

	if(parent.document.getElementById("validTotalHours")){
		if(parent.document.getElementById("validTotalHours").value=="false") {

			if(parent.document.getElementById("alertFlagHidden").value=="true"){
				//e.preventDefault();
				return ;
			}

			alert('Total weekly hours should be less than or equal to 168');
			//e.preventDefault();
			return ;
		} 
	}

	if(document.getElementById("setEditFlag")){
		if(parent.document.getElementById("setEditFlag").value=="true"){
		
			
			parent.document.getElementById('topNavFlag').value="true";
			parent.document.getElementById('confirmDiv').style.display="block";		
			parent.document.getElementById('confirmDiv').style.top="10%";
						
		}
		else{
			getMovieName("profile_login").notifyPageChangeComplete();
			
		}
	}
	else{
		getMovieName("profile_login").notifyPageChangeComplete();
		
	} 
}
// L&R END

//Omniture Code Starts for Fourm Buttons
function ClickforumOmni(obj,Forumurl,secName){
	try
	{
		secName = secName+"/"+pageNameValHeader ;
		s.linkTrackVars='eVar37,events';
		s.linkTrackEvents='event61';
		s.eVar37= Forumurl;
		s.events='event61';
		s.tl(obj,'o',secName);
	}
	catch(error)
	{ } 
}
//Omniture Code Ends for Fourm Buttons

//Recent Browsing History
function getImgBaseUrl()
{
	if(window.location.protocol.indexOf('https')!=-1 )
		var imgBaseURL=window.location.protocol+"//"+window.location.host+ucmroot;
	else if((hostName.indexOf("stagea.us.playstation.com")!=-1) || (hostName.indexOf("stage.us.playstation.com")!=-1) || (hostName.indexOf("pre-prd.us.playstation.com")!=-1))
		imgBaseURL= "http://stage-webassets.scea.com"+ucmroot;
	else if((hostName.indexOf("us.playstation.com")!=-1) || (hostName.indexOf("qa.playstation.com")!=-1))
		imgBaseURL= "http://webassets.scea.com"+ucmroot;
	else
		imgBaseURL=ucmroot;
		
		return imgBaseURL;
}

function readMetaTags(productType) {

	var data1 = "";
	
	if (productType=="Game") {			
		data1 = readGamesMetaTags();
	}
	else if (productType == "Movie" || productType == "TV Show" || productType == "Season")	{
		data1 = readMoviesTVShowsMetaTags();
	}
	else if (productType == "System") {
		data1 = readSystemMetaTags();
	}
	else if (productType == "Accessory") {
		data1= readAccessoriesMetaTags();
	} 
	else if(productType == "Add-on") {
	
		data1 =  readAddOnsMetaTags();
	}
	else if(productType == "Qore Season" || productType == "Pulse Season" ||productType == "Pulse Episode" || productType == "Qore Episode" ) {
		
		data1 = readPulseQoreMetaTags();		
	}
	else if(productType == "The Tester Episode" || productType == "TheTester Season") {
		data1 = readTesterMetaTags();
	}
	return data1;
}

//make first letter caps
function upper_case(string_char){
var first_capital_letter=string_char.charAt(0).toUpperCase() + string_char.substr(1);
return first_capital_letter;
} 

function getDesc(desc) {
	if (desc.length >= 150) {
	desc = desc.substring(0, 150);
// find last space
	lastSpacePos = desc.lastIndexOf(" ");
	desc = desc.substring(0, lastSpacePos) + "...";
	
		
	}
	return desc;
}
//This function replaces special character with html entity
function replaceAll(txt, replace, with_this) {
  return txt.replace(new RegExp(replace, 'g'),with_this);
}
function readTesterMetaTags() {
	var genre =  $('meta[name=genre]').attr("content"); 
	var platform =  $('meta[name=tvshowPlatform]').attr("content"); 
	var releaseDate =  $('meta[name=releasedDate]').attr("content"); 
	var title =  escape($('meta[name=description]').attr("content").replace("The Tester ",""));	
	var description = escape(getDesc($('meta[name=ShortDescription]').attr("content")));
	var imageUrl =  $('meta[name=ImageUrl]').attr("content"); 
	var rating =  $('meta[name=MPAARating]').attr("content"); 
	
	return "genre="+genre+"&platform="+platform+"&releasedDate="+releaseDate+"&title="+title+"&description="+description+"&rating="+rating+"&imageUrl="+imageUrl;
}
function readPulseQoreMetaTags() {
	var genre =  $('meta[name=genre]').attr("content"); 
	var platform =  $('meta[name=tvshowPlatform]').attr("content"); 
	var releaseDate =  $('meta[name=releasedDate]').attr("content"); 
	var title =  escape($('meta[name=videoTitle]').attr("content"));
	var description = escape(getDesc($('meta[name=ShortDescription]').attr("content")));
	var imageUrl =  $('meta[name=ImageUrl]').attr("content"); 
	var rating =  $('meta[name=MPAARating]').attr("content"); 
	
	return "genre="+genre+"&platform="+platform+"&releasedDate="+releaseDate+"&title="+title+"&description="+description+"&rating="+rating+"&imageUrl="+imageUrl;
}
function readGamesMetaTags() {
	var genre =  $('meta[name=genre]').attr("content"); 
	var platform =  $('meta[name=gamePlatform]').attr("content"); 
	var title =  escape($('meta[name=gameTitle]').attr("content"));	
	var description = escape(getDesc($('meta[name=gameLongDescription]').attr("content")));
	var releaseDate =  $('meta[name=releasedDate]').attr("content"); 
	var imageUrl =  $('meta[name=gameImageUrl]').attr("content"); 
	var rating =  $('meta[name=gameRating]').attr("content"); 
	
	return "genre="+genre+"&platform="+platform+"&title="+title+"&releasedDate="+releaseDate+"&description="+description+"&rating="+rating+"&imageUrl="+imageUrl;
}
function readMoviesTVShowsMetaTags() {
	var genre =  $('meta[name=genre]').attr("content");
	var platform =  $('meta[name=tvshowPlatform]').attr("content"); 
	var title =  escape($('meta[name=videoTitle]').attr("content")); 	 
	var description =  escape(getDesc($('meta[name=videoDescription]').attr("content"))); 
	var imageUrl =  $('meta[name=videoImageUrl]').attr("content"); 
	var rating =  $('meta[name=MPAARating]').attr("content"); 
	var releaseDate =  $('meta[name=releasedDate]').attr("content");
	
	return "genre="+genre+"&platform="+platform+"&title="+title+"&description="+description+"&imageUrl="+imageUrl+"&rating="+rating+"&releasedDate="+releaseDate;
}

function readAddOnsMetaTags() {

	var genre =  $('meta[name=genre]').attr("content");
	var platform =  $('meta[name=addOnPlatform]').attr("content"); 
	var title =  escape($('meta[name=title]').attr("content")); 	
	var description =  escape(getDesc($('meta[name=addOnLongDescription]').attr("content"))); 
	var imageUrl =  $('meta[name=addOnImageUrl]').attr("content");	
	var rating =  upper_case($('meta[name=MPAARating]').attr("content")); 
	var releaseDate =  $('meta[name=releasedDate]').attr("content");

	return "genre="+genre+"&platform="+platform+"&title="+title+"&description="+description+"&imageUrl="+imageUrl+"&releasedDate="+releaseDate+"&rating="+rating;
}
function readSystemMetaTags() {

	var platform=  $('meta[name=systemPlatform]').attr("content"); 
	var title =  escape($('meta[name=articleTitle]').attr("content"));  
	var description =  escape(getDesc($('meta[name=articleDesc]').attr("content"))); 
	var imageUrl =  $('meta[name=ThumbImageUrl]').attr("content"); 
	var price =  $('meta[name=systemPrice]').attr("content"); 
	
	return "platform="+platform+"&title="+title+"&price="+price+"&imageUrl="+imageUrl+"&description="+description;
}
function readAccessoriesMetaTags() {

	var platform =  $('meta[name=accessoryPlatform]').attr("content"); 
	var title =  escape($('meta[name=articleTitle]').attr("content")); 
	var description =  escape(getDesc($('meta[name=articleDesc]').attr("content"))); 	
	var model =  $('meta[name=accessoryModel]').attr("content"); 
	var imageUrl =  $('meta[name=accessoryImageUrl]').attr("content"); 
	var manufacturer =  $('meta[name=accessoryManufacturer]').attr("content"); 
	
	return "platform="+platform+"&title="+title+"&model="+model+"&description="+description+"&imageUrl="+imageUrl+"&manufacturer="+manufacturer;
}
function browsingHistory() {
 if(enableRBH){
	document.getElementById('loader').style.display="";
 	var url=window.location.href; 
	var hostName=getBaseURL();
	var esrbRating =  $('meta[name=gameRating]').attr("content"); 
		
	if(esrbRating!=null) {
		
		esrbRating=esrbRating.toLowerCase();
		
	} else {
		
		esrbRating=0;
	}
	
	var skuid=getSKU_ID();
	var productType=getProductType();	
		
	if(esrbRating == 'mature' || esrbRating == 'adults only' 
		||  esrbRating == 't'|| esrbRating == 'rp-m') {
			    
    	var ageGateCross=readCookie("op.an");
           			
		if(ageGateCross == 'bD7YHksGRXI=') {
					
			recentHistory(skuid,productType);
		}
	} else {	

		recentHistory(skuid,productType);
	}
}
else {
	document.getElementById('loader').style.display="none";	
}
}

//This method Reads the SKU ID from the Detail page
function getSKU_ID() {
	var sku_id =  $('meta[name=SKU-ID]').attr("content"); 
	var productType = getProductType();

	if (sku_id == null
		|| (productType != 'Movie' && productType != 'Game'
		&& productType != 'Accessory' && productType != 'System'
		&& productType != 'Add-on' && productType != 'TV Show' && productType != 'Season'
		&& productType != 'Pulse Episode' && productType != 'Qore Episode' 
		&& productType != 'Pulse Season' && productType != 'Qore Season'
		&& productType != 'TheTester Season' && productType != 'The Tester Episode')) { 
		
		// set skuid to 0
		sku_id = 0;
	}
	if(sku_id.length > 30) {

		var d=(sku_id.length)-30;
		sku_id=sku_id.substring(d);
	}	
	return sku_id;
}
	
//This method Reads the ProductType from the Detail page
function getProductType() {

	var productType= $('meta[name=productType]').attr("content");

	if (productType == null
		|| (productType != 'Movie' && productType != 'Game'
		&& productType != 'Accessory' && productType != 'System'
		&& productType != 'Add-on' && productType != 'TV Show' && productType != 'Season' 
		&& productType != 'Pulse Episode' && productType != 'Qore Episode' 
		&& productType != 'Pulse Season' && productType != 'Qore Season'
		&& productType != 'TheTester Season' && productType != 'The Tester Episode')) { 
	
		// set productType to 0
		productType = 0;
	}
	return productType;
}
	
 // This method  makes a servlet request and get the response of the servlet 
function recentHistory(skuid,productType) {
	var data1 = readMetaTags(productType);
	var pscomUrl = "";
	
	if(skuid != 0) {
		var url = window.location.href; 				
		var baseUrl = getBaseURL();
		
		pscomUrl = url.replace(baseUrl, "").replace(".html","").replace(".htm","");	
		//pscomUrl = url.replace(window.location.protocol+'//'+window.location.host,"").replace(".html","").replace(".htm","");			
	}

   var xmlDoc='';
   
   $.ajax({
   
		type: "GET",
		cache: false,
		url: "/recentlyviewedhistory/ViewRecentHistory",
		dataType: "text/xml",
		data:data1+"&sku-id="+skuid+"&pscomUrl="+pscomUrl+"&productType="+productType,
		error: function(html){
		
		},
		 success: function(html){

	 		if(html!="") {
	
				if (window.DOMParser) {
	
					parser=new DOMParser();
					xmlDoc=parser.parseFromString(html,"text/xml");
			
				} else {
		
					xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
					xmlDoc.async="false";
					xmlDoc.loadXML(html); 
			
				}
			display(xmlDoc,skuid);	
			}
		}
	});
}

  // This function  displays the history details on Detail page
function display(xmlDoc,skuid1) {
		
        var item = xmlDoc.getElementsByTagName("product")[0].childNodes;
      	document.getElementById('loader').style.display="none";	
     
        if(item.length!=0) {
        		$(".seprator").css("display","block");        		
        		$("#main-box").addClass("border-history");
        	var item1 = xmlDoc.getElementsByTagName("historydata")[0].childNodes;        
        	var _title ="";
        	var _title1 ="";
        	var _thumbnail="";
        	var _pscomurl="";
			var _description="";
			var _skuid="";
			var _console="";
			var site="/usplaystation/";
			var appendHtmlExt = false;
    		var lastSpacePos = 0;
    		
    		if((window.location.toString()).indexOf(site)==-1){
        		site="/";
        		appendHtmlExt = true;
   		 	}	
				document.getElementById('main-box').innerHTML = "<div class='browser-history' id='browser-history' ><h2>Recent Browsing History</h2><div class='game-product' id='game-product'></div></div><div class='aroow-link' id='arrow-link'> <a href='"+site+"browsinghistory/index.htm' onclick=\"javascript:ClickhistoryOmni(this,'event72','','VIEW_YOUR_BROWSING_HISTORY');\" target='_top'>View Your Browsing History</a></div>";					  		
				
				
				for(var i=0;i<item.length;i++) {
					for(var j=0;j<item1.length;j++) {
						var txt = xmlDoc.documentElement.childNodes[i].childNodes[j].childNodes[0].nodeValue;			
						var txt1 = xmlDoc.documentElement.childNodes[i].childNodes[j].tagName;
	
						if(txt1 == 'title') {
							_title = unescape(txt);	
							_title1 = replaceAll(_title, "'" ,"&#x2019;");
							if(_title.length >= 40) {								
								_title = _title.substring(0, 40);
								// find last space
								lastSpacePos = _title.lastIndexOf(" ");
								_title = _title.substring(0, lastSpacePos) + "...";
								}	
							_title = replaceAll(_title, "'" ,"&#x2019;");	
						}
						else if(txt1 == 'thumbnail') {
							_thumbnail = txt;		
						} 
						else if(txt1 == 'pscomurl') {
							_pscomurl = appendHtmlExt ? txt + ".html" : txt;
						}
						else if(txt1=='description') {
							_description = unescape(txt);
							if(_description.length>=72){
								_description = _description.substring(0, 72);
								// find last space
								lastSpacePos = _description.lastIndexOf(" ");
								_description = _description.substring(0, lastSpacePos) + "...";
							}                  
						}else if(txt1=='console') {
                
							_console = txt;
                 
              		 	}
					}				
					setHistoryDetail(_title,_title1,_thumbnail,_pscomurl,_description,_console);							 
				}		
        }	
        													
}             

function setHistoryDetail(title,title1,thumbnail,pscomurl,description,console) {
	var hostName=getBaseURL();
	var thumbArea = document.getElementById("game-product").innerHTML
	thumbArea += "<div class='game-box' style='' id='game-box'><div class='game-img' id='game-img'>"
	
	if(window.location.pathname.toLowerCase().indexOf("/psvita/") != -1){
		thumbArea += "<div style='background-image:url(&#39;"+thumbnail+"&#39;);background-position:center top; background-repeat:no-repeat; display: inline-block; width: 115px; margin:18px auto 0;'><a href='"+hostName+pscomurl+"'><img alt='"+title1+" - "+console+"' title='"+title1+" - "+console+"' src='" + getImgBaseUrl() + "groups/public/documents/webasset/psv_imgcover.png' border='0' alt='' /></a></div>"
	}else{
		$("#main-box").css("border","1px solid #ededed");
		thumbArea += "<a href='"+hostName+pscomurl+"'><i></i> <img alt='"+title1+" - "+console+"' title='"+title1+" - "+console+"' src='"+thumbnail+"' border='0'  /></a>"
	}
	
	thumbArea += "</div><div class='game-text' id='game-text'><h5><a href='"+hostName+pscomurl+"'>"+title+"</a></h5>"
	thumbArea += "<p>"+description+"</p> </div><div class='arroWLink'>"
	thumbArea += "<a onclick=\"javascript:ClickhistoryOmni(this,'event71','"+hostName+pscomurl+"','RECENT_BROWSING_HISTORY/LEARN_MORE');\" href='"+hostName+pscomurl+"' >Learn more</a></div> </div></div></div>"
	
	
	
	document.getElementById("game-product").innerHTML = thumbArea;

}

//Recent Browsing history JS CODE ENDS
// for disabled add to wish list and add to my game
$(document).ready(function(){
	if(isAddLinksEnabled.toString()=="true"){
	}else{
		$("#wishlistGame a, #addgamediv a").removeAttr("onclick").attr("style","cursor:default;"); 
		$("#addgamediv a").parent().attr("style", "background:none;");
		$("#wishlistGame a").parent().attr("style", "background:none;");
		$("#wishlistGame a, #addgamediv a").hover(function(){
			$(this).css("color","#000");
		});
		$("#wishlistGame").remove();
		$("#addgamediv").remove();
	}
});


/* Sony Footer Logo (Sony Computer Entertainment) */
$(document).ready(function(){
	$(".below-allLinksImg .sonyLogo").css("display","block");
	
/***********************ONLY FOR BROWSEALL AND 404 DYNAMIC CHANGE starts**************************/
if(window.location.pathname.toLowerCase().indexOf("ps-products") != -1){
                $("#footer .community ul li").eq("2").html("<a onclick=javascript:ClickOmniTrack(this,'event37','Protection_Plan'); href='/support/protection-plan/index.htm' style='width:175px;'>Protection Plan</a>");
} 
if($("#SiteMap").hasClass("error_404") == true){
                $("#footer .community ul li").eq("2").html("<a onclick=javascript:ClickOmniTrack(this,'event37','Protection_Plan'); href='/support/protection-plan/index.htm'>Protection Plan</a>");
} 

/***********************ONLY FOR BROWSEALL AND 404 DYNAMIC CHANGE ends **************************/

}); 

function getSearchSiteValue() {

	var url = window.location.toString();
	var result = "";
	if(url.indexOf("/support") > -1) {
		result = "support";
		
	}
	return result;
}
