﻿var Sys = {};
var ua = navigator.userAgent.toLowerCase();
if (window.ActiveXObject)
    Sys.ie = ua.match(/msie ([\d.]+)/)[1]
else if (document.getBoxObjectFor)
    Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
else if (window.openDatabase)
    Sys.safari = ua.match(/version\/([\d.]+)/)[1];
function getPageTitle() {
	if (document.title.indexOf('/') != -1){
		return document.title.split("/")[1];
	}
	else{
		return document.getElementById('pageTitle').innerHTML;
	}
}
function topNavImg_Load(){
	var url = document.location.toString().toLowerCase();
    var topData = document.getElementById("TopData").innerHTML;
    var lst = topData.split("@ ");
    for (var i = 0; i < lst.length - 1; i++) { 
        var topNavlst=lst[i].split(";");
        var url1=topNavlst[2].toLowerCase();
        var url2=url1.substring(0,url1.indexOf('/',url1.indexOf('/',1)+1)+1);
        if (url.indexOf(url2) != -1) {
            var thisImg=document.getElementById(topNavlst[0]);
            if (thisImg!=null){
            	thisImg.onmouseover = function() { }
            	thisImg.onmouseout = function() { }
                thisImg.src=topNavlst[1];
                return;
            }
        }
    }
}
function topNav_Hover(obj) {
    if (obj != null) {
    	for (var i=0; i<top_nav_lists.length;i++){
    		if (obj.id==top_nav_lists[i][0] && obj.src.indexOf('_s')==-1){
    			obj.src="/social/PublishingImages/Social/"+top_nav_lists[i][1]+"_o.gif";
    		}
    	}
    }
}
function topNav_unHover(obj){
	if (obj != null) {
    	for (var i=0; i<top_nav_lists.length;i++){
    		if (obj.id==top_nav_lists[i][0] && obj.src.indexOf('_s')==-1){
    			obj.src="/social/PublishingImages/Social/"+top_nav_lists[i][1]+".gif";
    		}
    	}
    }
}
function SecNavImg_Load(sec_nav){
	var sec_nav_lists;
	if (sec_nav==0) sec_nav_lists=sec_nav_benifits;
	if (sec_nav==1) sec_nav_lists=sec_nav_community;
	if (sec_nav==2) sec_nav_lists=sec_nav_resources;
	
	for (var i=0; i<sec_nav_lists.length;i++){
		if (document.URL.toLocaleLowerCase().indexOf(sec_nav_lists[i][2].toLocaleLowerCase())!=-1)
			document.getElementById(sec_nav_lists[i][0]).src="/social/PublishingImages/Social/"+sec_nav_lists[i][1]+"_s.gif";
		else
			document.getElementById(sec_nav_lists[i][0]).src="/social/PublishingImages/Social/"+sec_nav_lists[i][1]+".gif";
	}
}
function sec_Nav_Hover(sec_nav,obj){
	var sec_nav_lists;
	if (sec_nav==0) sec_nav_lists=sec_nav_benifits;
	if (sec_nav==1) sec_nav_lists=sec_nav_community;
	if (sec_nav==2) sec_nav_lists=sec_nav_resources;

	if (obj != null) {
    	for (var i=0; i<sec_nav_lists.length;i++){
    		if (obj.id==sec_nav_lists[i][0] && obj.src.indexOf('_s')==-1){
    			obj.src="/social/PublishingImages/Social/"+sec_nav_lists[i][1]+"_o.gif";
    		}
    	}
    }
}
function sec_Nav_unHover(sec_nav,obj){
	var sec_nav_lists;
	if (sec_nav==0) sec_nav_lists=sec_nav_benifits;
	if (sec_nav==1) sec_nav_lists=sec_nav_community;
	if (sec_nav==2) sec_nav_lists=sec_nav_resources;

	if (obj != null) {
    	for (var i=0; i<sec_nav_lists.length;i++){
    		if (obj.id==sec_nav_lists[i][0] && obj.src.indexOf('_s')==-1){
    			obj.src="/social/PublishingImages/Social/"+sec_nav_lists[i][1]+".gif";
    		}
    	}
    }
}

