function selectdiv(divid){
	var d=document.getElementById(divid);
	if(d==null){
		return;
	}
	//ie
	if(document.selection){
		document.selection.empty();
		var range=document.body.createTextRange();
		range.moveToElementText(d);
		range.select();
	}
	else{
		if(window.getSelection){
			var range=document.createRange();
			range.selectNode(d);
			window.getSelection().removeAllRanges();
			window.getSelection().addRange(range);
		}
	}
}

function selectandcopy(divid){
	try{
		selectdiv(divid);
		var r=document.selection.createRange();
		r.execCommand("Copy");

	}
	catch(ex){
		alert('Sorry, your browser is not supported');
	}
}

function showhide(elemid){
	var elem=document.getElementById(elemid);
	if(elem==null){
		return;
	}
	if(elem.style.display=='none'){
		elem.style.display='';
	}
	else{
		elem.style.display='none';
	}
}
function serrate(isnegative,ispositive,itemtype,url_hash,cve_number,relateditemid){
	if(window.frames['ratingiframe']==null){
		alert("window.frames['ratingiframe']==null");
		return;
	}
	var f=window.frames['ratingiframe'].document.forms[0];
	f.action='/rate-item.php';
	if(isnegative==1){
		f.negative.value=1;
	}
	if(ispositive==1){
		f.positive.value=1;
	}
	f.itemtype.value=itemtype;
	f.url_hash.value=url_hash;
	f.cve_number.value=cve_number;
	f.relateditemid.value=relateditemid;
	f.submit();
}
function cvsshover(cvssscore){
	var t=document.getElementById('barchart_'+cvssscore);
	if(t==null){
		return;
	}
	t.style.background='#e6eEFF';
	var s=document.getElementById('barspan_'+cvssscore);
	if(s==null){
		return;
	}
	s.style.background='#e6eEFF';
}
function cvssmout(cvssscore){
	var t=document.getElementById('barchart_'+cvssscore);
	if(t==null){
		return;
	}
	t.style.background='';
	var s=document.getElementById('barspan_'+cvssscore);
	if(s==null){
		return;
	}
	s.style.background='';
}
function cvssclick(cs){
	var u='/vulnerability-list/cvssscoremin-';
	u=u+cs+'/cvssscoremax-';
	if(cs==9){
		u=u+"10";
	}
	else {
		u=u+cs+".99";
	}
	u=u+'/vulnerabilities.html';
	window.location.href=u;
}

function pm(itemid){
	var x=document.getElementById(itemid);
	var a=document.getElementById('pm_'+itemid);
	if(x==null || a==null ){
		return;
	}
	if(x.style.display=='none'){
		x.style.display='';
		a.innerHTML='-';
	}
	else{
		x.style.display='none';
		a.innerHTML='+';
	}
}


function collapseexpandall(isexpand){
	var allitems=new Array();
	allitems[0]='cvssscorestable';
	allitems[1]='vendorstatementsdiv';
	allitems[2]='ovaldefsmaindiv';
	allitems[3]='vulnprodstable';
	allitems[4]='vulnversconuttable';
	allitems[5]='vulncondstable';
	allitems[6]='vulnrefstable';
	allitems[7]='metasploitmodstable';
	allitems[8]='addvendsuppdata';

	for(var i=0;i<9;i++){
		var x=document.getElementById(allitems[i]);
		var a=document.getElementById('pm_'+allitems[i]);
		if(x==null || a==null ){
			continue;
		}
		if(isexpand){
			x.style.display='';
			a.innerHTML='-';
		}
		else{
			x.style.display='none';
			a.innerHTML='+';
		}
	}
}

function cvevalset(itemid,value){
	var s=document.getElementById(itemid);
	if(s!=null){
		s.innerHTML='('+value+')';
	}
}

function icantseethedropdownmenu(){
	var s=document.getElementById('mbscrolld');
	var b=document.getElementById('mbcommentsd');
	var e=document.getElementById('mbextlinksd');
	var td1=document.getElementById('menubarmain1');
	var td2=document.getElementById('menubarmain2');
	var td3=document.getElementById('menubarmain3');

	if(s!=null){
		s.style.display='block';
	}
	if(b!=null){
		b.style.display='block';
	}
	if(e!=null){
		e.style.display='block';
	}
	if(td1!=null){
		td1.style.width='190px';
	}
	if(td2!=null){
		td2.style.width='190px';
	}
	if(td3!=null){
		td3.style.width='190px';
	}
	
}

function seraddtofavorites(itemtype,relateditemid){
	if(window.frames['ratingiframe']==null){
		alert("window.frames['ratingiframe']==null");
		return;
	}
	var f=window.frames['ratingiframe'].document.forms[0];
	f.action='/user-add-favorite.php';
	f.itemtype.value=itemtype;
	f.relateditemid.value=relateditemid;
	f.submit();
}