function searchSP(){
	var searchkey=document.getElementById('searchField');
	if(searchkey.value == "")
	{
		alert("search key words cannot be null!");
	}
	else
	{
		window.open('/social/SearchCenter/Pages/results.aspx?k='+searchkey.value+'&cs=%2Fsocial%2FSearchCenter%2FPages%2Fdefault.aspx','_self');
	}		
}
function searchWeb(){
	var searchkey=document.getElementById('searchField');
	if(searchkey.value == "")
	{
		alert("search key words cannot be null!");
	}
	else
	{
		window.open('http://search.live.com/results.aspx?q='+searchkey.value+'&src=IE-SearchBox');
	}
}

//Display Silverlight
var slRelativeUrl="/social/Hero%20Content%20Documents/"; 
var slSources=[['Home','08MS7202_SharePointHeader.xap','968px','274px'],
			  ['Benifits','08MS7202_featureHeader.xap','1024px','77px'],
			  ['Demo','DemoHeader.xap','1024px','77px'],
			  ['Successes','SuccessesHeader.xap','1024px','77px'],
			  ['Community','CommunityHeader.xap','1024px','77px'],
			  ['Partners','PartnersHeader.xap','1024px','77px'],
			  ['Resources','ResourcesHeader.xap','1024px','77px'],
			  ['DemoPlayer','DemoPlayer.xap','640px','415px'],
			  ['SuccessesPlayer','DemoPlayer.xap','640px','415px'],
			  ['CommunityPlayer','DemoPlayer.xap','640px','415px']];
function CheckBrowers(){
	if(Sys.ie) return "ie";
	if(Sys.firefox) return "firefox";
	if(Sys.safari) return 'safari';
	
	return "ie";
}		  
function CheckSilverlight(name){
	for (var i=0;i<slSources.length;i++){
		if (name==slSources[i][0]){
			return i;
		}
	}
	return -1;
}
function WriteSilverLight(name){
	var slObject = "";
	var urlHeader=document.URL.substring(0, document.URL.indexOf("/", 7));
	var num=CheckSilverlight(name);
	if (num==-1) return;
	
	slObject += '<object id="sl" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="'+slSources[num][2]+'" height="'+slSources[num][3]+'">';
	slObject += '<param name="source" value="'+slRelativeUrl+slSources[num][1]+'" />';
    slObject += '<param name="onerror" value="onSilverlightError" />';	
	if (CheckBrowers()!='safari'){
		slObject+="<param name='background' value='Transparent' />";
		slObject+="<param name='windowless' value='true' />";
	} else
		slObject+="<param name='background' value='White' />";
	slObject += '<param name="minRuntimeVersion" value="2.0.31005.0" />';
    slObject += '<param name="autoUpgrade" value="true" />';
    if (name=='DemoPlayer' || name=='SuccessesPlayer' || name=='CommunityPlayer'){
        var url=document.getElementById("previewdemovideo");
        var frame=document.getElementById("VideoThumb");
        var link;
        var frameNum=0;
        if (url!=null && frame!=null){
        	link=url.innerHTML;
        	if (frame.innerHTML.toLowerCase().indexOf('http://')==-1)
        		frameNum=urlHeader+frame.innerHTML;
        	else
        		frameNum=frame.innerHTML;	
        }
        else{
        	if (location.search.split("&").length>1)
        	{ 
        	    paraSet=location.search.split("&");
        	    link=paraSet[0].split("=")[1];
        	    frameNum=paraSet[1].split("=")[1];
        	}
           	else return;
        }
        switch(name){
        	case 'DemoPlayer':
        		slObject += '<param name="initParams" value="VideoLink='+link+',PreviewFrame='+frameNum+'"/>';
        		break;
        	case 'SuccessesPlayer':
        		slObject += '<param name="initParams" value="VideoLink='+link+',PreviewFrame='+frameNum+',Style=yellow"/>';
        		break;
        	case 'CommunityPlayer':
        		slObject += '<param name="initParams" value="VideoLink='+link+',PreviewFrame='+frameNum+',Style=orange"/>';
        		break;
        }
    }
    slObject += '<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">';
    slObject += '<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/></a></object>';
	
	document.write(slObject);
}
function MouseOverImage(object){  
   temp=object.src;
   object.src=object.getAttribute('hover');
}
function MouseOutImage(object){
 object.src=temp;
}
function queryurl(){ 
 var image=document.getElementById("secnavimages1");
 if(image != null)
   { 
    var address = window.location.href.toLowerCase();
 
    var a = address.split(token);
    if(a[1].indexOf("?")>=0)
     {
       a=a[1].split("?");
       a[1]=a[0];
}
for(i=1;i<parseInt(image.getAttribute('total'))+1;i++){    
    j=i;
    j=j+'';
    if(document.getElementById("secnavimages"+j).parentNode.href.toLowerCase().indexOf(a[1])>0){     
      document.getElementById("secnavimages"+j).src=document.getElementById("secnavimages"+j).getAttribute('selectedimage');
      document.getElementById("secnavimages"+j).onmouseover=function(){};
      document.getElementById("secnavimages"+j).onmouseout=function(){};
 }
}
}
}
 function queryurltop(){ 
 var image=document.getElementById("topnavimages1");
 var param; 
 if(image != null)
 { 
    var address = window.location.href.toLowerCase();
    var a = address.split("social");
    if(a[1].indexOf("?")>=0){
       a=a[1].split("?");
       a[1]=a[0];
	}
   a[1]= "social/"+ a[1].split("/")[1];                            
for(i=1;i<parseInt(image.getAttribute('total'))+1;i++){    
    j=i;
    j=j+'';
         if(document.getElementById("topnavimages"+j).parentNode.href.toLowerCase().indexOf(a[1])>0)
{     
      document.getElementById("topnavimages"+j).src=document.getElementById("topnavimages"+j).getAttribute('selectedimage');
document.getElementById("topnavimages"+j).onmouseover=function(){};
 document.getElementById("topnavimages"+j).onmouseout=function(){};
 }
}
}
}
     var tokenSelected = "Selected/";
     var tokenOnhover = "Onhover/";
     var tokenDefault = "Default/";
 function addEvent(func) {
            oldFunc = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            }
            else {
                window.onload = function() {

                    func();
                    oldFunc();


                }
            }
        }
        function setDefaultImage(imageNo) {
            var imageDefault = document.getElementById(imageNo);

            var sourceImage = imageDefault.src;
            var result = sourceImage.replace(tokenDefault, tokenSelected);
            imageDefault.src = result;
        }
         
        function getQueryString() {
        
         var length;
         var address = window.location.href;
                  
           if(address.indexOf(token)>=0)                          
              {
              var a = address.split(token);
              var image=document.getElementById(identity + a[1]);
              var sourceImage = image.src;
              image.src=sourceImage.replace(tokenDefault, tokenSelected);


               }
else {
          image=document.getElementById(identity+defaultselectedid);
          image.src=image.src.replace(tokenDefault, tokenSelected);

}
            
              
        }
  function mouseOver(object) {

            var sourceImage = object.src;
            temp=sourceImage;
            var result = sourceImage.replace(tokenDefault, tokenOnhover);
            object.src = result;


        }
        function mouseOut(object) {
            object.src = temp;
          
        }
  function digg(object)
 {
   object.href="http://digg.com/submit?phase=2&amp;url="+document.location.href;
 }
 
    function delicious(object)
 {
    object.href="http://del.icio.us/post?url="+document.location.href+"&amp;title="+document.title+"&amp;notes=social";

 }
function twitter(object)
   {
      object.href= "http://twitter.com/home?status=SharePoint Social Computing "+ document.title + " - " + document.location.href;
               
     }
       
       function facebook(object)
       {
             object.href="http://www.facebook.com/sharer.php?u="+document.location.href+"&amp;"+"t=SharePoint Social Computing " + document.title;
       }
            
            
